blob: 2d5e14866373e70dd49662e24a052629d9f44229 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
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>
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053042
43/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
44 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053045 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053046 * @cmd: pointer target vdev create command buffer
47 * @param: pointer host params for vdev create
48 *
49 * Return: None
50 */
51#ifdef CONFIG_MCL
52static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053053 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053054 wmi_vdev_create_cmd_fixed_param * cmd,
55 struct vdev_create_params *param)
56{
57 cmd->pdev_id = WMI_PDEV_ID_SOC;
58}
59#else
60static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053061 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053062 wmi_vdev_create_cmd_fixed_param * cmd,
63 struct vdev_create_params *param)
64{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053065 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
66 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053067}
68#endif
69
Govind Singh5eb51532016-03-09 11:34:12 +053070/**
71 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
72 * @wmi_handle: wmi handle
73 * @param: pointer to hold vdev create parameter
74 * @macaddr: vdev mac address
75 *
Govind Singhe7f2f342016-05-23 12:12:52 +053076 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053077 */
Sathish Kumarfd347372017-02-13 12:29:09 +053078static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053079 uint8_t macaddr[IEEE80211_ADDR_LEN],
80 struct vdev_create_params *param)
81{
82 wmi_vdev_create_cmd_fixed_param *cmd;
83 wmi_buf_t buf;
84 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053085 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070086 int num_bands = 2;
87 uint8_t *buf_ptr;
88 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053089
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070090 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053091 buf = wmi_buf_alloc(wmi_handle, len);
92 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053093 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053094 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053095 }
96 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
97 WMITLV_SET_HDR(&cmd->tlv_header,
98 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
99 WMITLV_GET_STRUCT_TLVLEN
100 (wmi_vdev_create_cmd_fixed_param));
101 cmd->vdev_id = param->if_id;
102 cmd->vdev_type = param->type;
103 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700104 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530105 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530106 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700107 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
108 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530109 macaddr[0], macaddr[1], macaddr[2],
110 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700111 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
112 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
113 (num_bands * sizeof(wmi_vdev_txrx_streams)));
114 buf_ptr += WMI_TLV_HDR_SIZE;
115
Govind Singh224a7312016-06-21 14:33:26 +0530116 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700117 param->type, param->subtype,
118 param->nss_2g, param->nss_5g);
119 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
120 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
121 txrx_streams->supported_tx_streams = param->nss_2g;
122 txrx_streams->supported_rx_streams = param->nss_2g;
123 WMITLV_SET_HDR(&txrx_streams->tlv_header,
124 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
125 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
126
127 txrx_streams++;
128 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
129 txrx_streams->supported_tx_streams = param->nss_5g;
130 txrx_streams->supported_rx_streams = param->nss_5g;
131 WMITLV_SET_HDR(&txrx_streams->tlv_header,
132 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
133 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530134 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530135 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530136 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530137 wmi_buf_free(buf);
138 }
139
140 return ret;
141}
142
143/**
144 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
145 * @wmi_handle: wmi handle
146 * @if_id: vdev id
147 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530148 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530149 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530150static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530151 uint8_t if_id)
152{
153 wmi_vdev_delete_cmd_fixed_param *cmd;
154 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530155 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530156
157 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
158 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530159 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530160 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530161 }
162
163 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
164 WMITLV_SET_HDR(&cmd->tlv_header,
165 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
166 WMITLV_GET_STRUCT_TLVLEN
167 (wmi_vdev_delete_cmd_fixed_param));
168 cmd->vdev_id = if_id;
169 ret = wmi_unified_cmd_send(wmi_handle, buf,
170 sizeof(wmi_vdev_delete_cmd_fixed_param),
171 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530172 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530173 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530174 wmi_buf_free(buf);
175 }
Govind Singhb53420c2016-03-09 14:32:57 +0530176 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530177
178 return ret;
179}
180
181/**
182 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
183 * @wmi: wmi handle
184 * @vdev_id: vdev id
185 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530186 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530187 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530188static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530189 uint8_t vdev_id)
190{
191 wmi_vdev_stop_cmd_fixed_param *cmd;
192 wmi_buf_t buf;
193 int32_t len = sizeof(*cmd);
194
195 buf = wmi_buf_alloc(wmi, len);
196 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530197 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530198 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530199 }
200 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
201 WMITLV_SET_HDR(&cmd->tlv_header,
202 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
203 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
204 cmd->vdev_id = vdev_id;
205 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530206 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530207 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530208 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530209 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530210 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530211
212 return 0;
213}
214
215/**
216 * send_vdev_down_cmd_tlv() - send vdev down command to fw
217 * @wmi: wmi handle
218 * @vdev_id: vdev id
219 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530220 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530221 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530222static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530223{
224 wmi_vdev_down_cmd_fixed_param *cmd;
225 wmi_buf_t buf;
226 int32_t len = sizeof(*cmd);
227
228 buf = wmi_buf_alloc(wmi, len);
229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530230 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530231 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530232 }
233 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
234 WMITLV_SET_HDR(&cmd->tlv_header,
235 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
236 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
237 cmd->vdev_id = vdev_id;
238 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530239 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530240 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530241 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530242 }
Govind Singhb53420c2016-03-09 14:32:57 +0530243 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530244
245 return 0;
246}
247
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530248#ifdef CONFIG_MCL
249static inline void copy_channel_info(
250 wmi_vdev_start_request_cmd_fixed_param * cmd,
251 wmi_channel *chan,
252 struct vdev_start_params *req)
253{
254 chan->mhz = req->chan_freq;
255
256 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
257
258 chan->band_center_freq1 = req->band_center_freq1;
259 chan->band_center_freq2 = req->band_center_freq2;
260
261 if (req->is_half_rate)
262 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
263 else if (req->is_quarter_rate)
264 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
265
Naveen Rawat44f2f432016-12-01 12:58:57 -0800266 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530267 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
268 cmd->disable_hw_ack = req->dis_hw_ack;
269 }
270
271 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
272 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
273
274}
275#else
276static inline void copy_channel_info(
277 wmi_vdev_start_request_cmd_fixed_param * cmd,
278 wmi_channel *chan,
279 struct vdev_start_params *req)
280{
281 chan->mhz = req->channel.mhz;
282
283 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
284
285 chan->band_center_freq1 = req->channel.cfreq1;
286 chan->band_center_freq2 = req->channel.cfreq2;
287
288 if (req->channel.half_rate)
289 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
290 else if (req->channel.quarter_rate)
291 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
292
293 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530294 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530295 cmd->disable_hw_ack = req->disable_hw_ack;
296 }
297
Krishna Rao0b952ea2017-03-20 13:30:10 +0530298 if (req->channel.dfs_set_cfreq2)
299 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
300
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530301 /* FIXME: Find out min, max and regulatory power levels */
302 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
303 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
304
305}
306#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530307/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530308 * send_vdev_start_cmd_tlv() - send vdev start request to fw
309 * @wmi_handle: wmi handle
310 * @req: vdev start params
311 *
312 * Return: QDF status
313 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530314static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530315 struct vdev_start_params *req)
316{
317 wmi_vdev_start_request_cmd_fixed_param *cmd;
318 wmi_buf_t buf;
319 wmi_channel *chan;
320 int32_t len, ret;
321 uint8_t *buf_ptr;
322
323 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
324 buf = wmi_buf_alloc(wmi_handle, len);
325 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530326 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530327 return QDF_STATUS_E_NOMEM;
328 }
329 buf_ptr = (uint8_t *) wmi_buf_data(buf);
330 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
331 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
332 WMITLV_SET_HDR(&cmd->tlv_header,
333 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
334 WMITLV_GET_STRUCT_TLVLEN
335 (wmi_vdev_start_request_cmd_fixed_param));
336 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
337 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
338 cmd->vdev_id = req->vdev_id;
339
340 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530341 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530342
343 cmd->beacon_interval = req->beacon_intval;
344 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530345
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800346 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
347 if (req->bcn_tx_rate_code)
348 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
349
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530351 cmd->beacon_interval = req->beacon_intval;
352 cmd->dtim_period = req->dtim_period;
353
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530354 /* Copy the SSID */
355 if (req->ssid.length) {
356 if (req->ssid.length < sizeof(cmd->ssid.ssid))
357 cmd->ssid.ssid_len = req->ssid.length;
358 else
359 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
360 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
361 cmd->ssid.ssid_len);
362 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530363
364 if (req->hidden_ssid)
365 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
366
367 if (req->pmf_enabled)
368 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530369 }
370
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700371 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530372 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530373 cmd->preferred_rx_streams = req->preferred_rx_streams;
374 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700375 cmd->cac_duration_ms = req->cac_duration_ms;
376 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700377 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378
379 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
380 sizeof(wmi_channel));
381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
382 cmd->num_noa_descriptors *
383 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800384 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
386 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700387 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800388 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389 req->is_dfs, req->beacon_intval, cmd->dtim_period,
390 chan->band_center_freq1, chan->band_center_freq2,
391 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700392 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700393 req->ldpc_rx_enabled, req->cac_duration_ms,
394 req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530395
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 if (req->is_restart)
397 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
398 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530399 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530400 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
401 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530402 if (ret) {
403 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530404 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530405 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530406 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407
408 return QDF_STATUS_SUCCESS;
409}
410
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530411/**
412 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
413 * @wmi_handle: wmi handle
414 * @restart_params: vdev restart params
415 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530416 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530417 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530418static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530419 struct hidden_ssid_vdev_restart_params *restart_params)
420{
421 wmi_vdev_start_request_cmd_fixed_param *cmd;
422 wmi_buf_t buf;
423 wmi_channel *chan;
424 int32_t len;
425 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530426 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530427
428 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
429 buf = wmi_buf_alloc(wmi_handle, len);
430 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530431 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530432 return QDF_STATUS_E_NOMEM;
433 }
434 buf_ptr = (uint8_t *) wmi_buf_data(buf);
435 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
436 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
437
438 WMITLV_SET_HDR(&cmd->tlv_header,
439 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
440 WMITLV_GET_STRUCT_TLVLEN
441 (wmi_vdev_start_request_cmd_fixed_param));
442
443 WMITLV_SET_HDR(&chan->tlv_header,
444 WMITLV_TAG_STRUC_wmi_channel,
445 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
446
447 cmd->vdev_id = restart_params->session_id;
448 cmd->ssid.ssid_len = restart_params->ssid_len;
449 qdf_mem_copy(cmd->ssid.ssid,
450 restart_params->ssid,
451 cmd->ssid.ssid_len);
452 cmd->flags = restart_params->flags;
453 cmd->requestor_id = restart_params->requestor_id;
454 cmd->disable_hw_ack = restart_params->disable_hw_ack;
455
456 chan->mhz = restart_params->mhz;
457 chan->band_center_freq1 =
458 restart_params->band_center_freq1;
459 chan->band_center_freq2 =
460 restart_params->band_center_freq2;
461 chan->info = restart_params->info;
462 chan->reg_info_1 = restart_params->reg_info_1;
463 chan->reg_info_2 = restart_params->reg_info_2;
464
465 cmd->num_noa_descriptors = 0;
466 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
467 sizeof(wmi_channel));
468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
469 cmd->num_noa_descriptors *
470 sizeof(wmi_p2p_noa_descriptor));
471
472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
473 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530474 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530475 wmi_buf_free(buf);
476 return QDF_STATUS_E_FAILURE;
477 }
478 return QDF_STATUS_SUCCESS;
479}
480
481
482/**
Govind Singh5eb51532016-03-09 11:34:12 +0530483 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
484 * @wmi: wmi handle
485 * @peer_addr: peer mac address
486 * @param: pointer to hold peer flush tid parameter
487 *
488 * Return: 0 for sucess or error code
489 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530490static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530491 uint8_t peer_addr[IEEE80211_ADDR_LEN],
492 struct peer_flush_params *param)
493{
494 wmi_peer_flush_tids_cmd_fixed_param *cmd;
495 wmi_buf_t buf;
496 int32_t len = sizeof(*cmd);
497
498 buf = wmi_buf_alloc(wmi, len);
499 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530500 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530501 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530502 }
503 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
504 WMITLV_SET_HDR(&cmd->tlv_header,
505 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
506 WMITLV_GET_STRUCT_TLVLEN
507 (wmi_peer_flush_tids_cmd_fixed_param));
508 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
509 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
510 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530511 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530512 peer_addr, param->vdev_id,
513 param->peer_tid_bitmap);
514 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530515 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530516 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530517 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530518 }
519
520 return 0;
521}
522
523/**
524 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
525 * @wmi: wmi handle
526 * @peer_addr: peer mac addr
527 * @vdev_id: vdev id
528 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530529 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530530 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530531static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530532 uint8_t peer_addr[IEEE80211_ADDR_LEN],
533 uint8_t vdev_id)
534{
535 wmi_peer_delete_cmd_fixed_param *cmd;
536 wmi_buf_t buf;
537 int32_t len = sizeof(*cmd);
538 buf = wmi_buf_alloc(wmi, len);
539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530540 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530541 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530542 }
543 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
544 WMITLV_SET_HDR(&cmd->tlv_header,
545 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
546 WMITLV_GET_STRUCT_TLVLEN
547 (wmi_peer_delete_cmd_fixed_param));
548 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
549 cmd->vdev_id = vdev_id;
550
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800551 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530552 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530553 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530554 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530555 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530556 }
Govind Singh5eb51532016-03-09 11:34:12 +0530557
558 return 0;
559}
560
561/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530562 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
563 * to target id.
564 * @targ_paramid: Target parameter id to hold the result.
565 * @peer_param_id: host param id.
566 *
567 * Return: QDF_STATUS_SUCCESS for success
568 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
569 */
570#ifdef CONFIG_MCL
571static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
572 uint32_t *targ_paramid,
573 uint32_t peer_param_id)
574{
575 *targ_paramid = peer_param_id;
576 return QDF_STATUS_SUCCESS;
577}
578#else
579static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
580 uint32_t *targ_paramid,
581 uint32_t peer_param_id)
582{
583 switch (peer_param_id) {
584 case WMI_HOST_PEER_MIMO_PS_STATE:
585 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
586 break;
587 case WMI_HOST_PEER_AMPDU:
588 *targ_paramid = WMI_PEER_AMPDU;
589 break;
590 case WMI_HOST_PEER_AUTHORIZE:
591 *targ_paramid = WMI_PEER_AUTHORIZE;
592 break;
593 case WMI_HOST_PEER_CHWIDTH:
594 *targ_paramid = WMI_PEER_CHWIDTH;
595 break;
596 case WMI_HOST_PEER_NSS:
597 *targ_paramid = WMI_PEER_NSS;
598 break;
599 case WMI_HOST_PEER_USE_4ADDR:
600 *targ_paramid = WMI_PEER_USE_4ADDR;
601 break;
602 case WMI_HOST_PEER_MEMBERSHIP:
603 *targ_paramid = WMI_PEER_MEMBERSHIP;
604 break;
605 case WMI_HOST_PEER_USERPOS:
606 *targ_paramid = WMI_PEER_USERPOS;
607 break;
608 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
609 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
610 break;
611 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
612 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
613 break;
614 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
615 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
616 break;
617 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
618 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
619 break;
620 case WMI_HOST_PEER_PHYMODE:
621 *targ_paramid = WMI_PEER_PHYMODE;
622 break;
623 case WMI_HOST_PEER_USE_FIXED_PWR:
624 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
625 break;
626 case WMI_HOST_PEER_PARAM_FIXED_RATE:
627 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
628 break;
629 case WMI_HOST_PEER_SET_MU_WHITELIST:
630 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
631 break;
632 case WMI_HOST_PEER_SET_MAC_TX_RATE:
633 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
634 break;
635 case WMI_HOST_PEER_SET_MIN_TX_RATE:
636 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
637 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530638 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
639 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
640 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530641 case WMI_HOST_PEER_NSS_VHT160:
642 *targ_paramid = WMI_PEER_NSS_VHT160;
643 break;
644 case WMI_HOST_PEER_NSS_VHT80_80:
645 *targ_paramid = WMI_PEER_NSS_VHT80_80;
646 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530647 default:
648 return QDF_STATUS_E_NOSUPPORT;
649 }
650
651 return QDF_STATUS_SUCCESS;
652}
653#endif
654/**
Govind Singh5eb51532016-03-09 11:34:12 +0530655 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530656 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530657 * @peer_addr: peer mac address
658 * @param : pointer to hold peer set parameter
659 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530660 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530661 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530662static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530663 uint8_t peer_addr[IEEE80211_ADDR_LEN],
664 struct peer_set_params *param)
665{
666 wmi_peer_set_param_cmd_fixed_param *cmd;
667 wmi_buf_t buf;
668 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530669 uint32_t param_id;
670
671 if (convert_host_peer_id_to_target_id_tlv(&param_id,
672 param->param_id) != QDF_STATUS_SUCCESS)
673 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530674
675 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
676 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530677 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530678 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530679 }
680 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
681 WMITLV_SET_HDR(&cmd->tlv_header,
682 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
683 WMITLV_GET_STRUCT_TLVLEN
684 (wmi_peer_set_param_cmd_fixed_param));
685 cmd->vdev_id = param->vdev_id;
686 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530687 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530688 cmd->param_value = param->param_value;
689 err = wmi_unified_cmd_send(wmi, buf,
690 sizeof(wmi_peer_set_param_cmd_fixed_param),
691 WMI_PEER_SET_PARAM_CMDID);
692 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530693 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530694 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530695 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530696 }
697
698 return 0;
699}
700
701/**
702 * send_vdev_up_cmd_tlv() - send vdev up command in fw
703 * @wmi: wmi handle
704 * @bssid: bssid
705 * @vdev_up_params: pointer to hold vdev up parameter
706 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530707 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530708 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530709static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530710 uint8_t bssid[IEEE80211_ADDR_LEN],
711 struct vdev_up_params *params)
712{
713 wmi_vdev_up_cmd_fixed_param *cmd;
714 wmi_buf_t buf;
715 int32_t len = sizeof(*cmd);
716
Govind Singhb53420c2016-03-09 14:32:57 +0530717 WMI_LOGD("%s: VDEV_UP", __func__);
718 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530719 params->vdev_id, params->assoc_id, bssid);
720 buf = wmi_buf_alloc(wmi, len);
721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530722 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530723 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530724 }
725 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
726 WMITLV_SET_HDR(&cmd->tlv_header,
727 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
728 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
729 cmd->vdev_id = params->vdev_id;
730 cmd->vdev_assoc_id = params->assoc_id;
731 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
732 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530733 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530734 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530735 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530736 }
737
738 return 0;
739}
740
741/**
742 * send_peer_create_cmd_tlv() - send peer create command to fw
743 * @wmi: wmi handle
744 * @peer_addr: peer mac address
745 * @peer_type: peer type
746 * @vdev_id: vdev id
747 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530748 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530749 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530750static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530751 struct peer_create_params *param)
752{
753 wmi_peer_create_cmd_fixed_param *cmd;
754 wmi_buf_t buf;
755 int32_t len = sizeof(*cmd);
756
757 buf = wmi_buf_alloc(wmi, len);
758 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530759 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530760 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530761 }
762 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
763 WMITLV_SET_HDR(&cmd->tlv_header,
764 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
765 WMITLV_GET_STRUCT_TLVLEN
766 (wmi_peer_create_cmd_fixed_param));
767 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
768 cmd->peer_type = param->peer_type;
769 cmd->vdev_id = param->vdev_id;
770
771 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530772 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530773 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530774 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530775 }
Govind Singhb53420c2016-03-09 14:32:57 +0530776 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530777 param->vdev_id);
778
779 return 0;
780}
781
782/**
Leo Changeee40872016-09-28 13:43:36 -0700783 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
784 * command to fw
785 * @wmi: wmi handle
786 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
787 *
788 * Return: 0 for success or error code
789 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700790static
Leo Changeee40872016-09-28 13:43:36 -0700791QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
792 struct rx_reorder_queue_setup_params *param)
793{
794 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
795 wmi_buf_t buf;
796 int32_t len = sizeof(*cmd);
797
798 buf = wmi_buf_alloc(wmi, len);
799 if (!buf) {
800 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
801 return QDF_STATUS_E_NOMEM;
802 }
803 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
804 WMITLV_SET_HDR(&cmd->tlv_header,
805 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
806 WMITLV_GET_STRUCT_TLVLEN
807 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
808 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
809 cmd->vdev_id = param->vdev_id;
810 cmd->tid = param->tid;
811 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
812 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
813 cmd->queue_no = param->queue_no;
814
815 if (wmi_unified_cmd_send(wmi, buf, len,
816 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
817 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
818 __func__);
819 qdf_nbuf_free(buf);
820 return QDF_STATUS_E_FAILURE;
821 }
822 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
823 param->peer_macaddr, param->vdev_id, param->tid);
824
825 return QDF_STATUS_SUCCESS;
826}
827
828/**
829 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
830 * command to fw
831 * @wmi: wmi handle
832 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
833 *
834 * Return: 0 for success or error code
835 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700836static
Leo Changeee40872016-09-28 13:43:36 -0700837QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
838 struct rx_reorder_queue_remove_params *param)
839{
840 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
841 wmi_buf_t buf;
842 int32_t len = sizeof(*cmd);
843
844 buf = wmi_buf_alloc(wmi, len);
845 if (!buf) {
846 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
847 return QDF_STATUS_E_NOMEM;
848 }
849 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
850 wmi_buf_data(buf);
851 WMITLV_SET_HDR(&cmd->tlv_header,
852 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
853 WMITLV_GET_STRUCT_TLVLEN
854 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
855 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
856 cmd->vdev_id = param->vdev_id;
857 cmd->tid_mask = param->peer_tid_bitmap;
858
859 if (wmi_unified_cmd_send(wmi, buf, len,
860 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
861 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
862 __func__);
863 qdf_nbuf_free(buf);
864 return QDF_STATUS_E_FAILURE;
865 }
866 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
867 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
868
869 return QDF_STATUS_SUCCESS;
870}
871
872/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530873 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
874 * @wmi_handle: wmi handle
875 * @param: pointer holding peer details
876 *
877 * Return: 0 for success or error code
878 */
879static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
880 struct peer_add_wds_entry_params *param)
881{
882 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
883 wmi_buf_t buf;
884 int len = sizeof(*cmd);
885
886 buf = wmi_buf_alloc(wmi_handle, len);
887 if (!buf) {
888 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
889 return QDF_STATUS_E_FAILURE;
890 }
891 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
892 WMITLV_SET_HDR(&cmd->tlv_header,
893 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
894 WMITLV_GET_STRUCT_TLVLEN
895 (wmi_peer_add_wds_entry_cmd_fixed_param));
896 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
897 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
898 cmd->flags = param->flags;
899
900 return wmi_unified_cmd_send(wmi_handle, buf, len,
901 WMI_PEER_ADD_WDS_ENTRY_CMDID);
902}
903
904/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530905 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530906 * @wmi_handle: wmi handle
907 * @param: pointer holding peer details
908 *
909 * Return: 0 for success or error code
910 */
911static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
912 struct peer_del_wds_entry_params *param)
913{
914 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
915 wmi_buf_t buf;
916 int len = sizeof(*cmd);
917
918 buf = wmi_buf_alloc(wmi_handle, len);
919 if (!buf) {
920 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
921 return QDF_STATUS_E_NOMEM;
922 }
923 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
924 WMITLV_SET_HDR(&cmd->tlv_header,
925 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
926 WMITLV_GET_STRUCT_TLVLEN
927 (wmi_peer_remove_wds_entry_cmd_fixed_param));
928 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
929 return wmi_unified_cmd_send(wmi_handle, buf, len,
930 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
931}
932
933/**
934 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
935 * @wmi_handle: wmi handle
936 * @param: pointer holding peer details
937 *
938 * Return: 0 for success or error code
939 */
940static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
941 struct peer_update_wds_entry_params *param)
942{
943 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
944 wmi_buf_t buf;
945 int len = sizeof(*cmd);
946
947 buf = wmi_buf_alloc(wmi_handle, len);
948 if (!buf) {
949 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
950 return QDF_STATUS_E_NOMEM;
951 }
952
953 /* wmi_buf_alloc returns zeroed command buffer */
954 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
955 WMITLV_SET_HDR(&cmd->tlv_header,
956 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
957 WMITLV_GET_STRUCT_TLVLEN
958 (wmi_peer_update_wds_entry_cmd_fixed_param));
959 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
960 if (param->wds_macaddr)
961 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
962 &cmd->wds_macaddr);
963 if (param->peer_macaddr)
964 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
965 &cmd->peer_macaddr);
966 return wmi_unified_cmd_send(wmi_handle, buf, len,
967 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
968}
969
970
971
972/**
Govind Singh5eb51532016-03-09 11:34:12 +0530973 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
974 * @wmi_handle: wmi handle
975 * @value: value
976 * @mac_id: mac id to have radio context
977 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530978 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530979 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530980static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530981 uint32_t value, uint8_t mac_id)
982{
983 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
984 wmi_buf_t buf;
985 int32_t len = sizeof(*cmd);
986
Govind Singhb53420c2016-03-09 14:32:57 +0530987 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530988
989 buf = wmi_buf_alloc(wmi_handle, len);
990 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530991 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530992 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530993 }
994
995 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
996 WMITLV_SET_HDR(&cmd->tlv_header,
997 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
998 WMITLV_GET_STRUCT_TLVLEN
999 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301000 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301001 cmd->enable = value;
1002
1003 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1004 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301005 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301006 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301007 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301008 }
1009
1010 return 0;
1011}
1012
1013/**
1014 * send_pdev_utf_cmd_tlv() - send utf command to fw
1015 * @wmi_handle: wmi handle
1016 * @param: pointer to pdev_utf_params
1017 * @mac_id: mac id to have radio context
1018 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301019 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301021static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301022send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1023 struct pdev_utf_params *param,
1024 uint8_t mac_id)
1025{
1026 wmi_buf_t buf;
1027 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001028 /* if param->len is 0 no data is sent, return error */
1029 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301030 static uint8_t msgref = 1;
1031 uint8_t segNumber = 0, segInfo, numSegments;
1032 uint16_t chunk_len, total_bytes;
1033 uint8_t *bufpos;
1034 struct seg_hdr_info segHdrInfo;
1035
1036 bufpos = param->utf_payload;
1037 total_bytes = param->len;
1038 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1039 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1040 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1041
1042 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1043 numSegments++;
1044
1045 while (param->len) {
1046 if (param->len > MAX_WMI_UTF_LEN)
1047 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1048 else
1049 chunk_len = param->len;
1050
1051 buf = wmi_buf_alloc(wmi_handle,
1052 (chunk_len + sizeof(segHdrInfo) +
1053 WMI_TLV_HDR_SIZE));
1054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301055 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301056 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301057 }
1058
1059 cmd = (uint8_t *) wmi_buf_data(buf);
1060
1061 segHdrInfo.len = total_bytes;
1062 segHdrInfo.msgref = msgref;
1063 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1064 segHdrInfo.segmentInfo = segInfo;
1065 segHdrInfo.pad = 0;
1066
Govind Singhb53420c2016-03-09 14:32:57 +05301067 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301068 " segHdrInfo.segmentInfo = %d",
1069 __func__, segHdrInfo.len, segHdrInfo.msgref,
1070 segHdrInfo.segmentInfo);
1071
Govind Singhb53420c2016-03-09 14:32:57 +05301072 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301073 "chunk len %d", __func__, total_bytes, segNumber,
1074 numSegments, chunk_len);
1075
1076 segNumber++;
1077
1078 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1079 (chunk_len + sizeof(segHdrInfo)));
1080 cmd += WMI_TLV_HDR_SIZE;
1081 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1082 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1083
1084 ret = wmi_unified_cmd_send(wmi_handle, buf,
1085 (chunk_len + sizeof(segHdrInfo) +
1086 WMI_TLV_HDR_SIZE),
1087 WMI_PDEV_UTF_CMDID);
1088
Govind Singh67922e82016-04-01 16:48:57 +05301089 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301090 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301091 wmi_buf_free(buf);
1092 break;
1093 }
1094
1095 param->len -= chunk_len;
1096 bufpos += chunk_len;
1097 }
1098
1099 msgref++;
1100
1101 return ret;
1102}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301103#ifdef CONFIG_MCL
1104static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1105 uint32_t host_param)
1106{
1107 return host_param;
1108}
1109#else
1110static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1111 uint32_t host_param)
1112{
1113 if (host_param < wmi_pdev_param_max)
1114 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301115
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301116 return WMI_UNAVAILABLE_PARAM;
1117}
1118#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301119/**
1120 * send_pdev_param_cmd_tlv() - set pdev parameters
1121 * @wmi_handle: wmi handle
1122 * @param: pointer to pdev parameter
1123 * @mac_id: radio context
1124 *
1125 * Return: 0 on success, errno on failure
1126 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301127static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301128send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1129 struct pdev_params *param,
1130 uint8_t mac_id)
1131{
Govind Singh67922e82016-04-01 16:48:57 +05301132 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301133 wmi_pdev_set_param_cmd_fixed_param *cmd;
1134 wmi_buf_t buf;
1135 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301136 uint32_t pdev_param;
1137
1138 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1139 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1140 WMI_LOGW("%s: Unavailable param %d\n",
1141 __func__, param->param_id);
1142 return QDF_STATUS_E_INVAL;
1143 }
Govind Singh5eb51532016-03-09 11:34:12 +05301144
1145 buf = wmi_buf_alloc(wmi_handle, len);
1146 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301147 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301148 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301149 }
1150 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1151 WMITLV_SET_HDR(&cmd->tlv_header,
1152 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1153 WMITLV_GET_STRUCT_TLVLEN
1154 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301155 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301156 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301157 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301158 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301159 param->param_value);
1160 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1161 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301162 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301163 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301164 wmi_buf_free(buf);
1165 }
1166 return ret;
1167}
1168
1169/**
1170 * send_suspend_cmd_tlv() - WMI suspend function
1171 * @param wmi_handle : handle to WMI.
1172 * @param param : pointer to hold suspend parameter
1173 * @mac_id: radio context
1174 *
1175 * Return 0 on success and -ve on failure.
1176 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301177static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301178 struct suspend_params *param,
1179 uint8_t mac_id)
1180{
1181 wmi_pdev_suspend_cmd_fixed_param *cmd;
1182 wmi_buf_t wmibuf;
1183 uint32_t len = sizeof(*cmd);
1184 int32_t ret;
1185
1186 /*
1187 * send the comand to Target to ignore the
1188 * PCIE reset so as to ensure that Host and target
1189 * states are in sync
1190 */
1191 wmibuf = wmi_buf_alloc(wmi_handle, len);
1192 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301193 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301194
1195 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1196 WMITLV_SET_HDR(&cmd->tlv_header,
1197 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1198 WMITLV_GET_STRUCT_TLVLEN
1199 (wmi_pdev_suspend_cmd_fixed_param));
1200 if (param->disable_target_intr)
1201 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1202 else
1203 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301204
1205 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1206
Govind Singh5eb51532016-03-09 11:34:12 +05301207 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1208 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301209 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301210 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301211 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301212 }
1213
1214 return ret;
1215}
1216
1217/**
1218 * send_resume_cmd_tlv() - WMI resume function
1219 * @param wmi_handle : handle to WMI.
1220 * @mac_id: radio context
1221 *
1222 * Return: 0 on success and -ve on failure.
1223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301224static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301225 uint8_t mac_id)
1226{
1227 wmi_buf_t wmibuf;
1228 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301229 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301230
1231 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1232 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301233 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301234 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1235 WMITLV_SET_HDR(&cmd->tlv_header,
1236 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1237 WMITLV_GET_STRUCT_TLVLEN
1238 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301239 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301240 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1241 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301242 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301243 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301244 wmi_buf_free(wmibuf);
1245 }
1246
1247 return ret;
1248}
1249
Will Huang422ac9a2017-11-17 13:19:16 +08001250#ifdef FEATURE_WLAN_D0WOW
1251/**
1252 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1253 * @param wmi_handle: handle to WMI.
1254 * @mac_id: radio context
1255 *
1256 * Return: 0 on success and error code on failure.
1257 */
1258static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1259 uint8_t mac_id)
1260{
1261 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1262 wmi_buf_t buf;
1263 int32_t len;
1264 QDF_STATUS status;
1265
1266 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1267
1268 buf = wmi_buf_alloc(wmi_handle, len);
1269 if (!buf) {
1270 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1271 return QDF_STATUS_E_NOMEM;
1272 }
1273 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1274 WMITLV_SET_HDR(&cmd->tlv_header,
1275 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1276 WMITLV_GET_STRUCT_TLVLEN
1277 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1278
1279 cmd->enable = true;
1280
1281 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1282 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1283 if (QDF_IS_STATUS_ERROR(status))
1284 wmi_buf_free(buf);
1285
1286 return status;
1287}
1288
1289/**
1290 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1291 * @param wmi_handle: handle to WMI.
1292 * @mac_id: radio context
1293 *
1294 * Return: 0 on success and error code on failure.
1295 */
1296static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1297 uint8_t mac_id)
1298{
1299 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1300 wmi_buf_t buf;
1301 int32_t len;
1302 QDF_STATUS status;
1303
1304 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1305
1306 buf = wmi_buf_alloc(wmi_handle, len);
1307 if (!buf) {
1308 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1309 return QDF_STATUS_E_NOMEM;
1310 }
1311 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1312 WMITLV_SET_HDR(&cmd->tlv_header,
1313 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1314 WMITLV_GET_STRUCT_TLVLEN
1315 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1316
1317 cmd->enable = false;
1318
1319 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1320 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1321 if (QDF_IS_STATUS_ERROR(status))
1322 wmi_buf_free(buf);
1323
1324 return status;
1325}
1326#endif
1327
Govind Singh5eb51532016-03-09 11:34:12 +05301328/**
1329 * send_wow_enable_cmd_tlv() - WMI wow enable function
1330 * @param wmi_handle : handle to WMI.
1331 * @param param : pointer to hold wow enable parameter
1332 * @mac_id: radio context
1333 *
1334 * Return: 0 on success and -ve on failure.
1335 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301336static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301337 struct wow_cmd_params *param,
1338 uint8_t mac_id)
1339{
1340 wmi_wow_enable_cmd_fixed_param *cmd;
1341 wmi_buf_t buf;
1342 int32_t len;
1343 int32_t ret;
1344
1345 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1346
1347 buf = wmi_buf_alloc(wmi_handle, len);
1348 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301349 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1350 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301351 }
1352 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1353 WMITLV_SET_HDR(&cmd->tlv_header,
1354 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1355 WMITLV_GET_STRUCT_TLVLEN
1356 (wmi_wow_enable_cmd_fixed_param));
1357 cmd->enable = param->enable;
1358 if (param->can_suspend_link)
1359 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1360 else
1361 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001362 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301363
Govind Singhb53420c2016-03-09 14:32:57 +05301364 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301365 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1366 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1367
1368 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1369 WMI_WOW_ENABLE_CMDID);
1370 if (ret)
1371 wmi_buf_free(buf);
1372
1373 return ret;
1374}
1375
1376/**
1377 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301378 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301379 * @peer_addr: peer mac address
1380 * @param: pointer to ap_ps parameter structure
1381 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301382 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301383 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301384static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301385 uint8_t *peer_addr,
1386 struct ap_ps_params *param)
1387{
1388 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1389 wmi_buf_t buf;
1390 int32_t err;
1391
1392 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1393 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301394 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301395 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301396 }
1397 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1398 WMITLV_SET_HDR(&cmd->tlv_header,
1399 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1400 WMITLV_GET_STRUCT_TLVLEN
1401 (wmi_ap_ps_peer_cmd_fixed_param));
1402 cmd->vdev_id = param->vdev_id;
1403 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1404 cmd->param = param->param;
1405 cmd->value = param->value;
1406 err = wmi_unified_cmd_send(wmi_handle, buf,
1407 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1408 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301409 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301410 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301411 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301412 }
1413
1414 return 0;
1415}
1416
1417/**
1418 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301419 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301420 * @peer_addr: peer mac address
1421 * @param: pointer to sta_ps parameter structure
1422 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301423 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301424 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301425static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301426 struct sta_ps_params *param)
1427{
1428 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1429 wmi_buf_t buf;
1430 int32_t len = sizeof(*cmd);
1431
1432 buf = wmi_buf_alloc(wmi_handle, len);
1433 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301434 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301435 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301436 }
1437
1438 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1439 WMITLV_SET_HDR(&cmd->tlv_header,
1440 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1441 WMITLV_GET_STRUCT_TLVLEN
1442 (wmi_sta_powersave_param_cmd_fixed_param));
1443 cmd->vdev_id = param->vdev_id;
1444 cmd->param = param->param;
1445 cmd->value = param->value;
1446
1447 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1448 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301449 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301450 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301451 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301452 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301453 }
1454
1455 return 0;
1456}
1457
1458/**
1459 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301460 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301461 * @param: ponirt to crash inject paramter structure
1462 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301463 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301464 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301465static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301466 struct crash_inject *param)
1467{
1468 int32_t ret = 0;
1469 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1470 uint16_t len = sizeof(*cmd);
1471 wmi_buf_t buf;
1472
1473 buf = wmi_buf_alloc(wmi_handle, len);
1474 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301475 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301476 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301477 }
1478
1479 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1480 WMITLV_SET_HDR(&cmd->tlv_header,
1481 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1482 WMITLV_GET_STRUCT_TLVLEN
1483 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1484 cmd->type = param->type;
1485 cmd->delay_time_ms = param->delay_time_ms;
1486
1487 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1488 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301489 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301490 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301491 __func__, ret);
1492 wmi_buf_free(buf);
1493 }
1494
1495 return ret;
1496}
1497
1498/**
1499 * send_dbglog_cmd_tlv() - set debug log level
1500 * @param wmi_handle : handle to WMI.
1501 * @param param : pointer to hold dbglog level parameter
1502 *
1503 * Return: 0 on success and -ve on failure.
1504 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301505 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301506send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1507 struct dbglog_params *dbglog_param)
1508{
1509 wmi_buf_t buf;
1510 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001511 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301512 int32_t i;
1513 int32_t len;
1514 int8_t *buf_ptr;
1515 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1516
Alok Kumar240afea2017-08-30 14:45:34 +05301517 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301518
1519 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1520 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1521 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1522 buf = wmi_buf_alloc(wmi_handle, len);
1523 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001524 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301525
1526 configmsg =
1527 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1528 buf_ptr = (int8_t *) configmsg;
1529 WMITLV_SET_HDR(&configmsg->tlv_header,
1530 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1531 WMITLV_GET_STRUCT_TLVLEN
1532 (wmi_debug_log_config_cmd_fixed_param));
1533 configmsg->dbg_log_param = dbglog_param->param;
1534 configmsg->value = dbglog_param->val;
1535 /* Filling in the data part of second tlv -- should
1536 * follow first tlv _ WMI_TLV_HDR_SIZE */
1537 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1538 sizeof
1539 (wmi_debug_log_config_cmd_fixed_param)
1540 + WMI_TLV_HDR_SIZE);
1541 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1542 WMITLV_TAG_ARRAY_UINT32,
1543 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1544 if (dbglog_param->module_id_bitmap) {
1545 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1546 module_id_bitmap_array[i] =
1547 dbglog_param->module_id_bitmap[i];
1548 }
1549 }
1550
1551 status = wmi_unified_cmd_send(wmi_handle, buf,
1552 len, WMI_DBGLOG_CFG_CMDID);
1553
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001554 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301555 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301556
1557 return status;
1558}
1559
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301560#ifdef CONFIG_MCL
1561static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1562 uint32_t host_param)
1563{
1564 return host_param;
1565}
1566#else
1567static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1568 uint32_t host_param)
1569{
1570 if (host_param < wmi_vdev_param_max)
1571 return wmi_handle->vdev_param[host_param];
1572
1573 return WMI_UNAVAILABLE_PARAM;
1574}
1575#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301576/**
1577 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1578 * @param wmi_handle : handle to WMI.
1579 * @param macaddr : MAC address
1580 * @param param : pointer to hold vdev set parameter
1581 *
1582 * Return: 0 on success and -ve on failure.
1583 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301584static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301585 struct vdev_set_params *param)
1586{
Govind Singh67922e82016-04-01 16:48:57 +05301587 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301588 wmi_vdev_set_param_cmd_fixed_param *cmd;
1589 wmi_buf_t buf;
1590 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301591 uint32_t vdev_param;
1592
1593 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1594 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1595 WMI_LOGW("%s:Vdev param %d not available", __func__,
1596 param->param_id);
1597 return QDF_STATUS_E_INVAL;
1598
1599 }
Govind Singh5eb51532016-03-09 11:34:12 +05301600
1601 buf = wmi_buf_alloc(wmi_handle, len);
1602 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301603 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301604 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301605 }
1606 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1607 WMITLV_SET_HDR(&cmd->tlv_header,
1608 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1609 WMITLV_GET_STRUCT_TLVLEN
1610 (wmi_vdev_set_param_cmd_fixed_param));
1611 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301612 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301613 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301614 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301615 param->if_id, param->param_id, param->param_value);
1616 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1617 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301618 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301619 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301620 wmi_buf_free(buf);
1621 }
1622
1623 return ret;
1624}
1625
1626/**
1627 * send_stats_request_cmd_tlv() - WMI request stats function
1628 * @param wmi_handle : handle to WMI.
1629 * @param macaddr : MAC address
1630 * @param param : pointer to hold stats request parameter
1631 *
1632 * Return: 0 on success and -ve on failure.
1633 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301634static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301635 uint8_t macaddr[IEEE80211_ADDR_LEN],
1636 struct stats_request_params *param)
1637{
Govind Singhd3156eb2016-02-26 17:50:39 +05301638 int32_t ret;
1639 wmi_request_stats_cmd_fixed_param *cmd;
1640 wmi_buf_t buf;
1641 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1642
1643 buf = wmi_buf_alloc(wmi_handle, len);
1644 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301645 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1646 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301647 }
1648
1649 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1650 WMITLV_SET_HDR(&cmd->tlv_header,
1651 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1652 WMITLV_GET_STRUCT_TLVLEN
1653 (wmi_request_stats_cmd_fixed_param));
1654 cmd->stats_id = param->stats_id;
1655 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301656 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1657 param->pdev_id);
1658 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Govind Singhd3156eb2016-02-26 17:50:39 +05301659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1660 WMI_REQUEST_STATS_CMDID);
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301661 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1662 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05301663 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301664 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301665 wmi_buf_free(buf);
1666 }
1667
1668 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301669}
1670
Govind Singh87542482016-06-08 19:40:11 +05301671#ifdef CONFIG_WIN
1672/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001673 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301674 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001675 * @param PKTLOG_EVENT : packet log event
1676 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301677 *
1678 * Return: 0 on success and -ve on failure.
1679 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301680static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001681 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301682{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001683 int32_t ret;
1684 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1685 wmi_buf_t buf;
1686 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1687
1688 buf = wmi_buf_alloc(wmi_handle, len);
1689 if (!buf) {
1690 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1691 return -QDF_STATUS_E_NOMEM;
1692 }
1693
1694 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1695 WMITLV_SET_HDR(&cmd->tlv_header,
1696 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1697 WMITLV_GET_STRUCT_TLVLEN
1698 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1699 cmd->evlist = PKTLOG_EVENT;
1700 cmd->pdev_id = mac_id;
1701 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1702 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1703 if (ret) {
1704 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1705 wmi_buf_free(buf);
1706 }
1707
1708 return ret;
1709}
1710
1711/**
1712 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1713 * @param wmi_handle : handle to WMI.
1714 * @mac_id: mac id to have radio context
1715 *
1716 * Return: 0 on success and -ve on failure.
1717 */
1718static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001719 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001720{
1721 int32_t ret;
1722 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1723 wmi_buf_t buf;
1724 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1725
1726 buf = wmi_buf_alloc(wmi_handle, len);
1727 if (!buf) {
1728 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1729 return -QDF_STATUS_E_NOMEM;
1730 }
1731
1732 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1733 WMITLV_SET_HDR(&cmd->tlv_header,
1734 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1735 WMITLV_GET_STRUCT_TLVLEN
1736 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1737 cmd->pdev_id = mac_id;
1738 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1739 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1740 if (ret) {
1741 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1742 wmi_buf_free(buf);
1743 }
1744
1745 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301746}
1747#else
Govind Singh5eb51532016-03-09 11:34:12 +05301748/**
Keyur Parekhde522342017-08-18 14:01:05 -07001749 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1750 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301751 * @param wmi_handle : handle to WMI.
1752 * @param macaddr : MAC address
1753 * @param param : pointer to hold stats request parameter
1754 *
1755 * Return: 0 on success and -ve on failure.
1756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301757static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301758 uint8_t macaddr[IEEE80211_ADDR_LEN],
1759 struct packet_enable_params *param)
1760{
1761 return 0;
1762}
Keyur Parekhde522342017-08-18 14:01:05 -07001763/**
1764 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1765 * packet-log
1766 * @param wmi_handle : handle to WMI.
1767 * @mac_id: mac id to have radio context
1768 *
1769 * Return: 0 on success and -ve on failure.
1770 */
1771static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1772 uint8_t mac_id)
1773{
1774 return 0;
1775}
Govind Singh87542482016-06-08 19:40:11 +05301776#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301777
Sathish Kumarfd347372017-02-13 12:29:09 +05301778static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301779 struct beacon_params *param)
1780{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301781 QDF_STATUS ret;
1782 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1783 wmi_buf_t wmi_buf;
1784 qdf_dma_addr_t dma_addr;
1785 uint32_t dtim_flag = 0;
1786
1787 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1788 if (!wmi_buf) {
1789 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1790 return QDF_STATUS_E_NOMEM;
1791 }
1792 if (param->is_dtim_count_zero) {
1793 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1794 if (param->is_bitctl_reqd) {
1795 /* deliver CAB traffic in next DTIM beacon */
1796 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1797 }
1798 }
1799 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1800 WMITLV_SET_HDR(&cmd->tlv_header,
1801 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1802 WMITLV_GET_STRUCT_TLVLEN
1803 (wmi_bcn_send_from_host_cmd_fixed_param));
1804 cmd->vdev_id = param->vdev_id;
1805 cmd->data_len = qdf_nbuf_len(param->wbuf);
1806 cmd->frame_ctrl = param->frame_ctrl;
1807 cmd->dtim_flag = dtim_flag;
1808 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1809 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1810#if defined(HTT_PADDR64)
1811 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1812#endif
1813 cmd->bcn_antenna = param->bcn_txant;
1814
1815 ret = wmi_unified_cmd_send(wmi_handle,
1816 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1817 if (ret != QDF_STATUS_SUCCESS) {
1818 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1819 wmi_buf_free(wmi_buf);
1820 }
1821
1822 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301823}
1824
1825/**
1826 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1827 * @param wmi_handle : handle to WMI.
1828 * @param param : pointer to hold beacon send cmd parameter
1829 *
1830 * Return: 0 on success and -ve on failure.
1831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301832static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301833 struct beacon_tmpl_params *param)
1834{
1835 int32_t ret;
1836 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1837 wmi_bcn_prb_info *bcn_prb_info;
1838 wmi_buf_t wmi_buf;
1839 uint8_t *buf_ptr;
1840 uint32_t wmi_buf_len;
1841
Sathish Kumar45e991b2017-02-27 10:35:40 +05301842 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301843 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1844 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1845 param->tmpl_len_aligned;
1846 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1847 if (!wmi_buf) {
1848 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1849 return QDF_STATUS_E_NOMEM;
1850 }
1851 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1852 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1853 WMITLV_SET_HDR(&cmd->tlv_header,
1854 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1855 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1856 cmd->vdev_id = param->vdev_id;
1857 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301858 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1859 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301860 cmd->buf_len = param->tmpl_len;
1861 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1862
1863 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1864 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1865 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1866 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1867 bcn_prb_info->caps = 0;
1868 bcn_prb_info->erp = 0;
1869 buf_ptr += sizeof(wmi_bcn_prb_info);
1870
1871 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1872 buf_ptr += WMI_TLV_HDR_SIZE;
1873 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1874
1875 ret = wmi_unified_cmd_send(wmi_handle,
1876 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1877 if (ret) {
1878 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1879 wmi_buf_free(wmi_buf);
1880 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301881
Govind Singh87542482016-06-08 19:40:11 +05301882 return 0;
1883}
Govind Singh5eb51532016-03-09 11:34:12 +05301884
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301885#ifdef CONFIG_MCL
1886static inline void copy_peer_flags_tlv(
1887 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1888 struct peer_assoc_params *param)
1889{
1890 cmd->peer_flags = param->peer_flags;
1891}
1892#else
1893static inline void copy_peer_flags_tlv(
1894 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1895 struct peer_assoc_params *param)
1896{
1897 /*
1898 * The target only needs a subset of the flags maintained in the host.
1899 * Just populate those flags and send it down
1900 */
1901 cmd->peer_flags = 0;
1902
1903 /*
1904 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1905 */
1906 if (param->is_wme_set) {
1907
1908 if (param->qos_flag)
1909 cmd->peer_flags |= WMI_PEER_QOS;
1910 if (param->apsd_flag)
1911 cmd->peer_flags |= WMI_PEER_APSD;
1912 if (param->ht_flag)
1913 cmd->peer_flags |= WMI_PEER_HT;
1914 if (param->bw_40)
1915 cmd->peer_flags |= WMI_PEER_40MHZ;
1916 if (param->bw_80)
1917 cmd->peer_flags |= WMI_PEER_80MHZ;
1918 if (param->bw_160)
1919 cmd->peer_flags |= WMI_PEER_160MHZ;
1920
1921 /* Typically if STBC is enabled for VHT it should be enabled
1922 * for HT as well
1923 **/
1924 if (param->stbc_flag)
1925 cmd->peer_flags |= WMI_PEER_STBC;
1926
1927 /* Typically if LDPC is enabled for VHT it should be enabled
1928 * for HT as well
1929 **/
1930 if (param->ldpc_flag)
1931 cmd->peer_flags |= WMI_PEER_LDPC;
1932
1933 if (param->static_mimops_flag)
1934 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1935 if (param->dynamic_mimops_flag)
1936 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1937 if (param->spatial_mux_flag)
1938 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1939 if (param->vht_flag)
1940 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001941 if (param->he_flag)
1942 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301943 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001944
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301945 if (param->is_pmf_enabled)
1946 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301947 /*
1948 * Suppress authorization for all AUTH modes that need 4-way handshake
1949 * (during re-association).
1950 * Authorization will be done for these modes on key installation.
1951 */
1952 if (param->auth_flag)
1953 cmd->peer_flags |= WMI_PEER_AUTH;
1954 if (param->need_ptk_4_way)
1955 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1956 else
1957 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1958 if (param->need_gtk_2_way)
1959 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1960 /* safe mode bypass the 4-way handshake */
1961 if (param->safe_mode_enabled)
1962 cmd->peer_flags &=
1963 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1964 /* Disable AMSDU for station transmit, if user configures it */
1965 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1966 * it
1967 * if (param->amsdu_disable) Add after FW support
1968 **/
1969
1970 /* Target asserts if node is marked HT and all MCS is set to 0.
1971 * Mark the node as non-HT if all the mcs rates are disabled through
1972 * iwpriv
1973 **/
1974 if (param->peer_ht_rates.num_rates == 0)
1975 cmd->peer_flags &= ~WMI_PEER_HT;
1976}
1977#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301978
1979#ifdef CONFIG_MCL
1980static inline void copy_peer_mac_addr_tlv(
1981 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1982 struct peer_assoc_params *param)
1983{
1984 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1985 sizeof(param->peer_macaddr));
1986}
1987#else
1988static inline void copy_peer_mac_addr_tlv(
1989 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1990 struct peer_assoc_params *param)
1991{
1992 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1993}
1994#endif
1995
Govind Singh5eb51532016-03-09 11:34:12 +05301996/**
1997 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1998 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301999 * @param param : pointer to peer assoc parameter
2000 *
2001 * Return: 0 on success and -ve on failure.
2002 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302003static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302004 struct peer_assoc_params *param)
2005{
Govind Singhd3156eb2016-02-26 17:50:39 +05302006 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2007 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002008 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302009 wmi_buf_t buf;
2010 int32_t len;
2011 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302012 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302013 uint32_t peer_legacy_rates_align;
2014 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002015 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302016
2017
2018 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2019 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302020
2021 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002022 (peer_legacy_rates_align * sizeof(uint8_t)) +
2023 WMI_TLV_HDR_SIZE +
2024 (peer_ht_rates_align * sizeof(uint8_t)) +
2025 sizeof(wmi_vht_rate_set) +
2026 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2027 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302028
2029 buf = wmi_buf_alloc(wmi_handle, len);
2030 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302031 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302032 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302033 }
2034
2035 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2036 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2037 WMITLV_SET_HDR(&cmd->tlv_header,
2038 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2039 WMITLV_GET_STRUCT_TLVLEN
2040 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302041
Govind Singhd3156eb2016-02-26 17:50:39 +05302042 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302043
Govind Singhd3156eb2016-02-26 17:50:39 +05302044 cmd->peer_new_assoc = param->peer_new_assoc;
2045 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302046
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302047 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302048 copy_peer_mac_addr_tlv(cmd, param);
2049
Govind Singhd3156eb2016-02-26 17:50:39 +05302050 cmd->peer_rate_caps = param->peer_rate_caps;
2051 cmd->peer_caps = param->peer_caps;
2052 cmd->peer_listen_intval = param->peer_listen_intval;
2053 cmd->peer_ht_caps = param->peer_ht_caps;
2054 cmd->peer_max_mpdu = param->peer_max_mpdu;
2055 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302056 cmd->peer_vht_caps = param->peer_vht_caps;
2057 cmd->peer_phymode = param->peer_phymode;
2058
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002059 /* Update 11ax capabilities */
2060 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2061 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002062 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2063 sizeof(param->peer_he_cap_phyinfo));
2064 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2065 sizeof(param->peer_ppet));
2066
Govind Singhd3156eb2016-02-26 17:50:39 +05302067 /* Update peer legacy rate information */
2068 buf_ptr += sizeof(*cmd);
2069 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302070 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302071 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302072 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302073 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302074 param->peer_legacy_rates.num_rates);
2075
2076 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002077 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302078 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302079 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302080 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302081 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302082 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302083 param->peer_ht_rates.num_rates);
2084
2085 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002086 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2088 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2089
2090 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302091
2092 /* Update bandwidth-NSS mapping */
2093 cmd->peer_bw_rxnss_override = 0;
2094 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2095
Govind Singhd3156eb2016-02-26 17:50:39 +05302096 mcs = (wmi_vht_rate_set *) buf_ptr;
2097 if (param->vht_capable) {
2098 mcs->rx_max_rate = param->rx_max_rate;
2099 mcs->rx_mcs_set = param->rx_mcs_set;
2100 mcs->tx_max_rate = param->tx_max_rate;
2101 mcs->tx_mcs_set = param->tx_mcs_set;
2102 }
2103
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002104 /* HE Rates */
2105 cmd->peer_he_mcs = param->peer_he_mcs_count;
2106 buf_ptr += sizeof(wmi_vht_rate_set);
2107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2108 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2109 buf_ptr += WMI_TLV_HDR_SIZE;
2110
2111 /* Loop through the HE rate set */
2112 for (i = 0; i < param->peer_he_mcs_count; i++) {
2113 he_mcs = (wmi_he_rate_set *) buf_ptr;
2114 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2115 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2116
2117 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2118 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2119 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2120 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2121 buf_ptr += sizeof(wmi_he_rate_set);
2122 }
2123
2124
Govind Singhb53420c2016-03-09 14:32:57 +05302125 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302126 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2127 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002128 "cmd->peer_vht_caps %x "
2129 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302130 "HE phy %x %x %x "
2131 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302132 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2133 cmd->peer_rate_caps, cmd->peer_caps,
2134 cmd->peer_listen_intval, cmd->peer_ht_caps,
2135 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2136 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002137 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2138 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302139 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2140 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302141
2142 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2143 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302144 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302145 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302146 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302147 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302148 }
2149
2150 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302151}
2152
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302153/* copy_scan_notify_events() - Helper routine to copy scan notify events
2154 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302155static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302156 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302157 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302158{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302159
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302160 /* Scan events subscription */
2161 if (param->scan_ev_started)
2162 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2163 if (param->scan_ev_completed)
2164 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2165 if (param->scan_ev_bss_chan)
2166 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2167 if (param->scan_ev_foreign_chan)
2168 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2169 if (param->scan_ev_dequeued)
2170 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2171 if (param->scan_ev_preempted)
2172 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2173 if (param->scan_ev_start_failed)
2174 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2175 if (param->scan_ev_restarted)
2176 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2177 if (param->scan_ev_foreign_chn_exit)
2178 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2179 if (param->scan_ev_suspended)
2180 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2181 if (param->scan_ev_resumed)
2182 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302183
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302184 /** Set scan control flags */
2185 cmd->scan_ctrl_flags = 0;
2186 if (param->scan_f_passive)
2187 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2188 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302189 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302190 if (param->scan_f_promisc_mode)
2191 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2192 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302193 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302194 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302195 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302196 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302197 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302198 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302199 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302200 if (param->scan_f_ofdm_rates)
2201 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2202 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302203 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302204 if (param->scan_f_filter_prb_req)
2205 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2206 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302207 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302208 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302209 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302210 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302211 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302212 if (param->scan_f_force_active_dfs_chn)
2213 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2214 if (param->scan_f_add_tpc_ie_in_probe)
2215 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2216 if (param->scan_f_add_ds_ie_in_probe)
2217 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2218 if (param->scan_f_add_spoofed_mac_in_probe)
2219 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2220 if (param->scan_f_add_rand_seq_in_probe)
2221 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2222 if (param->scan_f_en_ie_whitelist_in_probe)
2223 cmd->scan_ctrl_flags |=
2224 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302225
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302226 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2227 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2228 param->adaptive_dwell_time_mode);
2229}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302230
2231/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302232static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302233 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302234{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302235 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302236}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302237
Anish Natarajdd855152017-03-20 12:49:08 +05302238/*
2239 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2240 * @param wmi_handle : Handle to WMI
2241 * @param vdev_id : vdev identifier
2242 *
2243 * Return : void *
2244 */
2245static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2246{
2247 struct wlan_objmgr_vdev *vdev = NULL;
2248 struct wlan_objmgr_pdev *pdev = NULL;
2249 uint8_t pdev_id = 0;
2250
2251 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2252 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2253 vdev_id, WLAN_SCAN_ID);
2254 if (vdev) {
2255 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2256 pdev = wlan_vdev_get_pdev(vdev);
2257 if (pdev)
2258 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2259 else {
2260 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2261 }
2262 } else {
2263 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2264 }
2265
2266 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2267}
2268
Govind Singh5eb51532016-03-09 11:34:12 +05302269/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302270 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2271 * @mac: random mac addr
2272 * @mask: random mac mask
2273 * @mac_addr: wmi random mac
2274 * @mac_mask: wmi random mac mask
2275 *
2276 * Return None.
2277 */
2278static inline
2279void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2280 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2281{
2282 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2283 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2284}
2285
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302286/*
2287 * wmi_fill_vendor_oui() - fill vendor OUIs
2288 * @buf_ptr: pointer to wmi tlv buffer
2289 * @num_vendor_oui: number of vendor OUIs to be filled
2290 * @param_voui: pointer to OUI buffer
2291 *
2292 * This function populates the wmi tlv buffer when vendor specific OUIs are
2293 * present.
2294 *
2295 * Return: None
2296 */
2297static inline
2298void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2299 uint32_t *pvoui)
2300{
2301 wmi_vendor_oui *voui = NULL;
2302 uint32_t i;
2303
2304 voui = (wmi_vendor_oui *)buf_ptr;
2305
2306 for (i = 0; i < num_vendor_oui; i++) {
2307 WMITLV_SET_HDR(&voui[i].tlv_header,
2308 WMITLV_TAG_STRUC_wmi_vendor_oui,
2309 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2310 voui[i].oui_type_subtype = pvoui[i];
2311 }
2312}
2313
2314/*
2315 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2316 * @ie_bitmap: output pointer to ie bit map in cmd
2317 * @num_vendor_oui: output pointer to num vendor OUIs
2318 * @ie_whitelist: input parameter
2319 *
2320 * This function populates the IE whitelist attrs of scan, pno and
2321 * scan oui commands for ie_whitelist parameter.
2322 *
2323 * Return: None
2324 */
2325static inline
2326void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2327 uint32_t *num_vendor_oui,
2328 struct probe_req_whitelist_attr *ie_whitelist)
2329{
2330 uint32_t i = 0;
2331
2332 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2333 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2334
2335 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2336}
2337
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302338/**
Govind Singh5eb51532016-03-09 11:34:12 +05302339 * send_scan_start_cmd_tlv() - WMI scan start function
2340 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302341 * @param param : pointer to hold scan start cmd parameter
2342 *
2343 * Return: 0 on success and -ve on failure.
2344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302345static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302346 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302347{
Govind Singhd3156eb2016-02-26 17:50:39 +05302348 int32_t ret = 0;
2349 int32_t i;
2350 wmi_buf_t wmi_buf;
2351 wmi_start_scan_cmd_fixed_param *cmd;
2352 uint8_t *buf_ptr;
2353 uint32_t *tmp_ptr;
2354 wmi_ssid *ssid = NULL;
2355 wmi_mac_addr *bssid;
2356 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302357 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302358 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302359 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302360
2361 /* Length TLV placeholder for array of uint32_t */
2362 len += WMI_TLV_HDR_SIZE;
2363 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302364 if (params->chan_list.num_chan)
2365 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302366
2367 /* Length TLV placeholder for array of wmi_ssid structures */
2368 len += WMI_TLV_HDR_SIZE;
2369 if (params->num_ssids)
2370 len += params->num_ssids * sizeof(wmi_ssid);
2371
2372 /* Length TLV placeholder for array of wmi_mac_addr structures */
2373 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302374 if (params->num_bssid)
2375 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302376
2377 /* Length TLV placeholder for array of bytes */
2378 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302379 if (params->extraie.len)
2380 extraie_len_with_pad =
2381 roundup(params->extraie.len, sizeof(uint32_t));
2382 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302383
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302384 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2385 if (ie_whitelist->num_vendor_oui)
2386 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2387
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302388 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2389 if (params->scan_f_wide_band)
2390 phymode_roundup =
2391 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2392 sizeof(uint32_t));
2393 len += phymode_roundup;
2394
Govind Singhd3156eb2016-02-26 17:50:39 +05302395 /* Allocate the memory */
2396 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2397 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302398 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302399 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302400 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302401 }
2402 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2403 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2404 WMITLV_SET_HDR(&cmd->tlv_header,
2405 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2406 WMITLV_GET_STRUCT_TLVLEN
2407 (wmi_start_scan_cmd_fixed_param));
2408
2409 cmd->scan_id = params->scan_id;
2410 cmd->scan_req_id = params->scan_req_id;
2411 cmd->vdev_id = params->vdev_id;
2412 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302413
2414 copy_scan_event_cntrl_flags(cmd, params);
2415
Govind Singhd3156eb2016-02-26 17:50:39 +05302416 cmd->dwell_time_active = params->dwell_time_active;
2417 cmd->dwell_time_passive = params->dwell_time_passive;
2418 cmd->min_rest_time = params->min_rest_time;
2419 cmd->max_rest_time = params->max_rest_time;
2420 cmd->repeat_probe_time = params->repeat_probe_time;
2421 cmd->probe_spacing_time = params->probe_spacing_time;
2422 cmd->idle_time = params->idle_time;
2423 cmd->max_scan_time = params->max_scan_time;
2424 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302425 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302426 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302427 cmd->num_bssid = params->num_bssid;
2428 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302429 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302430 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302431 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2432
2433 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2434
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302435 if (params->scan_random.randomize)
2436 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2437 params->scan_random.mac_mask,
2438 &cmd->mac_addr,
2439 &cmd->mac_mask);
2440
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302441 if (ie_whitelist->white_list)
2442 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2443 &cmd->num_vendor_oui,
2444 ie_whitelist);
2445
Govind Singhd3156eb2016-02-26 17:50:39 +05302446 buf_ptr += sizeof(*cmd);
2447 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302448 for (i = 0; i < params->chan_list.num_chan; ++i)
2449 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302450
2451 WMITLV_SET_HDR(buf_ptr,
2452 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302453 (params->chan_list.num_chan * sizeof(uint32_t)));
2454 buf_ptr += WMI_TLV_HDR_SIZE +
2455 (params->chan_list.num_chan * sizeof(uint32_t));
2456
Govind Singh4eacd2b2016-03-07 14:24:22 +05302457 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302458 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302459 goto error;
2460 }
2461
2462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2463 (params->num_ssids * sizeof(wmi_ssid)));
2464
2465 if (params->num_ssids) {
2466 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2467 for (i = 0; i < params->num_ssids; ++i) {
2468 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302469 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302470 params->ssid[i].length);
2471 ssid++;
2472 }
2473 }
2474 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2475
2476 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2477 (params->num_bssid * sizeof(wmi_mac_addr)));
2478 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302479
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302480 if (params->num_bssid) {
2481 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302482 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2483 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302484 bssid++;
2485 }
2486 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302487
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302488 buf_ptr += WMI_TLV_HDR_SIZE +
2489 (params->num_bssid * sizeof(wmi_mac_addr));
2490
2491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2492 if (params->extraie.len)
2493 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2494 params);
2495
2496 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302497
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302498 /* probe req ie whitelisting */
2499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2500 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2501
2502 buf_ptr += WMI_TLV_HDR_SIZE;
2503
2504 if (cmd->num_vendor_oui) {
2505 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2506 ie_whitelist->voui);
2507 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2508 }
2509
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302510 /* Add phy mode TLV if it's a wide band scan */
2511 if (params->scan_f_wide_band) {
2512 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2513 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2514 for (i = 0; i < params->chan_list.num_chan; ++i)
2515 buf_ptr[i] =
2516 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2517 buf_ptr += phymode_roundup;
2518 } else {
2519 /* Add ZERO legth phy mode TLV */
2520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2521 }
2522
Anish Natarajdd855152017-03-20 12:49:08 +05302523 ret = wmi_unified_cmd_send(
2524 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302525 len, WMI_START_SCAN_CMDID);
2526 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302527 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302528 wmi_buf_free(wmi_buf);
2529 }
2530 return ret;
2531error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302532 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302533 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302534}
2535
2536/**
2537 * send_scan_stop_cmd_tlv() - WMI scan start function
2538 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302539 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302540 *
2541 * Return: 0 on success and -ve on failure.
2542 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302543static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302544 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302545{
Govind Singhd3156eb2016-02-26 17:50:39 +05302546 wmi_stop_scan_cmd_fixed_param *cmd;
2547 int ret;
2548 int len = sizeof(*cmd);
2549 wmi_buf_t wmi_buf;
2550
2551 /* Allocate the memory */
2552 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2553 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302554 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302555 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302556 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302557 goto error;
2558 }
2559
2560 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2561 WMITLV_SET_HDR(&cmd->tlv_header,
2562 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2563 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2564 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302565 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302566 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302567 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2568 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302569 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302570 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2571 /* Cancelling all scans */
2572 cmd->req_type = WMI_SCAN_STOP_ALL;
2573 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2574 /* Cancelling VAP scans */
2575 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2576 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2577 /* Cancelling specific scan */
2578 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302579 } else {
2580 WMI_LOGE("%s: Invalid Command : ", __func__);
2581 wmi_buf_free(wmi_buf);
2582 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302583 }
2584
Anish Natarajdd855152017-03-20 12:49:08 +05302585 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302586 len, WMI_STOP_SCAN_CMDID);
2587 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302588 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302589 wmi_buf_free(wmi_buf);
2590 }
2591
2592error:
2593 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302594}
2595
Govind Singh87542482016-06-08 19:40:11 +05302596#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302597/**
2598 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2599 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302600 * @param param : pointer to hold scan channel list parameter
2601 *
2602 * Return: 0 on success and -ve on failure.
2603 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302604static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302605 struct scan_chan_list_params *chan_list)
2606{
2607 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302608 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302609 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302610 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302611 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302612 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302613 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2614
2615 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2616 buf = wmi_buf_alloc(wmi_handle, len);
2617 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302618 WMI_LOGE("Failed to allocate memory");
2619 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302620 goto end;
2621 }
2622
2623 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2624 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2625 WMITLV_SET_HDR(&cmd->tlv_header,
2626 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2627 WMITLV_GET_STRUCT_TLVLEN
2628 (wmi_scan_chan_list_cmd_fixed_param));
2629
Govind Singhb53420c2016-03-09 14:32:57 +05302630 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302631
2632 cmd->num_scan_chans = chan_list->num_scan_chans;
2633 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2634 WMITLV_TAG_ARRAY_STRUC,
2635 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302636 chan_info = (wmi_channel_param *)
2637 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302638 tchan_info = chan_list->chan_info;
2639
2640 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2641 WMITLV_SET_HDR(&chan_info->tlv_header,
2642 WMITLV_TAG_STRUC_wmi_channel,
2643 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2644 chan_info->mhz = tchan_info->mhz;
2645 chan_info->band_center_freq1 =
2646 tchan_info->band_center_freq1;
2647 chan_info->band_center_freq2 =
2648 tchan_info->band_center_freq2;
2649 chan_info->info = tchan_info->info;
2650 chan_info->reg_info_1 = tchan_info->reg_info_1;
2651 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302652 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302653
2654 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2655 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2656 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2657 tchan_info++;
2658 chan_info++;
2659 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302660 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2661 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302662
Anish Natarajdd855152017-03-20 12:49:08 +05302663 qdf_status = wmi_unified_cmd_send(wmi_handle,
2664 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302665
Govind Singh67922e82016-04-01 16:48:57 +05302666 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302667 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302668 wmi_buf_free(buf);
2669 }
Govind Singh67922e82016-04-01 16:48:57 +05302670
Govind Singhd3156eb2016-02-26 17:50:39 +05302671end:
Govind Singhb53420c2016-03-09 14:32:57 +05302672 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302673}
Govind Singh87542482016-06-08 19:40:11 +05302674#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302675static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302676 struct scan_chan_list_params *chan_list)
2677{
2678 wmi_buf_t buf;
2679 QDF_STATUS qdf_status;
2680 wmi_scan_chan_list_cmd_fixed_param *cmd;
2681 int i;
2682 uint8_t *buf_ptr;
2683 wmi_channel *chan_info;
2684 struct channel_param *tchan_info;
2685 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302686
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302687 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302688 buf = wmi_buf_alloc(wmi_handle, len);
2689 if (!buf) {
2690 WMI_LOGE("Failed to allocate memory");
2691 qdf_status = QDF_STATUS_E_NOMEM;
2692 goto end;
2693 }
2694
2695 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2696 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2697 WMITLV_SET_HDR(&cmd->tlv_header,
2698 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2699 WMITLV_GET_STRUCT_TLVLEN
2700 (wmi_scan_chan_list_cmd_fixed_param));
2701
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302702 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302703
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302704 if (chan_list->append)
2705 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2706
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302707 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2708 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302709 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302710 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2711 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302712 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302713 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2714 tchan_info = &(chan_list->ch_param[0]);
2715
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302716 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302717 WMITLV_SET_HDR(&chan_info->tlv_header,
2718 WMITLV_TAG_STRUC_wmi_channel,
2719 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2720 chan_info->mhz = tchan_info->mhz;
2721 chan_info->band_center_freq1 =
2722 tchan_info->cfreq1;
2723 chan_info->band_center_freq2 =
2724 tchan_info->cfreq2;
2725
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302726 if (tchan_info->is_chan_passive)
2727 WMI_SET_CHANNEL_FLAG(chan_info,
2728 WMI_CHAN_FLAG_PASSIVE);
2729
2730 if (tchan_info->allow_vht)
2731 WMI_SET_CHANNEL_FLAG(chan_info,
2732 WMI_CHAN_FLAG_ALLOW_VHT);
2733 else if (tchan_info->allow_ht)
2734 WMI_SET_CHANNEL_FLAG(chan_info,
2735 WMI_CHAN_FLAG_ALLOW_HT);
2736 WMI_SET_CHANNEL_MODE(chan_info,
2737 tchan_info->phy_mode);
2738
2739 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2740 * after FW support
2741 */
2742
2743 /* also fill in power information */
2744 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2745 tchan_info->minpower);
2746 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2747 tchan_info->maxpower);
2748 WMI_SET_CHANNEL_REG_POWER(chan_info,
2749 tchan_info->maxregpower);
2750 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2751 tchan_info->antennamax);
2752 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2753 tchan_info->reg_class_id);
2754
Govind Singh87542482016-06-08 19:40:11 +05302755 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2756
Govind Singh87542482016-06-08 19:40:11 +05302757 tchan_info++;
2758 chan_info++;
2759 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302760 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2761 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302762
Anish Natarajdd855152017-03-20 12:49:08 +05302763 qdf_status = wmi_unified_cmd_send(
2764 wmi_handle,
2765 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302766
2767 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2768 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2769 wmi_buf_free(buf);
2770 }
2771
2772end:
2773 return qdf_status;
2774}
2775#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302776
2777/**
2778 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2779 *
2780 * @bufp: Pointer to buffer
2781 * @param: Pointer to tx param
2782 *
2783 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2784 */
2785static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2786 struct tx_send_params param)
2787{
2788 wmi_tx_send_params *tx_param;
2789 QDF_STATUS status = QDF_STATUS_SUCCESS;
2790
2791 if (!bufp) {
2792 status = QDF_STATUS_E_FAILURE;
2793 return status;
2794 }
2795 tx_param = (wmi_tx_send_params *)bufp;
2796 WMITLV_SET_HDR(&tx_param->tlv_header,
2797 WMITLV_TAG_STRUC_wmi_tx_send_params,
2798 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2799 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2800 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2801 param.mcs_mask);
2802 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2803 param.nss_mask);
2804 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2805 param.retry_limit);
2806 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2807 param.chain_mask);
2808 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2809 param.bw_mask);
2810 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2811 param.preamble_type);
2812 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2813 param.frame_type);
2814
2815 return status;
2816}
2817
Govind Singhd3156eb2016-02-26 17:50:39 +05302818/**
2819 * send_mgmt_cmd_tlv() - WMI scan start function
2820 * @wmi_handle : handle to WMI.
2821 * @param : pointer to hold mgmt cmd parameter
2822 *
2823 * Return: 0 on success and -ve on failure.
2824 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302825static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302826 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302827{
Govind Singh427ee5a2016-02-26 18:09:36 +05302828 wmi_buf_t buf;
2829 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2830 int32_t cmd_len;
2831 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302832 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302833 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302834 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302835 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2836 mgmt_tx_dl_frm_len;
2837
2838 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302839 WMI_TLV_HDR_SIZE +
2840 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302841
Sathish Kumar5b636932017-06-28 14:40:32 +05302842 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302843 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302844 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2845 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302846 }
2847
2848 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2849 bufp = (uint8_t *) cmd;
2850 WMITLV_SET_HDR(&cmd->tlv_header,
2851 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2852 WMITLV_GET_STRUCT_TLVLEN
2853 (wmi_mgmt_tx_send_cmd_fixed_param));
2854
2855 cmd->vdev_id = param->vdev_id;
2856
Govind Singh224a7312016-06-21 14:33:26 +05302857 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302858 cmd->chanfreq = param->chanfreq;
2859 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2860 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2861 sizeof(uint32_t)));
2862 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302863 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302864
2865 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2866 QDF_DMA_TO_DEVICE);
2867 if (status != QDF_STATUS_SUCCESS) {
2868 WMI_LOGE("%s: wmi buf map failed", __func__);
2869 goto err1;
2870 }
2871
Govind Singhb53420c2016-03-09 14:32:57 +05302872 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302873 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002874#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302875 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2876#endif
2877 cmd->frame_len = param->frm_len;
2878 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302879 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302880
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002881 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002882 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002883
Sathish Kumar5b636932017-06-28 14:40:32 +05302884 bufp += roundup(bufp_len, sizeof(uint32_t));
2885 if (param->tx_params_valid) {
2886 status = populate_tx_send_params(bufp, param->tx_param);
2887 if (status != QDF_STATUS_SUCCESS) {
2888 WMI_LOGE("%s: Populate TX send params failed",
2889 __func__);
2890 goto err1;
2891 }
2892 cmd_len += sizeof(wmi_tx_send_params);
2893 }
2894
Govind Singh427ee5a2016-02-26 18:09:36 +05302895 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2896 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302897 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302898 goto err1;
2899 }
Govind Singhb53420c2016-03-09 14:32:57 +05302900 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302901
2902err1:
2903 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302904 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302905}
2906
2907/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302908 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2909 * @wmi_handle : handle to WMI.
2910 * @param : pointer to offchan data tx cmd parameter
2911 *
2912 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2913 */
2914static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2915 struct wmi_offchan_data_tx_params *param)
2916{
2917 wmi_buf_t buf;
2918 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2919 int32_t cmd_len;
2920 uint64_t dma_addr;
2921 void *qdf_ctx = param->qdf_ctx;
2922 uint8_t *bufp;
2923 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2924 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302925 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302926
2927 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302928 WMI_TLV_HDR_SIZE +
2929 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302930
Sathish Kumar5b636932017-06-28 14:40:32 +05302931 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302932 if (!buf) {
2933 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2934 return QDF_STATUS_E_NOMEM;
2935 }
2936
2937 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2938 bufp = (uint8_t *) cmd;
2939 WMITLV_SET_HDR(&cmd->tlv_header,
2940 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2941 WMITLV_GET_STRUCT_TLVLEN
2942 (wmi_offchan_data_tx_send_cmd_fixed_param));
2943
2944 cmd->vdev_id = param->vdev_id;
2945
2946 cmd->desc_id = param->desc_id;
2947 cmd->chanfreq = param->chanfreq;
2948 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2949 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2950 sizeof(uint32_t)));
2951 bufp += WMI_TLV_HDR_SIZE;
2952 qdf_mem_copy(bufp, param->pdata, bufp_len);
2953 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2954 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2955 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2956#if defined(HTT_PADDR64)
2957 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2958#endif
2959 cmd->frame_len = param->frm_len;
2960 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302961 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302962
2963 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2964 bufp, cmd->vdev_id, cmd->chanfreq);
2965
Sathish Kumar5b636932017-06-28 14:40:32 +05302966 bufp += roundup(bufp_len, sizeof(uint32_t));
2967 if (param->tx_params_valid) {
2968 status = populate_tx_send_params(bufp, param->tx_param);
2969 if (status != QDF_STATUS_SUCCESS) {
2970 WMI_LOGE("%s: Populate TX send params failed",
2971 __func__);
2972 goto err1;
2973 }
2974 cmd_len += sizeof(wmi_tx_send_params);
2975 }
2976
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302977 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2978 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2979 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05302980 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302981 }
2982
2983 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05302984
2985err1:
2986 wmi_buf_free(buf);
2987 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302988}
2989
2990/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302991 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2992 * @wmi_handle: wmi handle
2993 * @param_value: parameter value
2994 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302995 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302996 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302997static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302998 uint32_t param_value)
2999{
Govind Singh67922e82016-04-01 16:48:57 +05303000 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303001 wmi_modem_power_state_cmd_param *cmd;
3002 wmi_buf_t buf;
3003 uint16_t len = sizeof(*cmd);
3004
3005 buf = wmi_buf_alloc(wmi_handle, len);
3006 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303007 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303008 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303009 }
3010 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3011 WMITLV_SET_HDR(&cmd->tlv_header,
3012 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3013 WMITLV_GET_STRUCT_TLVLEN
3014 (wmi_modem_power_state_cmd_param));
3015 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303016 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303017 param_value);
3018 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3019 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303020 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303021 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303022 wmi_buf_free(buf);
3023 }
Govind Singh67922e82016-04-01 16:48:57 +05303024
Govind Singh427ee5a2016-02-26 18:09:36 +05303025 return ret;
3026}
3027
3028/**
3029 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3030 * @wmi_handle: wmi handle
3031 * @vdev_id: vdev id
3032 * @val: value
3033 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303034 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303035 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303036static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303037 uint32_t vdev_id, uint8_t val)
3038{
3039 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3040 wmi_buf_t buf;
3041 int32_t len = sizeof(*cmd);
3042
Govind Singhb53420c2016-03-09 14:32:57 +05303043 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303044
3045 buf = wmi_buf_alloc(wmi_handle, len);
3046 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303048 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303049 }
3050 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3051 WMITLV_SET_HDR(&cmd->tlv_header,
3052 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3053 WMITLV_GET_STRUCT_TLVLEN
3054 (wmi_sta_powersave_mode_cmd_fixed_param));
3055 cmd->vdev_id = vdev_id;
3056 if (val)
3057 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3058 else
3059 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3060
3061 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3062 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303063 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303064 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303065 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303066 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303067 }
Govind Singh5eb51532016-03-09 11:34:12 +05303068 return 0;
3069}
3070
Govind Singh427ee5a2016-02-26 18:09:36 +05303071/**
3072 * send_set_mimops_cmd_tlv() - set MIMO powersave
3073 * @wmi_handle: wmi handle
3074 * @vdev_id: vdev id
3075 * @value: value
3076 *
Govind Singhb53420c2016-03-09 14:32:57 +05303077 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303078 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303079static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303080 uint8_t vdev_id, int value)
3081{
Govind Singh67922e82016-04-01 16:48:57 +05303082 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303083 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3084 wmi_buf_t buf;
3085 uint16_t len = sizeof(*cmd);
3086
3087 buf = wmi_buf_alloc(wmi_handle, len);
3088 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303089 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303090 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303091 }
3092 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3093 WMITLV_SET_HDR(&cmd->tlv_header,
3094 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3095 WMITLV_GET_STRUCT_TLVLEN
3096 (wmi_sta_smps_force_mode_cmd_fixed_param));
3097
3098 cmd->vdev_id = vdev_id;
3099
Houston Hoffmanb5168052016-04-14 02:18:01 -07003100 /* WMI_SMPS_FORCED_MODE values do not directly map
3101 * to SM power save values defined in the specification.
3102 * Make sure to send the right mapping.
3103 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303104 switch (value) {
3105 case 0:
3106 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3107 break;
3108 case 1:
3109 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3110 break;
3111 case 2:
3112 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3113 break;
3114 case 3:
3115 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3116 break;
3117 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303118 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3119 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303120 }
3121
Govind Singhb53420c2016-03-09 14:32:57 +05303122 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303123
3124 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3125 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303126 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303127 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303128 wmi_buf_free(buf);
3129 }
3130
3131 return ret;
3132}
3133
3134/**
3135 * send_set_smps_params_cmd_tlv() - set smps params
3136 * @wmi_handle: wmi handle
3137 * @vdev_id: vdev id
3138 * @value: value
3139 *
Govind Singhb53420c2016-03-09 14:32:57 +05303140 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303142static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303143 int value)
3144{
Govind Singh67922e82016-04-01 16:48:57 +05303145 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303146 wmi_sta_smps_param_cmd_fixed_param *cmd;
3147 wmi_buf_t buf;
3148 uint16_t len = sizeof(*cmd);
3149
3150 buf = wmi_buf_alloc(wmi_handle, len);
3151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303152 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303153 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303154 }
3155 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3156 WMITLV_SET_HDR(&cmd->tlv_header,
3157 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3158 WMITLV_GET_STRUCT_TLVLEN
3159 (wmi_sta_smps_param_cmd_fixed_param));
3160
3161 cmd->vdev_id = vdev_id;
3162 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3163 cmd->param =
3164 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3165
Govind Singhb53420c2016-03-09 14:32:57 +05303166 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 cmd->param);
3168
3169 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3170 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303171 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303172 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303173 wmi_buf_free(buf);
3174 }
3175
3176 return ret;
3177}
3178
3179/**
3180 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3181 * @wmi_handle: wmi handle
3182 * @noa: p2p power save parameters
3183 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303184 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303186static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303187 struct p2p_ps_params *noa)
3188{
3189 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3190 wmi_p2p_noa_descriptor *noa_discriptor;
3191 wmi_buf_t buf;
3192 uint8_t *buf_ptr;
3193 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303194 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303195 uint32_t duration;
3196
Govind Singhb53420c2016-03-09 14:32:57 +05303197 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303198 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3199 buf = wmi_buf_alloc(wmi_handle, len);
3200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303201 WMI_LOGE("Failed to allocate memory");
3202 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303203 goto end;
3204 }
3205
3206 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3207 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3208 WMITLV_SET_HDR(&cmd->tlv_header,
3209 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3210 WMITLV_GET_STRUCT_TLVLEN
3211 (wmi_p2p_set_noa_cmd_fixed_param));
3212 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3213 cmd->vdev_id = noa->session_id;
3214 cmd->enable = (duration) ? true : false;
3215 cmd->num_noa = 1;
3216
3217 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3218 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3219 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3220 sizeof
3221 (wmi_p2p_set_noa_cmd_fixed_param)
3222 + WMI_TLV_HDR_SIZE);
3223 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3224 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3225 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3226 noa_discriptor->type_count = noa->count;
3227 noa_discriptor->duration = duration;
3228 noa_discriptor->interval = noa->interval;
3229 noa_discriptor->start_time = 0;
3230
Govind Singhb53420c2016-03-09 14:32:57 +05303231 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 cmd->vdev_id, noa->count, noa_discriptor->duration,
3233 noa->interval);
3234 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3235 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303236 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303237 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303238 wmi_buf_free(buf);
3239 }
3240
3241end:
Govind Singhb53420c2016-03-09 14:32:57 +05303242 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303243 return status;
3244}
3245
3246
3247/**
3248 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3249 * @wmi_handle: wmi handle
3250 * @noa: p2p opp power save parameters
3251 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303252 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303253 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303254static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303255 struct p2p_ps_params *oppps)
3256{
3257 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3258 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303259 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303260
Govind Singhb53420c2016-03-09 14:32:57 +05303261 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3263 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303264 WMI_LOGE("Failed to allocate memory");
3265 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303266 goto end;
3267 }
3268
3269 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3270 WMITLV_SET_HDR(&cmd->tlv_header,
3271 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3272 WMITLV_GET_STRUCT_TLVLEN
3273 (wmi_p2p_set_oppps_cmd_fixed_param));
3274 cmd->vdev_id = oppps->session_id;
3275 if (oppps->ctwindow)
3276 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3277
3278 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303279 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303280 cmd->vdev_id, oppps->ctwindow);
3281 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3282 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303283 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303284 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303285 wmi_buf_free(buf);
3286 }
3287
3288end:
Govind Singhb53420c2016-03-09 14:32:57 +05303289 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303290 return status;
3291}
3292
Wu Gaocd3a8512017-03-13 20:17:34 +08003293#ifdef CONVERGED_P2P_ENABLE
3294/**
3295 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3296 * @wmi_handle: wmi handle
3297 * @param: p2p listen offload start parameters
3298 *
3299 * Return: QDF status
3300 */
3301static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3302 struct p2p_lo_start *param)
3303{
3304 wmi_buf_t buf;
3305 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3306 int32_t len = sizeof(*cmd);
3307 uint8_t *buf_ptr;
3308 QDF_STATUS status;
3309 int device_types_len_aligned;
3310 int probe_resp_len_aligned;
3311
3312 if (!param) {
3313 WMI_LOGE("lo start param is null");
3314 return QDF_STATUS_E_INVAL;
3315 }
3316
3317 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3318
3319 device_types_len_aligned =
3320 qdf_roundup(param->dev_types_len,
3321 sizeof(A_UINT32));
3322 probe_resp_len_aligned =
3323 qdf_roundup(param->probe_resp_len,
3324 sizeof(A_UINT32));
3325
3326 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3327 probe_resp_len_aligned;
3328
3329 buf = wmi_buf_alloc(wmi_handle, len);
3330 if (!buf) {
3331 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3332 __func__);
3333 return QDF_STATUS_E_NOMEM;
3334 }
3335
3336 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3337 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3338
3339 WMITLV_SET_HDR(&cmd->tlv_header,
3340 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3341 WMITLV_GET_STRUCT_TLVLEN(
3342 wmi_p2p_lo_start_cmd_fixed_param));
3343
3344 cmd->vdev_id = param->vdev_id;
3345 cmd->ctl_flags = param->ctl_flags;
3346 cmd->channel = param->freq;
3347 cmd->period = param->period;
3348 cmd->interval = param->interval;
3349 cmd->count = param->count;
3350 cmd->device_types_len = param->dev_types_len;
3351 cmd->prob_resp_len = param->probe_resp_len;
3352
3353 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3354 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3355 device_types_len_aligned);
3356 buf_ptr += WMI_TLV_HDR_SIZE;
3357 qdf_mem_copy(buf_ptr, param->device_types,
3358 param->dev_types_len);
3359
3360 buf_ptr += device_types_len_aligned;
3361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3362 probe_resp_len_aligned);
3363 buf_ptr += WMI_TLV_HDR_SIZE;
3364 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3365 param->probe_resp_len);
3366
3367 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3368 cmd->channel, cmd->period, cmd->interval, cmd->count);
3369
3370 status = wmi_unified_cmd_send(wmi_handle,
3371 buf, len,
3372 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3373 if (status != QDF_STATUS_SUCCESS) {
3374 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3375 __func__, status);
3376 wmi_buf_free(buf);
3377 return status;
3378 }
3379
3380 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3381
3382 return QDF_STATUS_SUCCESS;
3383}
3384
3385/**
3386 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3387 * @wmi_handle: wmi handle
3388 * @param: p2p listen offload stop parameters
3389 *
3390 * Return: QDF status
3391 */
3392static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3393 uint8_t vdev_id)
3394{
3395 wmi_buf_t buf;
3396 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3397 int32_t len;
3398 QDF_STATUS status;
3399
3400 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3401
3402 len = sizeof(*cmd);
3403 buf = wmi_buf_alloc(wmi_handle, len);
3404 if (!buf) {
3405 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3406 __func__);
3407 return QDF_STATUS_E_NOMEM;
3408 }
3409 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3410
3411 WMITLV_SET_HDR(&cmd->tlv_header,
3412 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3413 WMITLV_GET_STRUCT_TLVLEN(
3414 wmi_p2p_lo_stop_cmd_fixed_param));
3415
3416 cmd->vdev_id = vdev_id;
3417
3418 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3419
3420 status = wmi_unified_cmd_send(wmi_handle,
3421 buf, len,
3422 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3423 if (status != QDF_STATUS_SUCCESS) {
3424 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3425 __func__, status);
3426 wmi_buf_free(buf);
3427 return status;
3428 }
3429
3430 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3431
3432 return QDF_STATUS_SUCCESS;
3433}
3434#endif /* End of CONVERGED_P2P_ENABLE */
3435
Govind Singh427ee5a2016-02-26 18:09:36 +05303436/**
3437 * send_get_temperature_cmd_tlv() - get pdev temperature req
3438 * @wmi_handle: wmi handle
3439 *
Govind Singhb53420c2016-03-09 14:32:57 +05303440 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303441 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303442static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303443{
3444 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3445 wmi_buf_t wmi_buf;
3446 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3447 uint8_t *buf_ptr;
3448
3449 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303450 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3451 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303452 }
3453
3454 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3455 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303456 WMI_LOGE(FL("wmi_buf_alloc failed"));
3457 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303458 }
3459
3460 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3461
3462 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3463 WMITLV_SET_HDR(&cmd->tlv_header,
3464 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3465 WMITLV_GET_STRUCT_TLVLEN
3466 (wmi_pdev_get_temperature_cmd_fixed_param));
3467
3468 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3469 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303470 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303471 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303472 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303473 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303474
Govind Singhb53420c2016-03-09 14:32:57 +05303475 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303476}
3477
3478/**
3479 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3480 * @wmi_handle: wmi handle
3481 * @vdevid: vdev id
3482 * @peer_addr: peer mac address
3483 * @auto_triggerparam: auto trigger parameters
3484 * @num_ac: number of access category
3485 *
3486 * This function sets the trigger
3487 * uapsd params such as service interval, delay interval
3488 * and suspend interval which will be used by the firmware
3489 * to send trigger frames periodically when there is no
3490 * traffic on the transmit side.
3491 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303492 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303494static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303495 struct sta_uapsd_trig_params *param)
3496{
3497 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303498 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303499 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3500 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3501 uint32_t i;
3502 wmi_buf_t buf;
3503 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003504 struct sta_uapsd_params *uapsd_param;
3505 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303506
3507 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3508 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303509 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303510 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303511 }
3512
3513 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3514 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3515 WMITLV_SET_HDR(&cmd->tlv_header,
3516 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3517 WMITLV_GET_STRUCT_TLVLEN
3518 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3519 cmd->vdev_id = param->vdevid;
3520 cmd->num_ac = param->num_ac;
3521 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3522
3523 /* TLV indicating array of structures to follow */
3524 buf_ptr += sizeof(*cmd);
3525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3526
3527 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303528
3529 /*
3530 * Update tag and length for uapsd auto trigger params (this will take
3531 * care of updating tag and length if it is not pre-filled by caller).
3532 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003533 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3534 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303535 for (i = 0; i < param->num_ac; i++) {
3536 WMITLV_SET_HDR((buf_ptr +
3537 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3538 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3539 WMITLV_GET_STRUCT_TLVLEN
3540 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003541 trig_param->wmm_ac = uapsd_param->wmm_ac;
3542 trig_param->user_priority = uapsd_param->user_priority;
3543 trig_param->service_interval = uapsd_param->service_interval;
3544 trig_param->suspend_interval = uapsd_param->suspend_interval;
3545 trig_param->delay_interval = uapsd_param->delay_interval;
3546 trig_param++;
3547 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303548 }
3549
3550 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3551 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303552 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303553 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303554 wmi_buf_free(buf);
3555 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303556
Govind Singh427ee5a2016-02-26 18:09:36 +05303557 return ret;
3558}
3559
Govind Singh2edc80f2016-03-01 15:30:53 +05303560/**
3561 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3562 * @wmi_handle: pointer to the wmi handle
3563 * @utc: pointer to the UTC time struct
3564 *
3565 * Return: 0 on succes
3566 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303567static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303568 struct ocb_utc_param *utc)
3569{
Govind Singh67922e82016-04-01 16:48:57 +05303570 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303571 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3572 uint8_t *buf_ptr;
3573 uint32_t len, i;
3574 wmi_buf_t buf;
3575
3576 len = sizeof(*cmd);
3577 buf = wmi_buf_alloc(wmi_handle, len);
3578 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303579 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303580 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303581 }
3582
3583 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3584 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3585 WMITLV_SET_HDR(&cmd->tlv_header,
3586 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3587 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3588 cmd->vdev_id = utc->vdev_id;
3589
3590 for (i = 0; i < SIZE_UTC_TIME; i++)
3591 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3592
3593 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3594 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3595
3596 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3597 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303598 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303599 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303600 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303601 }
3602
Govind Singh67922e82016-04-01 16:48:57 +05303603 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303604}
3605
3606/**
3607 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3608 * frames on a channel
3609 * @wmi_handle: pointer to the wmi handle
3610 * @timing_advert: pointer to the timing advertisement struct
3611 *
3612 * Return: 0 on succes
3613 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303614static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303615 struct ocb_timing_advert_param *timing_advert)
3616{
Govind Singh67922e82016-04-01 16:48:57 +05303617 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303618 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3619 uint8_t *buf_ptr;
3620 uint32_t len, len_template;
3621 wmi_buf_t buf;
3622
3623 len = sizeof(*cmd) +
3624 WMI_TLV_HDR_SIZE;
3625
3626 len_template = timing_advert->template_length;
3627 /* Add padding to the template if needed */
3628 if (len_template % 4 != 0)
3629 len_template += 4 - (len_template % 4);
3630 len += len_template;
3631
3632 buf = wmi_buf_alloc(wmi_handle, len);
3633 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303634 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303635 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303636 }
3637
3638 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3639 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3640 WMITLV_SET_HDR(&cmd->tlv_header,
3641 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3642 WMITLV_GET_STRUCT_TLVLEN(
3643 wmi_ocb_start_timing_advert_cmd_fixed_param));
3644 cmd->vdev_id = timing_advert->vdev_id;
3645 cmd->repeat_rate = timing_advert->repeat_rate;
3646 cmd->channel_freq = timing_advert->chan_freq;
3647 cmd->timestamp_offset = timing_advert->timestamp_offset;
3648 cmd->time_value_offset = timing_advert->time_value_offset;
3649 cmd->timing_advert_template_length = timing_advert->template_length;
3650 buf_ptr += sizeof(*cmd);
3651
3652 /* Add the timing advert template */
3653 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3654 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303655 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303656 (uint8_t *)timing_advert->template_value,
3657 timing_advert->template_length);
3658
3659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3660 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303661 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303662 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303663 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303664 }
3665
Govind Singh67922e82016-04-01 16:48:57 +05303666 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303667}
3668
3669/**
3670 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3671 * on a channel
3672 * @wmi_handle: pointer to the wmi handle
3673 * @timing_advert: pointer to the timing advertisement struct
3674 *
3675 * Return: 0 on succes
3676 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303677static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303678 struct ocb_timing_advert_param *timing_advert)
3679{
Govind Singh67922e82016-04-01 16:48:57 +05303680 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303681 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3682 uint8_t *buf_ptr;
3683 uint32_t len;
3684 wmi_buf_t buf;
3685
3686 len = sizeof(*cmd);
3687 buf = wmi_buf_alloc(wmi_handle, len);
3688 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303689 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303690 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303691 }
3692
3693 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3694 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3695 WMITLV_SET_HDR(&cmd->tlv_header,
3696 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3697 WMITLV_GET_STRUCT_TLVLEN(
3698 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3699 cmd->vdev_id = timing_advert->vdev_id;
3700 cmd->channel_freq = timing_advert->chan_freq;
3701
3702 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3703 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303704 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303705 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303706 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303707 }
3708
Govind Singh67922e82016-04-01 16:48:57 +05303709 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303710}
3711
3712/**
3713 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3714 * @wmi_handle: pointer to the wmi handle
3715 * @request: pointer to the request
3716 *
3717 * Return: 0 on succes
3718 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303719static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303720 uint8_t vdev_id)
3721{
Govind Singhb53420c2016-03-09 14:32:57 +05303722 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303723 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3724 uint8_t *buf_ptr;
3725 wmi_buf_t buf;
3726 int32_t len;
3727
3728 len = sizeof(*cmd);
3729 buf = wmi_buf_alloc(wmi_handle, len);
3730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303731 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303732 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303733 }
3734 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3735
3736 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303737 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303738 WMITLV_SET_HDR(&cmd->tlv_header,
3739 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3740 WMITLV_GET_STRUCT_TLVLEN(
3741 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3742 cmd->vdev_id = vdev_id;
3743
3744 /* Send the WMI command */
3745 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3746 WMI_OCB_GET_TSF_TIMER_CMDID);
3747 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303748 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303749 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303750 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303751 }
3752
Govind Singh67922e82016-04-01 16:48:57 +05303753 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303754}
3755
3756/**
3757 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3758 * @wmi_handle: pointer to the wmi handle
3759 * @get_stats_param: pointer to the dcc stats
3760 *
3761 * Return: 0 on succes
3762 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303763static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303764 struct dcc_get_stats_param *get_stats_param)
3765{
Govind Singh67922e82016-04-01 16:48:57 +05303766 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303767 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3768 wmi_dcc_channel_stats_request *channel_stats_array;
3769 wmi_buf_t buf;
3770 uint8_t *buf_ptr;
3771 uint32_t len;
3772 uint32_t i;
3773
3774 /* Validate the input */
3775 if (get_stats_param->request_array_len !=
3776 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303778 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303779 }
3780
3781 /* Allocate memory for the WMI command */
3782 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3783 get_stats_param->request_array_len;
3784
3785 buf = wmi_buf_alloc(wmi_handle, len);
3786 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303787 WMI_LOGE(FL("wmi_buf_alloc failed"));
3788 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303789 }
3790
3791 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303792 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303793
3794 /* Populate the WMI command */
3795 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3796 buf_ptr += sizeof(*cmd);
3797
3798 WMITLV_SET_HDR(&cmd->tlv_header,
3799 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3800 WMITLV_GET_STRUCT_TLVLEN(
3801 wmi_dcc_get_stats_cmd_fixed_param));
3802 cmd->vdev_id = get_stats_param->vdev_id;
3803 cmd->num_channels = get_stats_param->channel_count;
3804
3805 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3806 get_stats_param->request_array_len);
3807 buf_ptr += WMI_TLV_HDR_SIZE;
3808
3809 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303810 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303811 get_stats_param->request_array_len);
3812 for (i = 0; i < cmd->num_channels; i++)
3813 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3814 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3815 WMITLV_GET_STRUCT_TLVLEN(
3816 wmi_dcc_channel_stats_request));
3817
3818 /* Send the WMI command */
3819 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3820 WMI_DCC_GET_STATS_CMDID);
3821
Govind Singh67922e82016-04-01 16:48:57 +05303822 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303823 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303824 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303825 }
3826
Govind Singh67922e82016-04-01 16:48:57 +05303827 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303828}
3829
3830/**
3831 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3832 * @wmi_handle: pointer to the wmi handle
3833 * @vdev_id: vdev id
3834 * @dcc_stats_bitmap: dcc status bitmap
3835 *
3836 * Return: 0 on succes
3837 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303838static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303839 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3840{
Govind Singh67922e82016-04-01 16:48:57 +05303841 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303842 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3843 wmi_buf_t buf;
3844 uint8_t *buf_ptr;
3845 uint32_t len;
3846
3847 /* Allocate memory for the WMI command */
3848 len = sizeof(*cmd);
3849
3850 buf = wmi_buf_alloc(wmi_handle, len);
3851 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303852 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303853 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303854 }
3855
3856 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303857 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303858
3859 /* Populate the WMI command */
3860 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3861
3862 WMITLV_SET_HDR(&cmd->tlv_header,
3863 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3864 WMITLV_GET_STRUCT_TLVLEN(
3865 wmi_dcc_clear_stats_cmd_fixed_param));
3866 cmd->vdev_id = vdev_id;
3867 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3868
3869 /* Send the WMI command */
3870 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3871 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303872 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303873 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303874 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303875 }
3876
Govind Singh67922e82016-04-01 16:48:57 +05303877 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303878}
3879
3880/**
3881 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3882 * @wmi_handle: pointer to the wmi handle
3883 * @update_ndl_param: pointer to the request parameters
3884 *
3885 * Return: 0 on success
3886 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303887static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303888 struct dcc_update_ndl_param *update_ndl_param)
3889{
Govind Singhb53420c2016-03-09 14:32:57 +05303890 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303891 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3892 wmi_dcc_ndl_chan *ndl_chan_array;
3893 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3894 uint32_t active_state_count;
3895 wmi_buf_t buf;
3896 uint8_t *buf_ptr;
3897 uint32_t len;
3898 uint32_t i;
3899
3900 /* validate the input */
3901 if (update_ndl_param->dcc_ndl_chan_list_len !=
3902 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303903 WMI_LOGE(FL("Invalid parameter"));
3904 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303905 }
3906 active_state_count = 0;
3907 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3908 for (i = 0; i < update_ndl_param->channel_count; i++)
3909 active_state_count +=
3910 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3911 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3912 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303913 WMI_LOGE(FL("Invalid parameter"));
3914 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303915 }
3916
3917 /* Allocate memory for the WMI command */
3918 len = sizeof(*cmd) +
3919 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3920 WMI_TLV_HDR_SIZE +
3921 update_ndl_param->dcc_ndl_active_state_list_len;
3922
3923 buf = wmi_buf_alloc(wmi_handle, len);
3924 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303925 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303926 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303927 }
3928
3929 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303930 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303931
3932 /* Populate the WMI command */
3933 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3934 buf_ptr += sizeof(*cmd);
3935
3936 WMITLV_SET_HDR(&cmd->tlv_header,
3937 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3938 WMITLV_GET_STRUCT_TLVLEN(
3939 wmi_dcc_update_ndl_cmd_fixed_param));
3940 cmd->vdev_id = update_ndl_param->vdev_id;
3941 cmd->num_channel = update_ndl_param->channel_count;
3942
3943 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3944 update_ndl_param->dcc_ndl_chan_list_len);
3945 buf_ptr += WMI_TLV_HDR_SIZE;
3946
3947 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303948 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303949 update_ndl_param->dcc_ndl_chan_list_len);
3950 for (i = 0; i < cmd->num_channel; i++)
3951 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3952 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3953 WMITLV_GET_STRUCT_TLVLEN(
3954 wmi_dcc_ndl_chan));
3955 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3956
3957 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3958 update_ndl_param->dcc_ndl_active_state_list_len);
3959 buf_ptr += WMI_TLV_HDR_SIZE;
3960
3961 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303962 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303963 update_ndl_param->dcc_ndl_active_state_list,
3964 update_ndl_param->dcc_ndl_active_state_list_len);
3965 for (i = 0; i < active_state_count; i++) {
3966 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3967 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3968 WMITLV_GET_STRUCT_TLVLEN(
3969 wmi_dcc_ndl_active_state_config));
3970 }
3971 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3972
3973 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303974 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303975 WMI_DCC_UPDATE_NDL_CMDID);
3976 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303977 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303979 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303980 }
3981
Govind Singh67922e82016-04-01 16:48:57 +05303982 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303983}
3984
3985/**
3986 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3987 * @wmi_handle: pointer to the wmi handle
3988 * @config: the OCB configuration
3989 *
3990 * Return: 0 on success
3991 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303992static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303993 struct ocb_config_param *config, uint32_t *ch_mhz)
3994{
Govind Singh67922e82016-04-01 16:48:57 +05303995 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303996 wmi_ocb_set_config_cmd_fixed_param *cmd;
3997 wmi_channel *chan;
3998 wmi_ocb_channel *ocb_chan;
3999 wmi_qos_parameter *qos_param;
4000 wmi_dcc_ndl_chan *ndl_chan;
4001 wmi_dcc_ndl_active_state_config *ndl_active_config;
4002 wmi_ocb_schedule_element *sched_elem;
4003 uint8_t *buf_ptr;
4004 wmi_buf_t buf;
4005 int32_t len;
4006 int32_t i, j, active_state_count;
4007
4008 /*
4009 * Validate the dcc_ndl_chan_list_len and count the number of active
4010 * states. Validate dcc_ndl_active_state_list_len.
4011 */
4012 active_state_count = 0;
4013 if (config->dcc_ndl_chan_list_len) {
4014 if (!config->dcc_ndl_chan_list ||
4015 config->dcc_ndl_chan_list_len !=
4016 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304017 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304018 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304019 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304020 }
4021
4022 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4023 i < config->channel_count; ++i, ++ndl_chan)
4024 active_state_count +=
4025 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4026
4027 if (active_state_count) {
4028 if (!config->dcc_ndl_active_state_list ||
4029 config->dcc_ndl_active_state_list_len !=
4030 active_state_count *
4031 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304032 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304033 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304034 }
4035 }
4036 }
4037
4038 len = sizeof(*cmd) +
4039 WMI_TLV_HDR_SIZE + config->channel_count *
4040 sizeof(wmi_channel) +
4041 WMI_TLV_HDR_SIZE + config->channel_count *
4042 sizeof(wmi_ocb_channel) +
4043 WMI_TLV_HDR_SIZE + config->channel_count *
4044 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4045 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4046 WMI_TLV_HDR_SIZE + active_state_count *
4047 sizeof(wmi_dcc_ndl_active_state_config) +
4048 WMI_TLV_HDR_SIZE + config->schedule_size *
4049 sizeof(wmi_ocb_schedule_element);
4050 buf = wmi_buf_alloc(wmi_handle, len);
4051 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304052 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304053 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304054 }
4055
4056 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4057 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4058 WMITLV_SET_HDR(&cmd->tlv_header,
4059 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4060 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
4061 cmd->vdev_id = config->session_id;
4062 cmd->channel_count = config->channel_count;
4063 cmd->schedule_size = config->schedule_size;
4064 cmd->flags = config->flags;
4065 buf_ptr += sizeof(*cmd);
4066
4067 /* Add the wmi_channel info */
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4069 config->channel_count*sizeof(wmi_channel));
4070 buf_ptr += WMI_TLV_HDR_SIZE;
4071 for (i = 0; i < config->channel_count; i++) {
4072 chan = (wmi_channel *)buf_ptr;
4073 WMITLV_SET_HDR(&chan->tlv_header,
4074 WMITLV_TAG_STRUC_wmi_channel,
4075 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4076 chan->mhz = config->channels[i].chan_freq;
4077 chan->band_center_freq1 = config->channels[i].chan_freq;
4078 chan->band_center_freq2 = 0;
4079 chan->info = 0;
4080
4081 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
4082 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4083 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4084 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4085 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4086 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4087 config->channels[i].antenna_max);
4088
4089 if (config->channels[i].bandwidth < 10)
4090 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4091 else if (config->channels[i].bandwidth < 20)
4092 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4093 buf_ptr += sizeof(*chan);
4094 }
4095
4096 /* Add the wmi_ocb_channel info */
4097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4098 config->channel_count*sizeof(wmi_ocb_channel));
4099 buf_ptr += WMI_TLV_HDR_SIZE;
4100 for (i = 0; i < config->channel_count; i++) {
4101 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4102 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4103 WMITLV_TAG_STRUC_wmi_ocb_channel,
4104 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4105 ocb_chan->bandwidth = config->channels[i].bandwidth;
4106 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4107 config->channels[i].mac_address.bytes,
4108 &ocb_chan->mac_address);
4109 buf_ptr += sizeof(*ocb_chan);
4110 }
4111
4112 /* Add the wmi_qos_parameter info */
4113 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4114 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4115 buf_ptr += WMI_TLV_HDR_SIZE;
4116 /* WMI_MAX_NUM_AC parameters for each channel */
4117 for (i = 0; i < config->channel_count; i++) {
4118 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4119 qos_param = (wmi_qos_parameter *)buf_ptr;
4120 WMITLV_SET_HDR(&qos_param->tlv_header,
4121 WMITLV_TAG_STRUC_wmi_qos_parameter,
4122 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4123 qos_param->aifsn =
4124 config->channels[i].qos_params[j].aifsn;
4125 qos_param->cwmin =
4126 config->channels[i].qos_params[j].cwmin;
4127 qos_param->cwmax =
4128 config->channels[i].qos_params[j].cwmax;
4129 buf_ptr += sizeof(*qos_param);
4130 }
4131 }
4132
4133 /* Add the wmi_dcc_ndl_chan (per channel) */
4134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4135 config->dcc_ndl_chan_list_len);
4136 buf_ptr += WMI_TLV_HDR_SIZE;
4137 if (config->dcc_ndl_chan_list_len) {
4138 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304139 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304140 config->dcc_ndl_chan_list_len);
4141 for (i = 0; i < config->channel_count; i++)
4142 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4143 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4144 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4145 buf_ptr += config->dcc_ndl_chan_list_len;
4146 }
4147
4148 /* Add the wmi_dcc_ndl_active_state_config */
4149 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4150 sizeof(wmi_dcc_ndl_active_state_config));
4151 buf_ptr += WMI_TLV_HDR_SIZE;
4152 if (active_state_count) {
4153 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304154 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304155 config->dcc_ndl_active_state_list,
4156 active_state_count * sizeof(*ndl_active_config));
4157 for (i = 0; i < active_state_count; ++i)
4158 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4159 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4160 WMITLV_GET_STRUCT_TLVLEN(
4161 wmi_dcc_ndl_active_state_config));
4162 buf_ptr += active_state_count *
4163 sizeof(*ndl_active_config);
4164 }
4165
4166 /* Add the wmi_ocb_schedule_element info */
4167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4168 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4169 buf_ptr += WMI_TLV_HDR_SIZE;
4170 for (i = 0; i < config->schedule_size; i++) {
4171 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4172 WMITLV_SET_HDR(&sched_elem->tlv_header,
4173 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4174 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4175 sched_elem->channel_freq = config->schedule[i].chan_freq;
4176 sched_elem->total_duration = config->schedule[i].total_duration;
4177 sched_elem->guard_interval = config->schedule[i].guard_interval;
4178 buf_ptr += sizeof(*sched_elem);
4179 }
4180
4181
4182 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4183 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304184 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304185 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304186 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304187 }
4188
Govind Singh67922e82016-04-01 16:48:57 +05304189 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304190}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304191
4192/**
4193 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4194 * @wmi_handle: wmi handle
4195 * @mcc_adaptive_scheduler: enable/disable
4196 *
4197 * This function enable/disable mcc adaptive scheduler in fw.
4198 *
Govind Singhb53420c2016-03-09 14:32:57 +05304199 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304200 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304201static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004202 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4203 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304204{
Govind Singh67922e82016-04-01 16:48:57 +05304205 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304206 wmi_buf_t buf = 0;
4207 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4208 uint16_t len =
4209 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4210
4211 buf = wmi_buf_alloc(wmi_handle, len);
4212 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304213 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4214 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304215 }
4216 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4217 wmi_buf_data(buf);
4218
4219 WMITLV_SET_HDR(&cmd->tlv_header,
4220 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4221 WMITLV_GET_STRUCT_TLVLEN
4222 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4223 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304224 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304225
4226 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4227 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304228 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304229 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304230 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304231 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304232 }
Govind Singh67922e82016-04-01 16:48:57 +05304233
4234 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304235}
4236
4237/**
4238 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4239 * @wmi: wmi handle
4240 * @mcc_channel: mcc channel
4241 * @mcc_channel_time_latency: MCC channel time latency.
4242 *
4243 * Currently used to set time latency for an MCC vdev/adapter using operating
4244 * channel of it and channel number. The info is provided run time using
4245 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4246 *
4247 * Return: CDF status
4248 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304249static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304250 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4251{
Govind Singh67922e82016-04-01 16:48:57 +05304252 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304253 wmi_buf_t buf = 0;
4254 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4255 uint16_t len = 0;
4256 uint8_t *buf_ptr = NULL;
4257 wmi_resmgr_chan_latency chan_latency;
4258 /* Note: we only support MCC time latency for a single channel */
4259 uint32_t num_channels = 1;
4260 uint32_t chan1_freq = mcc_channel_freq;
4261 uint32_t latency_chan1 = mcc_channel_time_latency;
4262
4263
4264 /* If 0ms latency is provided, then FW will set to a default.
4265 * Otherwise, latency must be at least 30ms.
4266 */
4267 if ((latency_chan1 > 0) &&
4268 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304269 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304270 "Minimum is 30ms (or 0 to use default value by "
4271 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304272 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304273 }
4274
4275 /* Set WMI CMD for channel time latency here */
4276 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4277 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4278 num_channels * sizeof(wmi_resmgr_chan_latency);
4279 buf = wmi_buf_alloc(wmi_handle, len);
4280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304281 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4282 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304283 }
4284 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4285 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4286 wmi_buf_data(buf);
4287 WMITLV_SET_HDR(&cmdTL->tlv_header,
4288 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4289 WMITLV_GET_STRUCT_TLVLEN
4290 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4291 cmdTL->num_chans = num_channels;
4292 /* Update channel time latency information for home channel(s) */
4293 buf_ptr += sizeof(*cmdTL);
4294 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4295 num_channels * sizeof(wmi_resmgr_chan_latency));
4296 buf_ptr += WMI_TLV_HDR_SIZE;
4297 chan_latency.chan_mhz = chan1_freq;
4298 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304299 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304300 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4301 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304302 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304303 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304304 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304305 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304306 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304307 }
Govind Singh67922e82016-04-01 16:48:57 +05304308
4309 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304310}
4311
4312/**
4313 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4314 * @wmi: wmi handle
4315 * @adapter_1_chan_number: adapter 1 channel number
4316 * @adapter_1_quota: adapter 1 quota
4317 * @adapter_2_chan_number: adapter 2 channel number
4318 *
4319 * Return: CDF status
4320 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304321static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304322 uint32_t adapter_1_chan_freq,
4323 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4324{
Govind Singh67922e82016-04-01 16:48:57 +05304325 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304326 wmi_buf_t buf = 0;
4327 uint16_t len = 0;
4328 uint8_t *buf_ptr = NULL;
4329 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4330 wmi_resmgr_chan_time_quota chan_quota;
4331 uint32_t quota_chan1 = adapter_1_quota;
4332 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4333 uint32_t quota_chan2 = 100 - quota_chan1;
4334 /* Note: setting time quota for MCC requires info for 2 channels */
4335 uint32_t num_channels = 2;
4336 uint32_t chan1_freq = adapter_1_chan_freq;
4337 uint32_t chan2_freq = adapter_2_chan_freq;
4338
Govind Singhb53420c2016-03-09 14:32:57 +05304339 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304340 "freq2:%dMHz, Quota2:%dms", __func__,
4341 chan1_freq, quota_chan1, chan2_freq,
4342 quota_chan2);
4343
4344 /*
4345 * Perform sanity check on time quota values provided.
4346 */
4347 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4348 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304349 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304350 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304351 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304352 }
4353 /* Set WMI CMD for channel time quota here */
4354 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4355 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4356 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4357 buf = wmi_buf_alloc(wmi_handle, len);
4358 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304359 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4360 QDF_ASSERT(0);
4361 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304362 }
4363 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4364 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4365 wmi_buf_data(buf);
4366 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4367 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4368 WMITLV_GET_STRUCT_TLVLEN
4369 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4370 cmdTQ->num_chans = num_channels;
4371
4372 /* Update channel time quota information for home channel(s) */
4373 buf_ptr += sizeof(*cmdTQ);
4374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4375 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4376 buf_ptr += WMI_TLV_HDR_SIZE;
4377 chan_quota.chan_mhz = chan1_freq;
4378 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304379 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304380 /* Construct channel and quota record for the 2nd MCC mode. */
4381 buf_ptr += sizeof(chan_quota);
4382 chan_quota.chan_mhz = chan2_freq;
4383 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304384 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304385
4386 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4387 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304388 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304389 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304390 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304391 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304392 }
Govind Singh67922e82016-04-01 16:48:57 +05304393
4394 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304395}
4396
4397/**
4398 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4399 * @wmi_handle: Pointer to wmi handle
4400 * @thermal_info: Thermal command information
4401 *
4402 * This function sends the thermal management command
4403 * to the firmware
4404 *
Govind Singhb53420c2016-03-09 14:32:57 +05304405 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304406 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304407static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304408 struct thermal_cmd_params *thermal_info)
4409{
4410 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4411 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304412 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304413 uint32_t len = 0;
4414
4415 len = sizeof(*cmd);
4416
4417 buf = wmi_buf_alloc(wmi_handle, len);
4418 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304419 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4420 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304421 }
4422
4423 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4424
4425 WMITLV_SET_HDR(&cmd->tlv_header,
4426 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4427 WMITLV_GET_STRUCT_TLVLEN
4428 (wmi_thermal_mgmt_cmd_fixed_param));
4429
4430 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4431 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4432 cmd->enable = thermal_info->thermal_enable;
4433
Govind Singhb53420c2016-03-09 14:32:57 +05304434 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304435 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4436
4437 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4438 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304439 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304440 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304441 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304442 }
4443
Govind Singh67922e82016-04-01 16:48:57 +05304444 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304445}
4446
4447
4448/**
4449 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304450 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304451 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4452 *
4453 * This function sends down the LRO configuration parameters to
4454 * the firmware to enable LRO, sets the TCP flags and sets the
4455 * seed values for the toeplitz hash generation
4456 *
Govind Singhb53420c2016-03-09 14:32:57 +05304457 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304458 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304459static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304460 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4461{
4462 wmi_lro_info_cmd_fixed_param *cmd;
4463 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304464 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304465
4466
4467 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4468 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304469 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4470 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304471 }
4472
4473 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4474
4475 WMITLV_SET_HDR(&cmd->tlv_header,
4476 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4477 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4478
4479 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4480 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4481 wmi_lro_cmd->tcp_flag);
4482 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4483 wmi_lro_cmd->tcp_flag_mask);
4484 cmd->toeplitz_hash_ipv4_0_3 =
4485 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4486 cmd->toeplitz_hash_ipv4_4_7 =
4487 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4488 cmd->toeplitz_hash_ipv4_8_11 =
4489 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4490 cmd->toeplitz_hash_ipv4_12_15 =
4491 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4492 cmd->toeplitz_hash_ipv4_16 =
4493 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4494
4495 cmd->toeplitz_hash_ipv6_0_3 =
4496 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4497 cmd->toeplitz_hash_ipv6_4_7 =
4498 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4499 cmd->toeplitz_hash_ipv6_8_11 =
4500 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4501 cmd->toeplitz_hash_ipv6_12_15 =
4502 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4503 cmd->toeplitz_hash_ipv6_16_19 =
4504 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4505 cmd->toeplitz_hash_ipv6_20_23 =
4506 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4507 cmd->toeplitz_hash_ipv6_24_27 =
4508 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4509 cmd->toeplitz_hash_ipv6_28_31 =
4510 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4511 cmd->toeplitz_hash_ipv6_32_35 =
4512 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4513 cmd->toeplitz_hash_ipv6_36_39 =
4514 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4515 cmd->toeplitz_hash_ipv6_40 =
4516 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4517
Govind Singhb53420c2016-03-09 14:32:57 +05304518 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304519 cmd->lro_enable, cmd->tcp_flag_u32);
4520
4521 status = wmi_unified_cmd_send(wmi_handle, buf,
4522 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304523 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304524 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304525 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304526 }
4527
Govind Singh67922e82016-04-01 16:48:57 +05304528 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304529}
4530
Govind Singh4eacd2b2016-03-07 14:24:22 +05304531/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304532 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4533 * @wmi_handle: Pointer to wmi handle
4534 * @rate_report_params: Pointer to peer rate report parameters
4535 *
4536 *
4537 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4538 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304539static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304540 struct wmi_peer_rate_report_params *rate_report_params)
4541{
4542 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4543 wmi_buf_t buf = NULL;
4544 QDF_STATUS status = 0;
4545 uint32_t len = 0;
4546 uint32_t i, j;
4547
4548 len = sizeof(*cmd);
4549
4550 buf = wmi_buf_alloc(wmi_handle, len);
4551 if (!buf) {
4552 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4553 return QDF_STATUS_E_FAILURE;
4554 }
4555
4556 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4557 wmi_buf_data(buf);
4558
4559 WMITLV_SET_HDR(
4560 &cmd->tlv_header,
4561 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4562 WMITLV_GET_STRUCT_TLVLEN(
4563 wmi_peer_set_rate_report_condition_fixed_param));
4564
4565 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4566 cmd->report_backoff_time = rate_report_params->backoff_time;
4567 cmd->report_timer_period = rate_report_params->timer_period;
4568 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4569 cmd->cond_per_phy[i].val_cond_flags =
4570 rate_report_params->report_per_phy[i].cond_flags;
4571 cmd->cond_per_phy[i].rate_delta.min_delta =
4572 rate_report_params->report_per_phy[i].delta.delta_min;
4573 cmd->cond_per_phy[i].rate_delta.percentage =
4574 rate_report_params->report_per_phy[i].delta.percent;
4575 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4576 cmd->cond_per_phy[i].rate_threshold[j] =
4577 rate_report_params->report_per_phy[i].
4578 report_rate_threshold[j];
4579 }
4580 }
4581
4582 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4583 cmd->enable_rate_report,
4584 cmd->report_backoff_time, cmd->report_timer_period);
4585
4586 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4587 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4588 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304589 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304590 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4591 __func__);
4592 }
4593 return status;
4594}
4595
4596/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304597 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4598 * @wmi_handle: wmi handle
4599 * @param: bcn ll cmd parameter
4600 *
Govind Singhb53420c2016-03-09 14:32:57 +05304601 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304602 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304603static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304604 wmi_bcn_send_from_host_cmd_fixed_param *param)
4605{
4606 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4607 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304608 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304609
4610 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4611 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304612 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4613 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304614 }
4615
4616 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4617 WMITLV_SET_HDR(&cmd->tlv_header,
4618 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4619 WMITLV_GET_STRUCT_TLVLEN
4620 (wmi_bcn_send_from_host_cmd_fixed_param));
4621 cmd->vdev_id = param->vdev_id;
4622 cmd->data_len = param->data_len;
4623 cmd->frame_ctrl = param->frame_ctrl;
4624 cmd->frag_ptr = param->frag_ptr;
4625 cmd->dtim_flag = param->dtim_flag;
4626
4627 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4628 WMI_PDEV_SEND_BCN_CMDID);
4629
Govind Singh67922e82016-04-01 16:48:57 +05304630 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304631 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304632 wmi_buf_free(wmi_buf);
4633 }
4634
4635 return ret;
4636}
4637
4638/**
4639 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4640 * @wmi_handle: wmi handle
4641 * @vdev_id: vdev id
4642 * @max_retries: max retries
4643 * @retry_interval: retry interval
4644 * This function sets sta query related parameters in fw.
4645 *
Govind Singhb53420c2016-03-09 14:32:57 +05304646 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304647 */
4648
Sathish Kumarfd347372017-02-13 12:29:09 +05304649static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304650 uint8_t vdev_id, uint32_t max_retries,
4651 uint32_t retry_interval)
4652{
4653 wmi_buf_t buf;
4654 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4655 int len;
4656
4657 len = sizeof(*cmd);
4658 buf = wmi_buf_alloc(wmi_handle, len);
4659 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304660 WMI_LOGE(FL("wmi_buf_alloc failed"));
4661 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304662 }
4663
4664 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4665 WMITLV_SET_HDR(&cmd->tlv_header,
4666 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4667 WMITLV_GET_STRUCT_TLVLEN
4668 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4669
4670
4671 cmd->vdev_id = vdev_id;
4672 cmd->sa_query_max_retry_count = max_retries;
4673 cmd->sa_query_retry_interval = retry_interval;
4674
Govind Singhb53420c2016-03-09 14:32:57 +05304675 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304676 vdev_id, retry_interval, max_retries);
4677
4678 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4679 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304680 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304681 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304682 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304683 }
4684
Govind Singhb53420c2016-03-09 14:32:57 +05304685 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304686 return 0;
4687}
4688
4689/**
4690 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4691 * @wmi_handle: wmi handle
4692 * @params: sta keep alive parameter
4693 *
4694 * This function sets keep alive related parameters in fw.
4695 *
4696 * Return: CDF status
4697 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304698static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304699 struct sta_params *params)
4700{
4701 wmi_buf_t buf;
4702 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4703 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4704 uint8_t *buf_ptr;
4705 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304706 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304707
Govind Singhb53420c2016-03-09 14:32:57 +05304708 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304709
Govind Singh4eacd2b2016-03-07 14:24:22 +05304710 len = sizeof(*cmd) + sizeof(*arp_rsp);
4711 buf = wmi_buf_alloc(wmi_handle, len);
4712 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304713 WMI_LOGE("wmi_buf_alloc failed");
4714 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304715 }
4716
4717 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4718 buf_ptr = (uint8_t *) cmd;
4719 WMITLV_SET_HDR(&cmd->tlv_header,
4720 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4721 WMITLV_GET_STRUCT_TLVLEN
4722 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4723 cmd->interval = params->timeperiod;
4724 cmd->enable = (params->timeperiod) ? 1 : 0;
4725 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304726 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304727 params->timeperiod, params->method);
4728 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4729 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4730 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4731 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4732
c_manjee2772b9c2017-01-23 15:14:13 +05304733 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
4734 (params->method ==
4735 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05304736 if ((NULL == params->hostv4addr) ||
4737 (NULL == params->destv4addr) ||
4738 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07004739 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
4740 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304741 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304742 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304743 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304744 }
c_manjee2772b9c2017-01-23 15:14:13 +05304745 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05304746 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304747 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304748 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304749 WMI_IPV4_ADDR_LEN);
4750 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4751 } else {
4752 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4753 }
4754
Govind Singh67922e82016-04-01 16:48:57 +05304755 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4756 WMI_STA_KEEPALIVE_CMDID);
4757 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304758 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304759 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304760 }
4761
Govind Singhb53420c2016-03-09 14:32:57 +05304762 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304763 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304764}
4765
4766/**
4767 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4768 * @wmi_handle: wmi handle
4769 * @if_id: vdev id
4770 * @gtx_info: GTX config params
4771 *
4772 * This function set GTX related params in firmware.
4773 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304774 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304775 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304776static 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 +05304777 struct wmi_gtx_config *gtx_info)
4778{
4779 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4780 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304781 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304782 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304783
Govind Singh4eacd2b2016-03-07 14:24:22 +05304784 buf = wmi_buf_alloc(wmi_handle, len);
4785 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304786 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304787 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304788 }
4789 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4790 WMITLV_SET_HDR(&cmd->tlv_header,
4791 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4792 WMITLV_GET_STRUCT_TLVLEN
4793 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4794 cmd->vdev_id = if_id;
4795
4796 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4797 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4798 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4799 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4800 cmd->gtxPERMargin = gtx_info->gtx_margin;
4801 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4802 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4803 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4804
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304806 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4807 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4808 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4809 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4810
Abhishek Singh716c46c2016-05-04 16:24:07 +05304811 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304812 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304813 if (QDF_IS_STATUS_ERROR(ret)) {
4814 WMI_LOGE("Failed to set GTX PARAMS");
4815 wmi_buf_free(buf);
4816 }
4817 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304818}
4819
4820/**
4821 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4822 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304823 * @vdev_id: vdev id.
4824 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05304825 *
4826 * This function updates EDCA parameters to the target
4827 *
4828 * Return: CDF Status
4829 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304830static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304831 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304832 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05304833{
4834 uint8_t *buf_ptr;
4835 wmi_buf_t buf;
4836 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304837 wmi_wmm_vparams *wmm_param;
4838 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304839 int len = sizeof(*cmd);
4840 int ac;
4841
4842 buf = wmi_buf_alloc(wmi_handle, len);
4843
4844 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304845 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4846 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304847 }
4848
4849 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4850 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4851 WMITLV_SET_HDR(&cmd->tlv_header,
4852 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4853 WMITLV_GET_STRUCT_TLVLEN
4854 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4855 cmd->vdev_id = vdev_id;
4856
4857 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4858 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304859 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304860 WMITLV_SET_HDR(&wmm_param->tlv_header,
4861 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4862 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4863 wmm_param->cwmin = twmm_param->cwmin;
4864 wmm_param->cwmax = twmm_param->cwmax;
4865 wmm_param->aifs = twmm_param->aifs;
4866 wmm_param->txoplimit = twmm_param->txoplimit;
4867 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304868 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304869 }
4870
4871 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4872 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4873 goto fail;
4874
Govind Singhb53420c2016-03-09 14:32:57 +05304875 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304876
4877fail:
4878 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304879 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4880 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304881}
4882
4883/**
4884 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4885 * @wmi_handle: wmi handle
4886 * @vdev_id: vdev id
4887 * @probe_rsp_info: probe response info
4888 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304889 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304890 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304891static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304892 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08004893 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304894{
4895 wmi_prb_tmpl_cmd_fixed_param *cmd;
4896 wmi_bcn_prb_info *bcn_prb_info;
4897 wmi_buf_t wmi_buf;
4898 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4899 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304900 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304901
Govind Singhb53420c2016-03-09 14:32:57 +05304902 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304903
Krunal Soni89426862017-11-14 15:42:48 -08004904 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304905 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4906
4907 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4908 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4909 tmpl_len_aligned;
4910
4911 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304912 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304913 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304914 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304915 }
4916
4917 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4918 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304919 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304920 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304921 }
4922
4923 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4924
4925 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4926 WMITLV_SET_HDR(&cmd->tlv_header,
4927 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4928 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4929 cmd->vdev_id = vdev_id;
4930 cmd->buf_len = tmpl_len;
4931 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4932
4933 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4934 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4935 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4936 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4937 bcn_prb_info->caps = 0;
4938 bcn_prb_info->erp = 0;
4939 buf_ptr += sizeof(wmi_bcn_prb_info);
4940
4941 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4942 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08004943 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304944
4945 ret = wmi_unified_cmd_send(wmi_handle,
4946 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304947 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304948 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304949 wmi_buf_free(wmi_buf);
4950 }
4951
4952 return ret;
4953}
4954
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304955#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304956#define WPI_IV_LEN 16
4957
4958/**
4959 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4960 *
4961 * @dest_tx: destination address of tsc key counter
4962 * @src_tx: source address of tsc key counter
4963 * @dest_rx: destination address of rsc key counter
4964 * @src_rx: source address of rsc key counter
4965 *
4966 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4967 *
4968 * Return: None
4969 *
4970 */
4971static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4972 uint8_t *dest_rx, uint8_t *src_rx)
4973{
4974 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4975 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4976}
4977#else
4978static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4979 uint8_t *dest_rx, uint8_t *src_rx)
4980{
4981 return;
4982}
4983#endif
4984
4985/**
4986 * send_setup_install_key_cmd_tlv() - set key parameters
4987 * @wmi_handle: wmi handle
4988 * @key_params: key parameters
4989 *
4990 * This function fills structure from information
4991 * passed in key_params.
4992 *
4993 * Return: QDF_STATUS_SUCCESS - success
4994 * QDF_STATUS_E_FAILURE - failure
4995 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4996 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304997static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304998 struct set_key_params *key_params)
4999{
5000 wmi_vdev_install_key_cmd_fixed_param *cmd;
5001 wmi_buf_t buf;
5002 uint8_t *buf_ptr;
5003 uint32_t len;
5004 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305005 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305006
5007 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5008 WMI_TLV_HDR_SIZE;
5009
5010 buf = wmi_buf_alloc(wmi_handle, len);
5011 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305012 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305013 return QDF_STATUS_E_NOMEM;
5014 }
5015
5016 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5017 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5018 WMITLV_SET_HDR(&cmd->tlv_header,
5019 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5020 WMITLV_GET_STRUCT_TLVLEN
5021 (wmi_vdev_install_key_cmd_fixed_param));
5022 cmd->vdev_id = key_params->vdev_id;
5023 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305024
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305025
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305026 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5027 cmd->key_flags |= key_params->key_flags;
5028 cmd->key_cipher = key_params->key_cipher;
5029 if ((key_params->key_txmic_len) &&
5030 (key_params->key_rxmic_len)) {
5031 cmd->key_txmic_len = key_params->key_txmic_len;
5032 cmd->key_rxmic_len = key_params->key_rxmic_len;
5033 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305034#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305035 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5036 key_params->tx_iv,
5037 cmd->wpi_key_rsc_counter,
5038 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305039#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305040 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5041 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5042 roundup(key_params->key_len, sizeof(uint32_t)));
5043 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
5044 qdf_mem_copy((void *)key_data,
5045 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005046 if (key_params->key_rsc_counter)
5047 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5048 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305049 cmd->key_len = key_params->key_len;
5050
5051 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5052 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305053 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305054 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305055
Govind Singh67922e82016-04-01 16:48:57 +05305056 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305057}
5058
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305059/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005060 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5061 * @wmi_handle: wmi handle
5062 * @params: sar limit params
5063 *
5064 * Return: QDF_STATUS_SUCCESS for success or error code
5065 */
5066static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5067 struct sar_limit_cmd_params *sar_limit_params)
5068{
5069 wmi_buf_t buf;
5070 QDF_STATUS qdf_status;
5071 wmi_sar_limits_cmd_fixed_param *cmd;
5072 int i;
5073 uint8_t *buf_ptr;
5074 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5075 struct sar_limit_cmd_row *sar_rows_list;
5076 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5077
5078 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5079 buf = wmi_buf_alloc(wmi_handle, len);
5080 if (!buf) {
5081 WMI_LOGE("Failed to allocate memory");
5082 qdf_status = QDF_STATUS_E_NOMEM;
5083 goto end;
5084 }
5085
5086 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5087 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5088 WMITLV_SET_HDR(&cmd->tlv_header,
5089 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5090 WMITLV_GET_STRUCT_TLVLEN
5091 (wmi_sar_limits_cmd_fixed_param));
5092 cmd->sar_enable = sar_limit_params->sar_enable;
5093 cmd->commit_limits = sar_limit_params->commit_limits;
5094 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5095
5096 WMI_LOGD("no of sar rows = %d, len = %d",
5097 sar_limit_params->num_limit_rows, len);
5098 buf_ptr += sizeof(*cmd);
5099 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5100 sizeof(wmi_sar_limit_cmd_row) *
5101 sar_limit_params->num_limit_rows);
5102 if (cmd->num_limit_rows == 0)
5103 goto send_sar_limits;
5104
5105 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5106 (buf_ptr + WMI_TLV_HDR_SIZE);
5107 sar_rows_list = sar_limit_params->sar_limit_row_list;
5108
5109 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5110 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5111 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5112 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5113 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5114 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5115 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5116 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5117 wmi_sar_rows_list->validity_bitmap =
5118 sar_rows_list->validity_bitmap;
5119 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5120 i, wmi_sar_rows_list->band_id,
5121 wmi_sar_rows_list->chain_id,
5122 wmi_sar_rows_list->mod_id,
5123 wmi_sar_rows_list->limit_value,
5124 wmi_sar_rows_list->validity_bitmap);
5125 sar_rows_list++;
5126 wmi_sar_rows_list++;
5127 }
5128send_sar_limits:
5129 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5130 WMI_SAR_LIMITS_CMDID);
5131
5132 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5133 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5134 wmi_buf_free(buf);
5135 }
5136
5137end:
5138 return qdf_status;
5139}
5140
5141/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305142 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5143 * @wmi_handle: wmi handle
5144 * @params: encrypt/decrypt params
5145 *
5146 * Return: QDF_STATUS_SUCCESS for success or error code
5147 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005148static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305149QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
5150 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
5151{
5152 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5153 wmi_buf_t wmi_buf;
5154 uint8_t *buf_ptr;
5155 QDF_STATUS ret;
5156 uint32_t len;
5157
5158 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5159
5160 len = sizeof(*cmd) +
5161 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5162 WMI_TLV_HDR_SIZE;
5163 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5164 if (!wmi_buf) {
5165 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5166 __func__);
5167 return QDF_STATUS_E_NOMEM;
5168 }
5169
5170 buf_ptr = wmi_buf_data(wmi_buf);
5171 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5172
5173 WMITLV_SET_HDR(&cmd->tlv_header,
5174 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5175 WMITLV_GET_STRUCT_TLVLEN(
5176 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5177
5178 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5179 cmd->key_flag = encrypt_decrypt_params->key_flag;
5180 cmd->key_idx = encrypt_decrypt_params->key_idx;
5181 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5182 cmd->key_len = encrypt_decrypt_params->key_len;
5183 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5184 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5185
5186 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5187 encrypt_decrypt_params->key_len);
5188
5189 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5190 MAX_MAC_HEADER_LEN);
5191
5192 cmd->data_len = encrypt_decrypt_params->data_len;
5193
5194 if (cmd->data_len) {
5195 buf_ptr += sizeof(*cmd);
5196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5197 roundup(encrypt_decrypt_params->data_len,
5198 sizeof(A_UINT32)));
5199 buf_ptr += WMI_TLV_HDR_SIZE;
5200 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5201 encrypt_decrypt_params->data_len);
5202 }
5203
5204 /* This conversion is to facilitate data to FW in little endian */
5205 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5206 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5207 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5208 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5209 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5210 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5211
5212 ret = wmi_unified_cmd_send(wmi_handle,
5213 wmi_buf, len,
5214 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5215 if (QDF_IS_STATUS_ERROR(ret)) {
5216 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5217 wmi_buf_free(wmi_buf);
5218 }
5219
5220 return ret;
5221}
5222
5223
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305224
Govind Singh4eacd2b2016-03-07 14:24:22 +05305225/**
5226 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5227 * @wmi_handle: wmi handle
5228 * @vdev_id: vdev id
5229 * @p2p_ie: p2p IE
5230 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305231 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305233static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 A_UINT32 vdev_id, uint8_t *p2p_ie)
5235{
Govind Singh67922e82016-04-01 16:48:57 +05305236 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5238 wmi_buf_t wmi_buf;
5239 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5240 uint8_t *buf_ptr;
5241
5242 ie_len = (uint32_t) (p2p_ie[1] + 2);
5243
5244 /* More than one P2P IE may be included in a single frame.
5245 If multiple P2P IEs are present, the complete P2P attribute
5246 data consists of the concatenation of the P2P Attribute
5247 fields of the P2P IEs. The P2P Attributes field of each
5248 P2P IE may be any length up to the maximum (251 octets).
5249 In this case host sends one P2P IE to firmware so the length
5250 should not exceed more than 251 bytes
5251 */
5252 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305253 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305254 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305255 }
5256
5257 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5258
5259 wmi_buf_len =
5260 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5261 WMI_TLV_HDR_SIZE;
5262
5263 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5264 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305265 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305266 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267 }
5268
5269 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5270
5271 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5272 WMITLV_SET_HDR(&cmd->tlv_header,
5273 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5274 WMITLV_GET_STRUCT_TLVLEN
5275 (wmi_p2p_go_set_beacon_ie_fixed_param));
5276 cmd->vdev_id = vdev_id;
5277 cmd->ie_buf_len = ie_len;
5278
5279 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5280 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5281 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305282 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305283
Govind Singhb53420c2016-03-09 14:32:57 +05305284 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305285
5286 ret = wmi_unified_cmd_send(wmi_handle,
5287 wmi_buf, wmi_buf_len,
5288 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305289 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305290 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305291 wmi_buf_free(wmi_buf);
5292 }
5293
Govind Singhb53420c2016-03-09 14:32:57 +05305294 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305295 return ret;
5296}
5297
5298/**
5299 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5300 * @wmi_handle: wmi handle
5301 * @req: gateway parameter update request structure
5302 *
5303 * This function reads the incoming @req and fill in the destination
5304 * WMI structure and sends down the gateway configs down to the firmware
5305 *
Govind Singhb53420c2016-03-09 14:32:57 +05305306 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305308static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305309 struct gateway_update_req_param *req)
5310{
5311 wmi_roam_subnet_change_config_fixed_param *cmd;
5312 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305313 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305314 int len = sizeof(*cmd);
5315
5316 buf = wmi_buf_alloc(wmi_handle, len);
5317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305318 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5319 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305320 }
5321
5322 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5323 WMITLV_SET_HDR(&cmd->tlv_header,
5324 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5325 WMITLV_GET_STRUCT_TLVLEN(
5326 wmi_roam_subnet_change_config_fixed_param));
5327
5328 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305329 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5330 QDF_IPV4_ADDR_SIZE);
5331 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5332 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305333 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5334 &cmd->inet_gw_mac_addr);
5335 cmd->max_retries = req->max_retries;
5336 cmd->timeout = req->timeout;
5337 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5338 cmd->flag = 0;
5339 if (req->ipv4_addr_type)
5340 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5341
5342 if (req->ipv6_addr_type)
5343 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5344
5345 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5346 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305347 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305348 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305349 ret);
5350 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305351 }
5352
Govind Singh67922e82016-04-01 16:48:57 +05305353 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305354}
5355
5356/**
5357 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5358 * @wmi_handle: wmi handle
5359 * @req: rssi monitoring request structure
5360 *
5361 * This function reads the incoming @req and fill in the destination
5362 * WMI structure and send down the rssi monitoring configs down to the firmware
5363 *
5364 * Return: 0 on success; error number otherwise
5365 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305366static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305367 struct rssi_monitor_param *req)
5368{
5369 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5370 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305371 QDF_STATUS ret;
5372 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305373
5374 buf = wmi_buf_alloc(wmi_handle, len);
5375 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305376 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5377 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305378 }
5379
5380 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5381 WMITLV_SET_HDR(&cmd->tlv_header,
5382 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5383 WMITLV_GET_STRUCT_TLVLEN(
5384 wmi_rssi_breach_monitor_config_fixed_param));
5385
5386 cmd->vdev_id = req->session_id;
5387 cmd->request_id = req->request_id;
5388 cmd->lo_rssi_reenable_hysteresis = 0;
5389 cmd->hi_rssi_reenable_histeresis = 0;
5390 cmd->min_report_interval = 0;
5391 cmd->max_num_report = 1;
5392 if (req->control) {
5393 /* enable one threshold for each min/max */
5394 cmd->enabled_bitmap = 0x09;
5395 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5396 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5397 } else {
5398 cmd->enabled_bitmap = 0;
5399 cmd->low_rssi_breach_threshold[0] = 0;
5400 cmd->hi_rssi_breach_threshold[0] = 0;
5401 }
5402
5403 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5404 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305405 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305406 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305407 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305408 }
5409
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005410 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5411
Govind Singh67922e82016-04-01 16:48:57 +05305412 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305413}
5414
5415/**
5416 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5417 * @wmi_handle: wmi handle
5418 * @psetoui: OUI parameters
5419 *
5420 * set scan probe OUI parameters in firmware
5421 *
5422 * Return: CDF status
5423 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305424static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305425 struct scan_mac_oui *psetoui)
5426{
5427 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5428 wmi_buf_t wmi_buf;
5429 uint32_t len;
5430 uint8_t *buf_ptr;
5431 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305432 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305433
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305434 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5435 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5436
Govind Singh4eacd2b2016-03-07 14:24:22 +05305437 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5438 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305439 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5440 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305441 }
5442 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5443 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5444 WMITLV_SET_HDR(&cmd->tlv_header,
5445 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5446 WMITLV_GET_STRUCT_TLVLEN
5447 (wmi_scan_prob_req_oui_cmd_fixed_param));
5448
5449 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305450 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305451 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5452 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305453 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305454 cmd->prob_req_oui);
5455
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305456 cmd->vdev_id = psetoui->vdev_id;
5457 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5458 if (psetoui->enb_probe_req_sno_randomization)
5459 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5460
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305461 if (ie_whitelist->white_list) {
5462 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5463 &cmd->num_vendor_oui,
5464 ie_whitelist);
5465 cmd->flags |=
5466 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5467 }
5468
5469 buf_ptr += sizeof(*cmd);
5470 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5471 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5472 buf_ptr += WMI_TLV_HDR_SIZE;
5473
5474 if (cmd->num_vendor_oui != 0) {
5475 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5476 ie_whitelist->voui);
5477 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5478 }
5479
Govind Singh4eacd2b2016-03-07 14:24:22 +05305480 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5481 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305482 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305483 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305484 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305485 }
Govind Singhb53420c2016-03-09 14:32:57 +05305486 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305487}
5488
5489/**
5490 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5491 * @wmi_handle: wmi handle
5492 * @req: passpoint network request structure
5493 *
5494 * This function sends down WMI command with network id set to wildcard id.
5495 * firmware shall clear all the config entries
5496 *
Govind Singhb53420c2016-03-09 14:32:57 +05305497 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305498 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305499static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305500 struct wifi_passpoint_req_param *req)
5501{
5502 wmi_passpoint_config_cmd_fixed_param *cmd;
5503 wmi_buf_t buf;
5504 uint32_t len;
5505 int ret;
5506
5507 len = sizeof(*cmd);
5508 buf = wmi_buf_alloc(wmi_handle, len);
5509 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305510 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5511 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305512 }
5513
5514 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5515
5516 WMITLV_SET_HDR(&cmd->tlv_header,
5517 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5518 WMITLV_GET_STRUCT_TLVLEN(
5519 wmi_passpoint_config_cmd_fixed_param));
5520 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5521
5522 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5523 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5524 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305525 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305526 __func__);
5527 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305528 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305529 }
5530
Govind Singhb53420c2016-03-09 14:32:57 +05305531 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305532}
5533
5534/**
5535 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5536 * @wmi_handle: wmi handle
5537 * @req: passpoint network request structure
5538 *
5539 * This function reads the incoming @req and fill in the destination
5540 * WMI structure and send down the passpoint configs down to the firmware
5541 *
Govind Singhb53420c2016-03-09 14:32:57 +05305542 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305543 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305544static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305545 struct wifi_passpoint_req_param *req)
5546{
5547 wmi_passpoint_config_cmd_fixed_param *cmd;
5548 u_int8_t i, j, *bytes;
5549 wmi_buf_t buf;
5550 uint32_t len;
5551 int ret;
5552
5553 len = sizeof(*cmd);
5554 for (i = 0; i < req->num_networks; i++) {
5555 buf = wmi_buf_alloc(wmi_handle, len);
5556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305557 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5558 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305559 }
5560
5561 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5562 wmi_buf_data(buf);
5563
5564 WMITLV_SET_HDR(&cmd->tlv_header,
5565 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5566 WMITLV_GET_STRUCT_TLVLEN(
5567 wmi_passpoint_config_cmd_fixed_param));
5568 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305569 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5570 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305571 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305572 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305573 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5574 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305575 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305576 j, bytes[0], bytes[1], bytes[2], bytes[3],
5577 bytes[4], bytes[5], bytes[6], bytes[7]);
5578
Govind Singhb53420c2016-03-09 14:32:57 +05305579 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305580 &req->networks[i].roaming_consortium_ids[j],
5581 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5582 }
Govind Singhb53420c2016-03-09 14:32:57 +05305583 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305584 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305585 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305586 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5587
5588 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5589 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5590 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305591 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305592 __func__);
5593 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305594 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305595 }
5596 }
5597
Govind Singhb53420c2016-03-09 14:32:57 +05305598 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305599}
5600
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05305601#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305602/**
5603 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
5604 * @wmi_handle: wmi handle
5605 * @roam_req: Roam scan offload params
5606 * @buf_ptr: command buffer to send
5607 * @fils_tlv_len: fils tlv length
5608 *
5609 * Return: Updated buffer pointer
5610 */
5611static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5612 struct roam_offload_scan_params *roam_req,
5613 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5614{
5615 wmi_roam_fils_offload_tlv_param *fils_tlv;
5616 wmi_erp_info *erp_info;
5617 struct roam_fils_params *roam_fils_params;
5618
5619 if (!roam_req->add_fils_tlv)
5620 return buf_ptr;
5621
5622 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5623 sizeof(*fils_tlv));
5624 buf_ptr += WMI_TLV_HDR_SIZE;
5625
5626 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
5627 WMITLV_SET_HDR(&fils_tlv->tlv_header,
5628 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
5629 WMITLV_GET_STRUCT_TLVLEN
5630 (wmi_roam_fils_offload_tlv_param));
5631
5632 roam_fils_params = &roam_req->roam_fils_params;
5633 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
5634
5635 erp_info->username_length = roam_fils_params->username_length;
5636 qdf_mem_copy(erp_info->username, roam_fils_params->username,
5637 erp_info->username_length);
5638
5639 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
5640
5641 erp_info->rRk_length = roam_fils_params->rrk_length;
5642 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
5643 erp_info->rRk_length);
5644
5645 erp_info->rIk_length = roam_fils_params->rik_length;
5646 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
5647 erp_info->rIk_length);
5648
5649 erp_info->realm_len = roam_fils_params->realm_len;
5650 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
5651 erp_info->realm_len);
5652
5653 buf_ptr += sizeof(*fils_tlv);
5654 return buf_ptr;
5655}
5656#else
5657static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5658 struct roam_offload_scan_params *roam_req,
5659 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5660{
5661 return buf_ptr;
5662}
5663#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305664/**
5665 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5666 * @wmi_handle: wmi handle
5667 * @scan_cmd_fp: start scan command ptr
5668 * @roam_req: roam request param
5669 *
5670 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5671 * of WMI_ROAM_SCAN_MODE.
5672 *
5673 * Return: QDF status
5674 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305675static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305676 wmi_start_scan_cmd_fixed_param *
5677 scan_cmd_fp,
5678 struct roam_offload_scan_params *roam_req)
5679{
5680 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305681 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305682 int len;
5683 uint8_t *buf_ptr;
5684 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305685
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305686#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5687 int auth_mode = roam_req->auth_mode;
5688 wmi_roam_offload_tlv_param *roam_offload_params;
5689 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5690 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5691 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305692 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305693 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305694#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5695 /* Need to create a buf with roam_scan command at
5696 * front and piggyback with scan command */
5697 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5698#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5699 (2 * WMI_TLV_HDR_SIZE) +
5700#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5701 sizeof(wmi_start_scan_cmd_fixed_param);
5702#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07005703 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305704 if (roam_req->is_roam_req_valid &&
5705 roam_req->roam_offload_enabled) {
5706 len += sizeof(wmi_roam_offload_tlv_param);
5707 len += WMI_TLV_HDR_SIZE;
5708 if ((auth_mode != WMI_AUTH_NONE) &&
5709 ((auth_mode != WMI_AUTH_OPEN) ||
5710 (auth_mode == WMI_AUTH_OPEN &&
5711 roam_req->mdid.mdie_present) ||
5712 roam_req->is_ese_assoc)) {
5713 len += WMI_TLV_HDR_SIZE;
5714 if (roam_req->is_ese_assoc)
5715 len +=
5716 sizeof(wmi_roam_ese_offload_tlv_param);
5717 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5718 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5719 (auth_mode == WMI_AUTH_OPEN &&
5720 roam_req->mdid.mdie_present))
5721 len +=
5722 sizeof(wmi_roam_11r_offload_tlv_param);
5723 else
5724 len +=
5725 sizeof(wmi_roam_11i_offload_tlv_param);
5726 } else {
5727 len += WMI_TLV_HDR_SIZE;
5728 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305729
5730 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5731 + roundup(roam_req->assoc_ie_length,
5732 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305733
5734 if (roam_req->add_fils_tlv) {
5735 fils_tlv_len = sizeof(
5736 wmi_roam_fils_offload_tlv_param);
5737 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
5738 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305739 } else {
5740 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305741 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305742 __func__, roam_req->roam_offload_enabled);
5743 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305744 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305745 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305746 }
5747 if (roam_req->is_roam_req_valid &&
5748 roam_req->roam_offload_enabled) {
5749 roam_req->mode = roam_req->mode |
5750 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5751 }
5752#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5753
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305754 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5755 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5756 len = sizeof(wmi_roam_scan_mode_fixed_param);
5757
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305758 buf = wmi_buf_alloc(wmi_handle, len);
5759 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305760 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305761 return QDF_STATUS_E_NOMEM;
5762 }
5763
5764 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5765 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5766 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5767 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5768 WMITLV_GET_STRUCT_TLVLEN
5769 (wmi_roam_scan_mode_fixed_param));
5770
5771 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5772 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305773 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5774 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5775 roam_scan_mode_fp->flags |=
5776 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305777 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305778 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305779
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305780 /* Fill in scan parameters suitable for roaming scan */
5781 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305782
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305783 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5784 sizeof(wmi_start_scan_cmd_fixed_param));
5785 /* Ensure there is no additional IEs */
5786 scan_cmd_fp->ie_len = 0;
5787 WMITLV_SET_HDR(buf_ptr,
5788 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5789 WMITLV_GET_STRUCT_TLVLEN
5790 (wmi_start_scan_cmd_fixed_param));
5791#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5792 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5793 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5794 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5795 sizeof(wmi_roam_offload_tlv_param));
5796 buf_ptr += WMI_TLV_HDR_SIZE;
5797 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5798 WMITLV_SET_HDR(buf_ptr,
5799 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5800 WMITLV_GET_STRUCT_TLVLEN
5801 (wmi_roam_offload_tlv_param));
5802 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5803 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5804 roam_offload_params->select_5g_margin =
5805 roam_req->select_5ghz_margin;
5806 roam_offload_params->reassoc_failure_timeout =
5807 roam_req->reassoc_failure_timeout;
5808
5809 /* Fill the capabilities */
5810 roam_offload_params->capability =
5811 roam_req->roam_offload_params.capability;
5812 roam_offload_params->ht_caps_info =
5813 roam_req->roam_offload_params.ht_caps_info;
5814 roam_offload_params->ampdu_param =
5815 roam_req->roam_offload_params.ampdu_param;
5816 roam_offload_params->ht_ext_cap =
5817 roam_req->roam_offload_params.ht_ext_cap;
5818 roam_offload_params->ht_txbf =
5819 roam_req->roam_offload_params.ht_txbf;
5820 roam_offload_params->asel_cap =
5821 roam_req->roam_offload_params.asel_cap;
5822 roam_offload_params->qos_caps =
5823 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005824 roam_offload_params->qos_enabled =
5825 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305826 roam_offload_params->wmm_caps =
5827 roam_req->roam_offload_params.wmm_caps;
5828 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5829 (uint8_t *)roam_req->roam_offload_params.mcsset,
5830 ROAM_OFFLOAD_NUM_MCS_SET);
5831
5832 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5833 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5834 * they are filled in the same order.Depending on the
5835 * authentication type, the other mode TLV's are nullified
5836 * and only headers are filled.*/
5837 if ((auth_mode != WMI_AUTH_NONE) &&
5838 ((auth_mode != WMI_AUTH_OPEN) ||
5839 (auth_mode == WMI_AUTH_OPEN
5840 && roam_req->mdid.mdie_present) ||
5841 roam_req->is_ese_assoc)) {
5842 if (roam_req->is_ese_assoc) {
5843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5844 WMITLV_GET_STRUCT_TLVLEN(0));
5845 buf_ptr += WMI_TLV_HDR_SIZE;
5846 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5847 WMITLV_GET_STRUCT_TLVLEN(0));
5848 buf_ptr += WMI_TLV_HDR_SIZE;
5849 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5850 sizeof(wmi_roam_ese_offload_tlv_param));
5851 buf_ptr += WMI_TLV_HDR_SIZE;
5852 roam_offload_ese =
5853 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5854 qdf_mem_copy(roam_offload_ese->krk,
5855 roam_req->krk,
5856 sizeof(roam_req->krk));
5857 qdf_mem_copy(roam_offload_ese->btk,
5858 roam_req->btk,
5859 sizeof(roam_req->btk));
5860 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5861 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5862 WMITLV_GET_STRUCT_TLVLEN
5863 (wmi_roam_ese_offload_tlv_param));
5864 buf_ptr +=
5865 sizeof(wmi_roam_ese_offload_tlv_param);
5866 } else if (auth_mode == WMI_AUTH_FT_RSNA
5867 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5868 || (auth_mode == WMI_AUTH_OPEN
5869 && roam_req->mdid.mdie_present)) {
5870 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5871 0);
5872 buf_ptr += WMI_TLV_HDR_SIZE;
5873 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5874 sizeof(wmi_roam_11r_offload_tlv_param));
5875 buf_ptr += WMI_TLV_HDR_SIZE;
5876 roam_offload_11r =
5877 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5878 roam_offload_11r->r0kh_id_len =
5879 roam_req->rokh_id_length;
5880 qdf_mem_copy(roam_offload_11r->r0kh_id,
5881 roam_req->rokh_id,
5882 roam_offload_11r->r0kh_id_len);
5883 qdf_mem_copy(roam_offload_11r->psk_msk,
5884 roam_req->psk_pmk,
5885 sizeof(roam_req->psk_pmk));
5886 roam_offload_11r->psk_msk_len =
5887 roam_req->pmk_len;
5888 roam_offload_11r->mdie_present =
5889 roam_req->mdid.mdie_present;
5890 roam_offload_11r->mdid =
5891 roam_req->mdid.mobility_domain;
5892 if (auth_mode == WMI_AUTH_OPEN) {
5893 /* If FT-Open ensure pmk length
5894 and r0khid len are zero */
5895 roam_offload_11r->r0kh_id_len = 0;
5896 roam_offload_11r->psk_msk_len = 0;
5897 }
5898 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5899 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5900 WMITLV_GET_STRUCT_TLVLEN
5901 (wmi_roam_11r_offload_tlv_param));
5902 buf_ptr +=
5903 sizeof(wmi_roam_11r_offload_tlv_param);
5904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5905 WMITLV_GET_STRUCT_TLVLEN(0));
5906 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07005907 WMI_LOGD("psk_msk_len = %d",
5908 roam_offload_11r->psk_msk_len);
5909 if (roam_offload_11r->psk_msk_len)
5910 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
5911 QDF_TRACE_LEVEL_DEBUG,
5912 roam_offload_11r->psk_msk,
5913 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305914 } else {
5915 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5916 sizeof(wmi_roam_11i_offload_tlv_param));
5917 buf_ptr += WMI_TLV_HDR_SIZE;
5918 roam_offload_11i =
5919 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005920
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005921 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005922 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305923 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5924 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005925 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305926 } else {
5927 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5928 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005929 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005930 }
5931 if (roam_req->roam_key_mgmt_offload_enabled &&
5932 roam_req->fw_pmksa_cache) {
5933 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5934 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005935 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005936 } else {
5937 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5938 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005939 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305940 }
5941
5942 qdf_mem_copy(roam_offload_11i->pmk,
5943 roam_req->psk_pmk,
5944 sizeof(roam_req->psk_pmk));
5945 roam_offload_11i->pmk_len = roam_req->pmk_len;
5946 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5947 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5948 WMITLV_GET_STRUCT_TLVLEN
5949 (wmi_roam_11i_offload_tlv_param));
5950 buf_ptr +=
5951 sizeof(wmi_roam_11i_offload_tlv_param);
5952 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5953 0);
5954 buf_ptr += WMI_TLV_HDR_SIZE;
5955 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5956 0);
5957 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07005958 WMI_LOGD("pmk_len = %d",
5959 roam_offload_11i->pmk_len);
5960 if (roam_offload_11i->pmk_len)
5961 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
5962 QDF_TRACE_LEVEL_DEBUG,
5963 roam_offload_11i->pmk,
5964 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305965 }
5966 } else {
5967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5968 WMITLV_GET_STRUCT_TLVLEN(0));
5969 buf_ptr += WMI_TLV_HDR_SIZE;
5970 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5971 WMITLV_GET_STRUCT_TLVLEN(0));
5972 buf_ptr += WMI_TLV_HDR_SIZE;
5973 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5974 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305975 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305976 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305977
5978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5979 sizeof(*assoc_ies));
5980 buf_ptr += WMI_TLV_HDR_SIZE;
5981
5982 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5983 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5984 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5985 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5986 assoc_ies->buf_len = roam_req->assoc_ie_length;
5987
5988 buf_ptr += sizeof(*assoc_ies);
5989
5990 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5991 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5992 buf_ptr += WMI_TLV_HDR_SIZE;
5993
5994 if (assoc_ies->buf_len != 0) {
5995 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5996 assoc_ies->buf_len);
5997 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305998 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
5999 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6000 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306001 } else {
6002 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6003 WMITLV_GET_STRUCT_TLVLEN(0));
6004 buf_ptr += WMI_TLV_HDR_SIZE;
6005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6006 WMITLV_GET_STRUCT_TLVLEN(0));
6007 buf_ptr += WMI_TLV_HDR_SIZE;
6008 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6009 WMITLV_GET_STRUCT_TLVLEN(0));
6010 buf_ptr += WMI_TLV_HDR_SIZE;
6011 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6012 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306013 buf_ptr += WMI_TLV_HDR_SIZE;
6014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6015 WMITLV_GET_STRUCT_TLVLEN(0));
6016 buf_ptr += WMI_TLV_HDR_SIZE;
6017 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6018 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306019 }
6020#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306021
6022send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306023 status = wmi_unified_cmd_send(wmi_handle, buf,
6024 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306025 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306026 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306027 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6028 status);
6029 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306030 }
6031
Govind Singh67922e82016-04-01 16:48:57 +05306032 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306033}
6034
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006035static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6036 struct wmi_mawc_roam_params *params)
6037{
6038 wmi_buf_t buf = NULL;
6039 QDF_STATUS status;
6040 int len;
6041 uint8_t *buf_ptr;
6042 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6043
6044 len = sizeof(*wmi_roam_mawc_params);
6045 buf = wmi_buf_alloc(wmi_handle, len);
6046 if (!buf) {
6047 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6048 return QDF_STATUS_E_NOMEM;
6049 }
6050
6051 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6052 wmi_roam_mawc_params =
6053 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6054 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6055 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6056 WMITLV_GET_STRUCT_TLVLEN
6057 (wmi_roam_configure_mawc_cmd_fixed_param));
6058 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6059 if (params->enable)
6060 wmi_roam_mawc_params->enable = 1;
6061 else
6062 wmi_roam_mawc_params->enable = 0;
6063 wmi_roam_mawc_params->traffic_load_threshold =
6064 params->traffic_load_threshold;
6065 wmi_roam_mawc_params->best_ap_rssi_threshold =
6066 params->best_ap_rssi_threshold;
6067 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6068 params->rssi_stationary_high_adjust;
6069 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6070 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006071 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6072 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6073 wmi_roam_mawc_params->traffic_load_threshold,
6074 wmi_roam_mawc_params->best_ap_rssi_threshold,
6075 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6076 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006077
6078 status = wmi_unified_cmd_send(wmi_handle, buf,
6079 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6080 if (QDF_IS_STATUS_ERROR(status)) {
6081 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6082 status);
6083 wmi_buf_free(buf);
6084 return status;
6085 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006086
6087 return QDF_STATUS_SUCCESS;
6088}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306089
6090/**
6091 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6092 * rssi threashold
6093 * @wmi_handle: wmi handle
6094 * @roam_req: Roaming request buffer
6095 *
6096 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6097 *
6098 * Return: QDF status
6099 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306100static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306101 struct roam_offload_scan_rssi_params *roam_req)
6102{
6103 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306104 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306105 int len;
6106 uint8_t *buf_ptr;
6107 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6108 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6109 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306110 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006111 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306112
6113 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6114 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6115 len += sizeof(wmi_roam_scan_extended_threshold_param);
6116 len += WMI_TLV_HDR_SIZE;
6117 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306118 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6119 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006120 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6121 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306122 buf = wmi_buf_alloc(wmi_handle, len);
6123 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306124 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306125 return QDF_STATUS_E_NOMEM;
6126 }
6127
6128 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6129 rssi_threshold_fp =
6130 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6131 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6132 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6133 WMITLV_GET_STRUCT_TLVLEN
6134 (wmi_roam_scan_rssi_threshold_fixed_param));
6135 /* fill in threshold values */
6136 rssi_threshold_fp->vdev_id = roam_req->session_id;
6137 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6138 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6139 rssi_threshold_fp->hirssi_scan_max_count =
6140 roam_req->hi_rssi_scan_max_count;
6141 rssi_threshold_fp->hirssi_scan_delta =
6142 roam_req->hi_rssi_scan_rssi_delta;
6143 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006144 rssi_threshold_fp->rssi_thresh_offset_5g =
6145 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306146
6147 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6148 WMITLV_SET_HDR(buf_ptr,
6149 WMITLV_TAG_ARRAY_STRUC,
6150 sizeof(wmi_roam_scan_extended_threshold_param));
6151 buf_ptr += WMI_TLV_HDR_SIZE;
6152 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6153
6154 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6155 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6156 ext_thresholds->boost_threshold_5g =
6157 roam_req->boost_threshold_5g;
6158
6159 ext_thresholds->boost_algorithm_5g =
6160 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6161 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6162 ext_thresholds->penalty_algorithm_5g =
6163 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6164 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6165 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6166 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6167 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6168
6169 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6170 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6171 WMITLV_GET_STRUCT_TLVLEN
6172 (wmi_roam_scan_extended_threshold_param));
6173 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6174 WMITLV_SET_HDR(buf_ptr,
6175 WMITLV_TAG_ARRAY_STRUC,
6176 sizeof(wmi_roam_earlystop_rssi_thres_param));
6177 buf_ptr += WMI_TLV_HDR_SIZE;
6178 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6179 early_stop_thresholds->roam_earlystop_thres_min =
6180 roam_req->roam_earlystop_thres_min;
6181 early_stop_thresholds->roam_earlystop_thres_max =
6182 roam_req->roam_earlystop_thres_max;
6183 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6184 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6185 WMITLV_GET_STRUCT_TLVLEN
6186 (wmi_roam_earlystop_rssi_thres_param));
6187
Gupta, Kapil7e652922016-04-12 15:02:00 +05306188 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6190 sizeof(wmi_roam_dense_thres_param));
6191 buf_ptr += WMI_TLV_HDR_SIZE;
6192 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6193 dense_thresholds->roam_dense_rssi_thres_offset =
6194 roam_req->dense_rssi_thresh_offset;
6195 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6196 dense_thresholds->roam_dense_traffic_thres =
6197 roam_req->traffic_threshold;
6198 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6199 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6200 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6201 WMITLV_GET_STRUCT_TLVLEN
6202 (wmi_roam_dense_thres_param));
6203
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006204 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6205 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6206 sizeof(wmi_roam_bg_scan_roaming_param));
6207 buf_ptr += WMI_TLV_HDR_SIZE;
6208 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6209 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6210 roam_req->bg_scan_bad_rssi_thresh;
6211 bg_scan_params->roam_bg_scan_client_bitmap =
6212 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306213 bg_scan_params->bad_rssi_thresh_offset_2g =
6214 roam_req->roam_bad_rssi_thresh_offset_2g;
6215 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006216 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6217 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6218 WMITLV_GET_STRUCT_TLVLEN
6219 (wmi_roam_bg_scan_roaming_param));
6220
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306221 status = wmi_unified_cmd_send(wmi_handle, buf,
6222 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306223 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306224 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306225 status);
6226 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306227 }
6228
Govind Singh67922e82016-04-01 16:48:57 +05306229 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306230}
6231
6232/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306233 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6234 * configuration params
6235 * @wma_handle: wma handler
6236 * @dwelltime_params: pointer to dwelltime_params
6237 *
6238 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6239 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006240static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306241QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6242 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6243{
6244 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6245 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6246 wmi_buf_t buf;
6247 uint8_t *buf_ptr;
6248 int32_t err;
6249 int len;
6250
6251 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6252 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6253 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6254 buf = wmi_buf_alloc(wmi_handle, len);
6255 if (!buf) {
6256 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6257 __func__);
6258 return QDF_STATUS_E_NOMEM;
6259 }
6260 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6261 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6262 WMITLV_SET_HDR(&dwell_param->tlv_header,
6263 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6264 WMITLV_GET_STRUCT_TLVLEN
6265 (wmi_scan_adaptive_dwell_config_fixed_param));
6266
6267 dwell_param->enable = dwelltime_params->is_enabled;
6268 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6269 WMITLV_SET_HDR(buf_ptr,
6270 WMITLV_TAG_ARRAY_STRUC,
6271 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6272 buf_ptr += WMI_TLV_HDR_SIZE;
6273
6274 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6275 WMITLV_SET_HDR(&cmd->tlv_header,
6276 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6277 WMITLV_GET_STRUCT_TLVLEN(
6278 wmi_scan_adaptive_dwell_parameters_tlv));
6279
6280 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6281 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6282 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6283 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6284 err = wmi_unified_cmd_send(wmi_handle, buf,
6285 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6286 if (err) {
6287 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6288 wmi_buf_free(buf);
6289 return QDF_STATUS_E_FAILURE;
6290 }
6291
6292 return QDF_STATUS_SUCCESS;
6293}
6294
Nitesh Shah52323d02017-05-22 15:49:00 +05306295/**
6296 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6297 * configuration params
6298 * @wmi_handle: wmi handler
6299 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6300 *
6301 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6302 */
6303static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6304 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6305{
6306 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6307 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6308 wmi_buf_t buf;
6309 uint8_t *buf_ptr;
6310 QDF_STATUS err;
6311 uint32_t i;
6312 int len;
6313
6314 len = sizeof(*dbs_scan_param);
6315 len += WMI_TLV_HDR_SIZE;
6316 len += dbs_scan_params->num_clients * sizeof(*cmd);
6317
6318 buf = wmi_buf_alloc(wmi_handle, len);
6319 if (!buf) {
6320 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6321 return QDF_STATUS_E_NOMEM;
6322 }
6323
6324 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6325 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6326 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6327 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6328 WMITLV_GET_STRUCT_TLVLEN
6329 (wmi_scan_dbs_duty_cycle_fixed_param));
6330
6331 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6332 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6333 buf_ptr += sizeof(*dbs_scan_param);
6334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6335 (sizeof(*cmd) * dbs_scan_params->num_clients));
6336 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6337
6338 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6339 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6340 WMITLV_SET_HDR(&cmd->tlv_header,
6341 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6342 WMITLV_GET_STRUCT_TLVLEN(
6343 wmi_scan_dbs_duty_cycle_tlv_param));
6344 cmd->module_id = dbs_scan_params->module_id[i];
6345 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6346 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6347 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6348 }
6349
6350 err = wmi_unified_cmd_send(wmi_handle, buf,
6351 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6352 if (QDF_IS_STATUS_ERROR(err)) {
6353 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6354 wmi_buf_free(buf);
6355 return QDF_STATUS_E_FAILURE;
6356 }
6357
6358 return QDF_STATUS_SUCCESS;
6359}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306360
6361/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306362 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6363 * @wmi_handle: wmi handle
6364 * @roam_req: Request which contains the filters
6365 *
6366 * There are filters such as whitelist, blacklist and preferred
6367 * list that need to be applied to the scan results to form the
6368 * probable candidates for roaming.
6369 *
6370 * Return: Return success upon succesfully passing the
6371 * parameters to the firmware, otherwise failure.
6372 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306373static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306374 struct roam_scan_filter_params *roam_req)
6375{
6376 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306377 QDF_STATUS status;
6378 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306379 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306380 uint8_t *buf_ptr;
6381 wmi_roam_filter_fixed_param *roam_filter;
6382 uint8_t *bssid_src_ptr = NULL;
6383 wmi_mac_addr *bssid_dst_ptr = NULL;
6384 wmi_ssid *ssid_ptr = NULL;
6385 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306386 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306387 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306388
6389 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306390
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306391 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306392 if (roam_req->num_bssid_black_list)
6393 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6394 len += WMI_TLV_HDR_SIZE;
6395 if (roam_req->num_ssid_white_list)
6396 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6397 len += 2 * WMI_TLV_HDR_SIZE;
6398 if (roam_req->num_bssid_preferred_list) {
6399 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6400 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6401 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306402 len += WMI_TLV_HDR_SIZE;
6403 if (roam_req->lca_disallow_config_present) {
6404 len += sizeof(*blist_param);
6405 blist_len = sizeof(*blist_param);
6406 }
6407
6408 len += WMI_TLV_HDR_SIZE;
6409 if (roam_req->num_rssi_rejection_ap)
6410 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306411
6412 buf = wmi_buf_alloc(wmi_handle, len);
6413 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306414 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306415 return QDF_STATUS_E_NOMEM;
6416 }
6417
6418 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6419 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6420 WMITLV_SET_HDR(&roam_filter->tlv_header,
6421 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6422 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6423 /* fill in fixed values */
6424 roam_filter->vdev_id = roam_req->session_id;
6425 roam_filter->flags = 0;
6426 roam_filter->op_bitmap = roam_req->op_bitmap;
6427 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6428 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6429 roam_filter->num_bssid_preferred_list =
6430 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306431 roam_filter->num_rssi_rejection_ap =
6432 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306433 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6434
6435 WMITLV_SET_HDR((buf_ptr),
6436 WMITLV_TAG_ARRAY_FIXED_STRUC,
6437 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6438 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6439 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6440 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6441 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6442 bssid_src_ptr += ATH_MAC_LEN;
6443 bssid_dst_ptr++;
6444 }
6445 buf_ptr += WMI_TLV_HDR_SIZE +
6446 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6447 WMITLV_SET_HDR((buf_ptr),
6448 WMITLV_TAG_ARRAY_FIXED_STRUC,
6449 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6450 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6451 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6452 qdf_mem_copy(&ssid_ptr->ssid,
6453 &roam_req->ssid_allowed_list[i].mac_ssid,
6454 roam_req->ssid_allowed_list[i].length);
6455 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6456 ssid_ptr++;
6457 }
6458 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6459 sizeof(wmi_ssid));
6460 WMITLV_SET_HDR((buf_ptr),
6461 WMITLV_TAG_ARRAY_FIXED_STRUC,
6462 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6463 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6464 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6465 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6466 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6467 (wmi_mac_addr *)bssid_dst_ptr);
6468 bssid_src_ptr += ATH_MAC_LEN;
6469 bssid_dst_ptr++;
6470 }
6471 buf_ptr += WMI_TLV_HDR_SIZE +
6472 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6473 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6474 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6475 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6476 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6477 *bssid_preferred_factor_ptr =
6478 roam_req->bssid_favored_factor[i];
6479 bssid_preferred_factor_ptr++;
6480 }
6481 buf_ptr += WMI_TLV_HDR_SIZE +
6482 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6483
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306484 WMITLV_SET_HDR(buf_ptr,
6485 WMITLV_TAG_ARRAY_STRUC, blist_len);
6486 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306487 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306488 blist_param =
6489 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6490 WMITLV_SET_HDR(&blist_param->tlv_header,
6491 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6492 WMITLV_GET_STRUCT_TLVLEN(
6493 wmi_roam_lca_disallow_config_tlv_param));
6494
6495 blist_param->disallow_duration = roam_req->disallow_duration;
6496 blist_param->rssi_channel_penalization =
6497 roam_req->rssi_channel_penalization;
6498 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306499 blist_param->disallow_lca_enable_source_bitmap =
6500 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6501 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306502 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6503 }
6504
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306505 WMITLV_SET_HDR(buf_ptr,
6506 WMITLV_TAG_ARRAY_STRUC,
6507 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6508 buf_ptr += WMI_TLV_HDR_SIZE;
6509 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6510 rssi_rej =
6511 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6512 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6513 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6514 WMITLV_GET_STRUCT_TLVLEN(
6515 wmi_roam_rssi_rejection_oce_config_param));
6516 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6517 roam_req->rssi_rejection_ap[i].bssid.bytes,
6518 &rssi_rej->bssid);
6519 rssi_rej->remaining_disallow_duration =
6520 roam_req->rssi_rejection_ap[i].remaining_duration;
6521 rssi_rej->requested_rssi =
6522 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6523 buf_ptr +=
6524 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6525 }
6526
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306527 status = wmi_unified_cmd_send(wmi_handle, buf,
6528 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306529 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306530 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306531 status);
6532 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306533 }
Govind Singh67922e82016-04-01 16:48:57 +05306534
6535 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306536}
6537
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306538#if defined(WLAN_FEATURE_FILS_SK)
6539static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
6540 struct hlp_params *params)
6541{
6542 uint32_t len;
6543 uint8_t *buf_ptr;
6544 wmi_buf_t buf = NULL;
6545 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
6546
6547 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
6548 len += WMI_TLV_HDR_SIZE;
6549 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
6550
6551 buf = wmi_buf_alloc(wmi_handle, len);
6552 if (!buf) {
6553 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6554 return QDF_STATUS_E_NOMEM;
6555 }
6556
6557 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6558 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
6559 WMITLV_SET_HDR(&hlp_params->tlv_header,
6560 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
6561 WMITLV_GET_STRUCT_TLVLEN(
6562 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
6563
6564 hlp_params->vdev_id = params->vdev_id;
6565 hlp_params->size = params->hlp_ie_len;
6566 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
6567
6568 buf_ptr += sizeof(*hlp_params);
6569
6570 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6571 round_up(params->hlp_ie_len,
6572 sizeof(uint32_t)));
6573 buf_ptr += WMI_TLV_HDR_SIZE;
6574 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
6575
6576 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
6577 hlp_params->vdev_id, hlp_params->size);
6578 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6579 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
6580 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
6581 wmi_buf_free(buf);
6582 return QDF_STATUS_E_FAILURE;
6583 }
6584
6585 return QDF_STATUS_SUCCESS;
6586}
6587#endif
6588
Govind Singh4eacd2b2016-03-07 14:24:22 +05306589/** send_set_epno_network_list_cmd_tlv() - set epno network list
6590 * @wmi_handle: wmi handle
6591 * @req: epno config params request structure
6592 *
6593 * This function reads the incoming epno config request structure
6594 * and constructs the WMI message to the firmware.
6595 *
6596 * Returns: 0 on success, error number otherwise
6597 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306598static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306599 struct wifi_enhanched_pno_params *req)
6600{
6601 wmi_nlo_config_cmd_fixed_param *cmd;
6602 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306603 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306604 u_int8_t i, *buf_ptr;
6605 wmi_buf_t buf;
6606 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306607 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306608
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306609 /* Fixed Params */
6610 len = sizeof(*cmd);
6611 if (req->num_networks) {
6612 /* TLV place holder for array of structures
6613 * then each nlo_configured_parameters(nlo_list) TLV.
6614 */
6615 len += WMI_TLV_HDR_SIZE;
6616 len += (sizeof(nlo_configured_parameters)
6617 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6618 /* TLV for array of uint32 channel_list */
6619 len += WMI_TLV_HDR_SIZE;
6620 /* TLV for nlo_channel_prediction_cfg */
6621 len += WMI_TLV_HDR_SIZE;
6622 /* TLV for candidate score params */
6623 len += sizeof(enlo_candidate_score_params);
6624 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306625
6626 buf = wmi_buf_alloc(wmi_handle, len);
6627 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306628 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6629 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306630 }
6631
6632 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6633
6634 buf_ptr = (u_int8_t *) cmd;
6635 WMITLV_SET_HDR(&cmd->tlv_header,
6636 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6637 WMITLV_GET_STRUCT_TLVLEN(
6638 wmi_nlo_config_cmd_fixed_param));
6639 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306640
6641 /* set flag to reset if num of networks are 0 */
6642 cmd->flags = (req->num_networks == 0 ?
6643 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306644
6645 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6646
Govind Singhb53420c2016-03-09 14:32:57 +05306647 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306648 WMI_LOGD("SSID count: %d flags: %d",
6649 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306650
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306651 /* Fill nlo_config only when num_networks are non zero */
6652 if (cmd->no_of_ssids) {
6653 /* Fill networks */
6654 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6655 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6656 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306657
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306658 nlo_list = (nlo_configured_parameters *) buf_ptr;
6659 for (i = 0; i < cmd->no_of_ssids; i++) {
6660 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6661 WMITLV_TAG_ARRAY_BYTE,
6662 WMITLV_GET_STRUCT_TLVLEN(
6663 nlo_configured_parameters));
6664 /* Copy ssid and it's length */
6665 nlo_list[i].ssid.valid = true;
6666 nlo_list[i].ssid.ssid.ssid_len =
6667 req->networks[i].ssid.length;
6668 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6669 req->networks[i].ssid.mac_ssid,
6670 nlo_list[i].ssid.ssid.ssid_len);
6671 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6672 nlo_list[i].ssid.ssid.ssid_len,
6673 (char *) nlo_list[i].ssid.ssid.ssid,
6674 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306675
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306676 /* Copy pno flags */
6677 nlo_list[i].bcast_nw_type.valid = true;
6678 nlo_list[i].bcast_nw_type.bcast_nw_type =
6679 req->networks[i].flags;
6680 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306681 nlo_list[i].bcast_nw_type.bcast_nw_type);
6682
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306683 /* Copy auth bit field */
6684 nlo_list[i].auth_type.valid = true;
6685 nlo_list[i].auth_type.auth_type =
6686 req->networks[i].auth_bit_field;
6687 WMI_LOGD("Auth bit field (%u)",
6688 nlo_list[i].auth_type.auth_type);
6689 }
6690
6691 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6692 /* Fill the channel list */
6693 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6694 buf_ptr += WMI_TLV_HDR_SIZE;
6695
6696 /* Fill prediction_param */
6697 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6698 buf_ptr += WMI_TLV_HDR_SIZE;
6699
6700 /* Fill epno candidate score params */
6701 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6702 WMITLV_SET_HDR(buf_ptr,
6703 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6704 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6705 cand_score_params->min5GHz_rssi =
6706 req->min_5ghz_rssi;
6707 cand_score_params->min24GHz_rssi =
6708 req->min_24ghz_rssi;
6709 cand_score_params->initial_score_max =
6710 req->initial_score_max;
6711 cand_score_params->current_connection_bonus =
6712 req->current_connection_bonus;
6713 cand_score_params->same_network_bonus =
6714 req->same_network_bonus;
6715 cand_score_params->secure_bonus =
6716 req->secure_bonus;
6717 cand_score_params->band5GHz_bonus =
6718 req->band_5ghz_bonus;
6719 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306720 }
6721
Govind Singh4eacd2b2016-03-07 14:24:22 +05306722 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306723 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306724 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306725 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306727 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306728 }
6729
Govind Singhb53420c2016-03-09 14:32:57 +05306730 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306731 req->session_id);
6732
Govind Singh67922e82016-04-01 16:48:57 +05306733 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306734}
6735
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306736
Govind Singh4eacd2b2016-03-07 14:24:22 +05306737/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6738 * @wmi_handle: wmi handle
6739 * @ipa_offload: ipa offload control parameter
6740 *
6741 * Returns: 0 on success, error number otherwise
6742 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306743static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306744 struct ipa_offload_control_params *ipa_offload)
6745{
6746 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6747 wmi_buf_t wmi_buf;
6748 uint32_t len;
6749 u_int8_t *buf_ptr;
6750
6751 len = sizeof(*cmd);
6752 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6753 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306754 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6755 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306756 }
6757
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08006758 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306759 ipa_offload->offload_type, ipa_offload->enable);
6760
6761 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6762
6763 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6764 WMITLV_SET_HDR(&cmd->tlv_header,
6765 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6766 WMITLV_GET_STRUCT_TLVLEN(
6767 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6768
6769 cmd->offload_type = ipa_offload->offload_type;
6770 cmd->vdev_id = ipa_offload->vdev_id;
6771 cmd->enable = ipa_offload->enable;
6772
6773 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6774 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306775 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306776 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306777 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306778 }
6779
Govind Singhb53420c2016-03-09 14:32:57 +05306780 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306781}
6782
6783/**
6784 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6785 * @wmi_handle: wmi handle
6786 * @pgetcapab: get capabilities params
6787 *
6788 * This function send request to fw to get extscan capabilities.
6789 *
6790 * Return: CDF status
6791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306792static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306793 struct extscan_capabilities_params *pgetcapab)
6794{
6795 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6796 wmi_buf_t wmi_buf;
6797 uint32_t len;
6798 uint8_t *buf_ptr;
6799
6800 len = sizeof(*cmd);
6801 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6802 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306803 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6804 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306805 }
6806 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6807
6808 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6809 WMITLV_SET_HDR(&cmd->tlv_header,
6810 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6811 WMITLV_GET_STRUCT_TLVLEN
6812 (wmi_extscan_get_capabilities_cmd_fixed_param));
6813
6814 cmd->request_id = pgetcapab->request_id;
6815
6816 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6817 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306818 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306819 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306820 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306821 }
Govind Singhb53420c2016-03-09 14:32:57 +05306822 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306823}
6824
6825/**
6826 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6827 * @wmi_handle: wmi handle
6828 * @pcached_results: cached results parameters
6829 *
6830 * This function send request to fw to get cached results.
6831 *
6832 * Return: CDF status
6833 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306834static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306835 struct extscan_cached_result_params *pcached_results)
6836{
6837 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6838 wmi_buf_t wmi_buf;
6839 uint32_t len;
6840 uint8_t *buf_ptr;
6841
6842 len = sizeof(*cmd);
6843 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6844 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306845 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6846 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306847 }
6848 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6849
6850 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6851 WMITLV_SET_HDR(&cmd->tlv_header,
6852 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6853 WMITLV_GET_STRUCT_TLVLEN
6854 (wmi_extscan_get_cached_results_cmd_fixed_param));
6855
6856 cmd->request_id = pcached_results->request_id;
6857 cmd->vdev_id = pcached_results->session_id;
6858 cmd->control_flags = pcached_results->flush;
6859
6860 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6861 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306862 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306863 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306864 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306865 }
Govind Singhb53420c2016-03-09 14:32:57 +05306866 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306867}
6868
6869/**
6870 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6871 * @wmi_handle: wmi handle
6872 * @reset_req: Reset change request params
6873 *
6874 * This function sends stop change monitor request to fw.
6875 *
6876 * Return: CDF status
6877 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306878static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306879 struct extscan_capabilities_reset_params *reset_req)
6880{
6881 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6882 wmi_buf_t wmi_buf;
6883 uint32_t len;
6884 uint8_t *buf_ptr;
6885 int change_list = 0;
6886
6887 len = sizeof(*cmd);
6888
6889 /* reset significant change tlv is set to 0 */
6890 len += WMI_TLV_HDR_SIZE;
6891 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6892 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6893 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306894 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6895 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306896 }
6897 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6898
6899 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6900 buf_ptr;
6901 WMITLV_SET_HDR(&cmd->tlv_header,
6902 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6903 WMITLV_GET_STRUCT_TLVLEN
6904 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6905
6906 cmd->request_id = reset_req->request_id;
6907 cmd->vdev_id = reset_req->session_id;
6908 cmd->mode = 0;
6909
6910 buf_ptr += sizeof(*cmd);
6911 WMITLV_SET_HDR(buf_ptr,
6912 WMITLV_TAG_ARRAY_STRUC,
6913 change_list *
6914 sizeof(wmi_extscan_wlan_change_bssid_param));
6915 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6916 sizeof
6917 (wmi_extscan_wlan_change_bssid_param));
6918
6919 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6920 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306921 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306922 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306923 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306924 }
Govind Singhb53420c2016-03-09 14:32:57 +05306925 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306926}
6927
6928/**
6929 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6930 * @wmi_handle: wmi handle
6931 * @psigchange: change monitor request params
6932 * @buf: wmi buffer
6933 * @buf_len: buffer length
6934 *
6935 * This function fills elements of change monitor request buffer.
6936 *
6937 * Return: CDF status
6938 */
Govind Singhb53420c2016-03-09 14:32:57 +05306939static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306940 struct extscan_set_sig_changereq_params
6941 *psigchange, wmi_buf_t *buf, int *buf_len)
6942{
6943 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6944 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6945 uint8_t *buf_ptr;
6946 int j;
6947 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006948 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306949 struct ap_threshold_params *src_ap = psigchange->ap;
6950
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006951 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306952 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6953 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306954 }
6955 len += WMI_TLV_HDR_SIZE;
6956 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6957
6958 *buf = wmi_buf_alloc(wmi_handle, len);
6959 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306960 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306962 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306963 }
6964 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6965 cmd =
6966 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6967 buf_ptr;
6968 WMITLV_SET_HDR(&cmd->tlv_header,
6969 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6970 WMITLV_GET_STRUCT_TLVLEN
6971 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6972
6973 cmd->request_id = psigchange->request_id;
6974 cmd->vdev_id = psigchange->session_id;
6975 cmd->total_entries = numap;
6976 cmd->mode = 1;
6977 cmd->num_entries_in_page = numap;
6978 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6979 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6980 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6981 cmd->max_out_of_range_count = psigchange->min_breaching;
6982
6983 buf_ptr += sizeof(*cmd);
6984 WMITLV_SET_HDR(buf_ptr,
6985 WMITLV_TAG_ARRAY_STRUC,
6986 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6987 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6988 (buf_ptr + WMI_TLV_HDR_SIZE);
6989
6990 for (j = 0; j < numap; j++) {
6991 WMITLV_SET_HDR(dest_chglist,
6992 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6993 WMITLV_GET_STRUCT_TLVLEN
6994 (wmi_extscan_wlan_change_bssid_param));
6995
6996 dest_chglist->lower_rssi_limit = src_ap->low;
6997 dest_chglist->upper_rssi_limit = src_ap->high;
6998 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6999 &dest_chglist->bssid);
7000
Govind Singhb53420c2016-03-09 14:32:57 +05307001 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 dest_chglist->lower_rssi_limit);
7003 dest_chglist++;
7004 src_ap++;
7005 }
7006 buf_ptr += WMI_TLV_HDR_SIZE +
7007 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7008 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307009 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307010}
7011
7012/**
7013 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7014 * @wmi_handle: wmi handle
7015 * @psigchange: change monitor request params
7016 *
7017 * This function sends start change monitor request to fw.
7018 *
7019 * Return: CDF status
7020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307021static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307022 struct extscan_set_sig_changereq_params *
7023 psigchange)
7024{
Govind Singhb53420c2016-03-09 14:32:57 +05307025 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307026 wmi_buf_t buf;
7027 int len;
7028
7029
Govind Singhb53420c2016-03-09 14:32:57 +05307030 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307031 psigchange, &buf,
7032 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307033 if (qdf_status != QDF_STATUS_SUCCESS) {
7034 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307035 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307036 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307037 }
7038 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307039 WMI_LOGE("%s: Failed to get buffer", __func__);
7040 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307041 }
7042 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7043 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307044 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307045 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307046 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307047 }
Govind Singhb53420c2016-03-09 14:32:57 +05307048 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307049}
7050
7051/**
7052 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7053 * @wmi_handle: wmi handle
7054 * @photlist_reset: hotlist reset params
7055 *
7056 * This function configures hotlist monitor to stop in fw.
7057 *
7058 * Return: CDF status
7059 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307060static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307061 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7062{
7063 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7064 wmi_buf_t wmi_buf;
7065 uint32_t len;
7066 uint8_t *buf_ptr;
7067 int hotlist_entries = 0;
7068
7069 len = sizeof(*cmd);
7070
7071 /* reset bssid hotlist with tlv set to 0 */
7072 len += WMI_TLV_HDR_SIZE;
7073 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7074
7075 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7076 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307077 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7078 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079 }
7080
7081 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7082 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7083 buf_ptr;
7084 WMITLV_SET_HDR(&cmd->tlv_header,
7085 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7086 WMITLV_GET_STRUCT_TLVLEN
7087 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7088
7089 cmd->request_id = photlist_reset->request_id;
7090 cmd->vdev_id = photlist_reset->session_id;
7091 cmd->mode = 0;
7092
7093 buf_ptr += sizeof(*cmd);
7094 WMITLV_SET_HDR(buf_ptr,
7095 WMITLV_TAG_ARRAY_STRUC,
7096 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7097 buf_ptr += WMI_TLV_HDR_SIZE +
7098 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7099
7100 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7101 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307102 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307103 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307104 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307105 }
Govind Singhb53420c2016-03-09 14:32:57 +05307106 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307107}
7108
7109/**
7110 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7111 * @wmi_handle: wmi handle
7112 * @pstopcmd: stop scan command request params
7113 *
7114 * This function sends stop extscan request to fw.
7115 *
7116 * Return: CDF Status.
7117 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307118static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119 struct extscan_stop_req_params *pstopcmd)
7120{
7121 wmi_extscan_stop_cmd_fixed_param *cmd;
7122 wmi_buf_t wmi_buf;
7123 uint32_t len;
7124 uint8_t *buf_ptr;
7125
7126 len = sizeof(*cmd);
7127 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7128 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307129 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7130 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307131 }
7132 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7133 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7134 WMITLV_SET_HDR(&cmd->tlv_header,
7135 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7136 WMITLV_GET_STRUCT_TLVLEN
7137 (wmi_extscan_stop_cmd_fixed_param));
7138
7139 cmd->request_id = pstopcmd->request_id;
7140 cmd->vdev_id = pstopcmd->session_id;
7141
7142 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7143 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307144 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307145 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307146 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307147 }
7148
Govind Singhb53420c2016-03-09 14:32:57 +05307149 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307150}
7151
7152/**
7153 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7154 * @wmi_handle: wmi handle
7155 * @pstart: scan command request params
7156 * @buf: event buffer
7157 * @buf_len: length of buffer
7158 *
7159 * This function fills individual elements of extscan request and
7160 * TLV for buckets, channel list.
7161 *
7162 * Return: CDF Status.
7163 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007164static
Govind Singhb53420c2016-03-09 14:32:57 +05307165QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307166 struct wifi_scan_cmd_req_params *pstart,
7167 wmi_buf_t *buf, int *buf_len)
7168{
7169 wmi_extscan_start_cmd_fixed_param *cmd;
7170 wmi_extscan_bucket *dest_blist;
7171 wmi_extscan_bucket_channel *dest_clist;
7172 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7173 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7174 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7175
7176 uint8_t *buf_ptr;
7177 int i, k, count = 0;
7178 int len = sizeof(*cmd);
7179 int nbuckets = pstart->numBuckets;
7180 int nchannels = 0;
7181
7182 /* These TLV's are are NULL by default */
7183 uint32_t ie_len_with_pad = 0;
7184 int num_ssid = 0;
7185 int num_bssid = 0;
7186 int ie_len = 0;
7187
7188 uint32_t base_period = pstart->basePeriod;
7189
7190 /* TLV placeholder for ssid_list (NULL) */
7191 len += WMI_TLV_HDR_SIZE;
7192 len += num_ssid * sizeof(wmi_ssid);
7193
7194 /* TLV placeholder for bssid_list (NULL) */
7195 len += WMI_TLV_HDR_SIZE;
7196 len += num_bssid * sizeof(wmi_mac_addr);
7197
7198 /* TLV placeholder for ie_data (NULL) */
7199 len += WMI_TLV_HDR_SIZE;
7200 len += ie_len * sizeof(uint32_t);
7201
7202 /* TLV placeholder for bucket */
7203 len += WMI_TLV_HDR_SIZE;
7204 len += nbuckets * sizeof(wmi_extscan_bucket);
7205
7206 /* TLV channel placeholder */
7207 len += WMI_TLV_HDR_SIZE;
7208 for (i = 0; i < nbuckets; i++) {
7209 nchannels += src_bucket->numChannels;
7210 src_bucket++;
7211 }
7212
Govind Singhb53420c2016-03-09 14:32:57 +05307213 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307214 __func__, nbuckets, nchannels);
7215 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7216 /* Allocate the memory */
7217 *buf = wmi_buf_alloc(wmi_handle, len);
7218 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307219 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307221 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307222 }
7223 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7224 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7225 WMITLV_SET_HDR(&cmd->tlv_header,
7226 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7227 WMITLV_GET_STRUCT_TLVLEN
7228 (wmi_extscan_start_cmd_fixed_param));
7229
7230 cmd->request_id = pstart->requestId;
7231 cmd->vdev_id = pstart->sessionId;
7232 cmd->base_period = pstart->basePeriod;
7233 cmd->num_buckets = nbuckets;
7234 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307235 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307236 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307237 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307238 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307239#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307240 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7241 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307242 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7243 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7244#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7246
7247 /* The max dwell time is retrieved from the first channel
7248 * of the first bucket and kept common for all channels.
7249 */
7250 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7251 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7252 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7253 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7254 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7255 cmd->max_table_usage = pstart->report_threshold_percent;
7256 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7257
7258 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307259 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307260 cmd->probe_delay = 0;
7261 cmd->probe_spacing_time = 0;
7262 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7264 WMI_SCAN_ADD_CCK_RATES |
7265 WMI_SCAN_ADD_OFDM_RATES |
7266 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7267 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307268 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7269 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307270 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307271 cmd->num_ssids = 0;
7272 cmd->num_bssid = 0;
7273 cmd->ie_len = 0;
7274 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7275 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7276
7277 buf_ptr += sizeof(*cmd);
7278 WMITLV_SET_HDR(buf_ptr,
7279 WMITLV_TAG_ARRAY_FIXED_STRUC,
7280 num_ssid * sizeof(wmi_ssid));
7281 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7282
7283 WMITLV_SET_HDR(buf_ptr,
7284 WMITLV_TAG_ARRAY_FIXED_STRUC,
7285 num_bssid * sizeof(wmi_mac_addr));
7286 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7287
7288 ie_len_with_pad = 0;
7289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7290 ie_len_with_pad);
7291 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7292
7293 WMITLV_SET_HDR(buf_ptr,
7294 WMITLV_TAG_ARRAY_STRUC,
7295 nbuckets * sizeof(wmi_extscan_bucket));
7296 dest_blist = (wmi_extscan_bucket *)
7297 (buf_ptr + WMI_TLV_HDR_SIZE);
7298 src_bucket = pstart->buckets;
7299
7300 /* Retrieve scanning information from each bucket and
7301 * channels and send it to the target
7302 */
7303 for (i = 0; i < nbuckets; i++) {
7304 WMITLV_SET_HDR(dest_blist,
7305 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7306 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7307
7308 dest_blist->bucket_id = src_bucket->bucket;
7309 dest_blist->base_period_multiplier =
7310 src_bucket->period / base_period;
7311 dest_blist->min_period = src_bucket->period;
7312 dest_blist->max_period = src_bucket->max_period;
7313 dest_blist->exp_backoff = src_bucket->exponent;
7314 dest_blist->exp_max_step_count = src_bucket->step_count;
7315 dest_blist->channel_band = src_bucket->band;
7316 dest_blist->num_channels = src_bucket->numChannels;
7317 dest_blist->notify_extscan_events = 0;
7318
7319 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7320 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007321 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7322 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307323
7324 if (src_bucket->reportEvents &
7325 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7326 dest_blist->forwarding_flags =
7327 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7328 dest_blist->notify_extscan_events |=
7329 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7330 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7331 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7332 } else {
7333 dest_blist->forwarding_flags =
7334 WMI_EXTSCAN_NO_FORWARDING;
7335 }
7336
7337 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7338 dest_blist->configuration_flags = 0;
7339 else
7340 dest_blist->configuration_flags =
7341 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7342
Govind Singhb53420c2016-03-09 14:32:57 +05307343 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307344 __func__, dest_blist->notify_extscan_events,
7345 dest_blist->configuration_flags,
7346 dest_blist->forwarding_flags);
7347
7348 dest_blist->min_dwell_time_active =
7349 src_bucket->min_dwell_time_active;
7350 dest_blist->max_dwell_time_active =
7351 src_bucket->max_dwell_time_active;
7352 dest_blist->min_dwell_time_passive =
7353 src_bucket->min_dwell_time_passive;
7354 dest_blist->max_dwell_time_passive =
7355 src_bucket->max_dwell_time_passive;
7356 src_channel = src_bucket->channels;
7357
7358 /* save the channel info to later populate
7359 * the channel TLV
7360 */
7361 for (k = 0; k < src_bucket->numChannels; k++) {
7362 save_channel[count++].channel = src_channel->channel;
7363 src_channel++;
7364 }
7365 dest_blist++;
7366 src_bucket++;
7367 }
7368 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7369 WMITLV_SET_HDR(buf_ptr,
7370 WMITLV_TAG_ARRAY_STRUC,
7371 nchannels * sizeof(wmi_extscan_bucket_channel));
7372 dest_clist = (wmi_extscan_bucket_channel *)
7373 (buf_ptr + WMI_TLV_HDR_SIZE);
7374
7375 /* Active or passive scan is based on the bucket dwell time
7376 * and channel specific active,passive scans are not
7377 * supported yet
7378 */
7379 for (i = 0; i < nchannels; i++) {
7380 WMITLV_SET_HDR(dest_clist,
7381 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7382 WMITLV_GET_STRUCT_TLVLEN
7383 (wmi_extscan_bucket_channel));
7384 dest_clist->channel = save_channel[i].channel;
7385 dest_clist++;
7386 }
7387 buf_ptr += WMI_TLV_HDR_SIZE +
7388 (nchannels * sizeof(wmi_extscan_bucket_channel));
7389 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307390 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307391}
7392
7393/**
7394 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7395 * @wmi_handle: wmi handle
7396 * @pstart: scan command request params
7397 *
7398 * This function sends start extscan request to fw.
7399 *
7400 * Return: CDF Status.
7401 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307402static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307403 struct wifi_scan_cmd_req_params *pstart)
7404{
Govind Singhb53420c2016-03-09 14:32:57 +05307405 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307406 wmi_buf_t buf;
7407 int len;
7408
7409 /* Fill individual elements of extscan request and
7410 * TLV for buckets, channel list.
7411 */
Govind Singhb53420c2016-03-09 14:32:57 +05307412 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307413 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307414 if (qdf_status != QDF_STATUS_SUCCESS) {
7415 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7416 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307417 }
7418 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307419 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307420 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307421 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307422 }
7423 if (wmi_unified_cmd_send(wmi_handle, buf,
7424 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307425 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307426 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307427 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307428 }
7429
Govind Singhb53420c2016-03-09 14:32:57 +05307430 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307431}
7432
7433/**
7434 * send_plm_stop_cmd_tlv() - plm stop request
7435 * @wmi_handle: wmi handle
7436 * @plm: plm request parameters
7437 *
7438 * This function request FW to stop PLM.
7439 *
7440 * Return: CDF status
7441 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307442static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307443 const struct plm_req_params *plm)
7444{
7445 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7446 int32_t len;
7447 wmi_buf_t buf;
7448 uint8_t *buf_ptr;
7449 int ret;
7450
7451 len = sizeof(*cmd);
7452 buf = wmi_buf_alloc(wmi_handle, len);
7453 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307454 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7455 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456 }
7457
7458 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7459
7460 buf_ptr = (uint8_t *) cmd;
7461
7462 WMITLV_SET_HDR(&cmd->tlv_header,
7463 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7464 WMITLV_GET_STRUCT_TLVLEN
7465 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7466
7467 cmd->vdev_id = plm->session_id;
7468
7469 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307470 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307471
7472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7473 WMI_VDEV_PLMREQ_STOP_CMDID);
7474 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307475 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307476 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307477 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307478 }
7479
Govind Singhb53420c2016-03-09 14:32:57 +05307480 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307481}
7482
7483/**
7484 * send_plm_start_cmd_tlv() - plm start request
7485 * @wmi_handle: wmi handle
7486 * @plm: plm request parameters
7487 *
7488 * This function request FW to start PLM.
7489 *
7490 * Return: CDF status
7491 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307492static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307493 const struct plm_req_params *plm,
7494 uint32_t *gchannel_list)
7495{
7496 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7497 uint32_t *channel_list;
7498 int32_t len;
7499 wmi_buf_t buf;
7500 uint8_t *buf_ptr;
7501 uint8_t count;
7502 int ret;
7503
7504 /* TLV place holder for channel_list */
7505 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7506 len += sizeof(uint32_t) * plm->plm_num_ch;
7507
7508 buf = wmi_buf_alloc(wmi_handle, len);
7509 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307510 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7511 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307512 }
7513 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7514
7515 buf_ptr = (uint8_t *) cmd;
7516
7517 WMITLV_SET_HDR(&cmd->tlv_header,
7518 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7519 WMITLV_GET_STRUCT_TLVLEN
7520 (wmi_vdev_plmreq_start_cmd_fixed_param));
7521
7522 cmd->vdev_id = plm->session_id;
7523
7524 cmd->meas_token = plm->meas_token;
7525 cmd->dialog_token = plm->diag_token;
7526 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307527 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307528 cmd->off_duration = plm->meas_duration;
7529 cmd->burst_cycle = plm->burst_len;
7530 cmd->tx_power = plm->desired_tx_pwr;
7531 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7532 cmd->num_chans = plm->plm_num_ch;
7533
7534 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7535
Govind Singhb53420c2016-03-09 14:32:57 +05307536 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7537 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7538 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7539 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7540 WMI_LOGD("off_duration: %d", cmd->off_duration);
7541 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7542 WMI_LOGD("tx_power: %d", cmd->tx_power);
7543 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307544
7545 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7546 (cmd->num_chans * sizeof(uint32_t)));
7547
7548 buf_ptr += WMI_TLV_HDR_SIZE;
7549 if (cmd->num_chans) {
7550 channel_list = (uint32_t *) buf_ptr;
7551 for (count = 0; count < cmd->num_chans; count++) {
7552 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307553 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307554 channel_list[count] =
7555 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307556 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307557 }
7558 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7559 }
7560
7561 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7562 WMI_VDEV_PLMREQ_START_CMDID);
7563 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307564 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307565 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307566 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307567 }
7568
Govind Singhb53420c2016-03-09 14:32:57 +05307569 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307570}
7571
7572/**
7573 * send_pno_stop_cmd_tlv() - PNO stop request
7574 * @wmi_handle: wmi handle
7575 * @vdev_id: vdev id
7576 *
7577 * This function request FW to stop ongoing PNO operation.
7578 *
7579 * Return: CDF status
7580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307581static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307582{
7583 wmi_nlo_config_cmd_fixed_param *cmd;
7584 int32_t len = sizeof(*cmd);
7585 wmi_buf_t buf;
7586 uint8_t *buf_ptr;
7587 int ret;
7588
7589 /*
7590 * TLV place holder for array of structures nlo_configured_parameters
7591 * TLV place holder for array of uint32_t channel_list
7592 * TLV place holder for chnl prediction cfg
7593 */
7594 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7595 buf = wmi_buf_alloc(wmi_handle, len);
7596 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307597 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7598 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307599 }
7600
7601 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7602 buf_ptr = (uint8_t *) cmd;
7603
7604 WMITLV_SET_HDR(&cmd->tlv_header,
7605 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7606 WMITLV_GET_STRUCT_TLVLEN
7607 (wmi_nlo_config_cmd_fixed_param));
7608
7609 cmd->vdev_id = vdev_id;
7610 cmd->flags = WMI_NLO_CONFIG_STOP;
7611 buf_ptr += sizeof(*cmd);
7612
7613 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7614 buf_ptr += WMI_TLV_HDR_SIZE;
7615
7616 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7617 buf_ptr += WMI_TLV_HDR_SIZE;
7618
7619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7620 buf_ptr += WMI_TLV_HDR_SIZE;
7621
7622
7623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7624 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7625 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307626 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307627 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307628 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307629 }
7630
Govind Singhb53420c2016-03-09 14:32:57 +05307631 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307632}
7633
7634/**
Govind Singhccb0c272016-04-01 16:30:08 +05307635 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7636 * @buf_ptr: Buffer passed by upper layers
7637 * @pno: Buffer to be sent to the firmware
7638 *
7639 * Copy the PNO Channel prediction configuration parameters
7640 * passed by the upper layers to a WMI format TLV and send it
7641 * down to the firmware.
7642 *
7643 * Return: None
7644 */
7645static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7646 struct pno_scan_req_params *pno)
7647{
7648 nlo_channel_prediction_cfg *channel_prediction_cfg =
7649 (nlo_channel_prediction_cfg *) buf_ptr;
7650 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7651 WMITLV_TAG_ARRAY_BYTE,
7652 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307653#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307654 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7655 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7656 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7657 channel_prediction_cfg->full_scan_period_ms =
7658 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307659#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307660 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7661 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7662 channel_prediction_cfg->enable,
7663 channel_prediction_cfg->top_k_num,
7664 channel_prediction_cfg->stationary_threshold,
7665 channel_prediction_cfg->full_scan_period_ms);
7666}
7667
7668/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007669 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7670 * @wmi_handle: wmi handle
7671 * @params: configuration parameters
7672 *
7673 * Return: QDF_STATUS
7674 */
7675static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7676 struct nlo_mawc_params *params)
7677{
7678 wmi_buf_t buf = NULL;
7679 QDF_STATUS status;
7680 int len;
7681 uint8_t *buf_ptr;
7682 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7683
7684 len = sizeof(*wmi_nlo_mawc_params);
7685 buf = wmi_buf_alloc(wmi_handle, len);
7686 if (!buf) {
7687 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7688 return QDF_STATUS_E_NOMEM;
7689 }
7690
7691 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7692 wmi_nlo_mawc_params =
7693 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7694 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7695 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7696 WMITLV_GET_STRUCT_TLVLEN
7697 (wmi_nlo_configure_mawc_cmd_fixed_param));
7698 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7699 if (params->enable)
7700 wmi_nlo_mawc_params->enable = 1;
7701 else
7702 wmi_nlo_mawc_params->enable = 0;
7703 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7704 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7705 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007706 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7707 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7708 wmi_nlo_mawc_params->exp_backoff_ratio,
7709 wmi_nlo_mawc_params->init_scan_interval,
7710 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007711
7712 status = wmi_unified_cmd_send(wmi_handle, buf,
7713 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7714 if (QDF_IS_STATUS_ERROR(status)) {
7715 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7716 status);
7717 wmi_buf_free(buf);
7718 return QDF_STATUS_E_FAILURE;
7719 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007720
7721 return QDF_STATUS_SUCCESS;
7722}
7723
7724/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307725 * send_pno_start_cmd_tlv() - PNO start request
7726 * @wmi_handle: wmi handle
7727 * @pno: PNO request
7728 *
7729 * This function request FW to start PNO request.
7730 * Request: CDF status
7731 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307732static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307733 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307734{
7735 wmi_nlo_config_cmd_fixed_param *cmd;
7736 nlo_configured_parameters *nlo_list;
7737 uint32_t *channel_list;
7738 int32_t len;
7739 wmi_buf_t buf;
7740 uint8_t *buf_ptr;
7741 uint8_t i;
7742 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307743 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307744 connected_nlo_rssi_params *nlo_relative_rssi;
7745 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307746
7747 /*
7748 * TLV place holder for array nlo_configured_parameters(nlo_list)
7749 * TLV place holder for array of uint32_t channel_list
7750 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307751 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307752 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307753 */
7754 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307755 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307756 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307757
Abhishek Singh5987b632017-03-03 22:09:07 +05307758 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307759 WMI_NLO_MAX_CHAN);
7760 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307761 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307762 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307763 len += sizeof(enlo_candidate_score_params);
7764 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307765 len += sizeof(connected_nlo_rssi_params);
7766 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307767
7768 buf = wmi_buf_alloc(wmi_handle, len);
7769 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307770 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7771 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307772 }
7773
7774 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7775
7776 buf_ptr = (uint8_t *) cmd;
7777 WMITLV_SET_HDR(&cmd->tlv_header,
7778 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7779 WMITLV_GET_STRUCT_TLVLEN
7780 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307781 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307782 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7783
Govind Singh87542482016-06-08 19:40:11 +05307784#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307785 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307786 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307787#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307788 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307789 cmd->active_dwell_time = pno->active_dwell_time;
7790 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307791
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307792 if (pno->do_passive_scan)
7793 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307794 /* Copy scan interval */
7795 cmd->fast_scan_period = pno->fast_scan_period;
7796 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007797 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307798 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007799 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307800 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307801 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307802 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307803
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307804 /* mac randomization attributes */
7805 if (pno->scan_random.randomize) {
7806 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7807 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7808 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7809 pno->scan_random.mac_mask,
7810 &cmd->mac_addr,
7811 &cmd->mac_mask);
7812 }
7813
Govind Singh4eacd2b2016-03-07 14:24:22 +05307814 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7815
Abhishek Singh5987b632017-03-03 22:09:07 +05307816 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307817 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307818 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7819 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7820 buf_ptr += WMI_TLV_HDR_SIZE;
7821
7822 nlo_list = (nlo_configured_parameters *) buf_ptr;
7823 for (i = 0; i < cmd->no_of_ssids; i++) {
7824 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7825 WMITLV_TAG_ARRAY_BYTE,
7826 WMITLV_GET_STRUCT_TLVLEN
7827 (nlo_configured_parameters));
7828 /* Copy ssid and it's length */
7829 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307830 nlo_list[i].ssid.ssid.ssid_len =
7831 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307832 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307833 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307834 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307835 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307836 nlo_list[i].ssid.ssid.ssid_len,
7837 (char *)nlo_list[i].ssid.ssid.ssid,
7838 nlo_list[i].ssid.ssid.ssid_len);
7839
7840 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307841 if (pno->networks_list[i].rssi_thresh &&
7842 pno->networks_list[i].rssi_thresh >
7843 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307844 nlo_list[i].rssi_cond.valid = true;
7845 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307846 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307847 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307848 nlo_list[i].rssi_cond.rssi);
7849 }
7850 nlo_list[i].bcast_nw_type.valid = true;
7851 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307852 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007853 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307854 nlo_list[i].bcast_nw_type.bcast_nw_type);
7855 }
7856 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7857
7858 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307859 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307860 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307861 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307862 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7863 (cmd->num_of_channels * sizeof(uint32_t)));
7864 buf_ptr += WMI_TLV_HDR_SIZE;
7865
7866 channel_list = (uint32_t *) buf_ptr;
7867 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307868 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307869
7870 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307871 channel_list[i] =
7872 wlan_chan_to_freq(pno->
7873 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307874
Govind Singhb53420c2016-03-09 14:32:57 +05307875 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307876 }
7877 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7879 sizeof(nlo_channel_prediction_cfg));
7880 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307881 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307882 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307883 /** TODO: Discrete firmware doesn't have command/option to configure
7884 * App IE which comes from wpa_supplicant as of part PNO start request.
7885 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307886 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7887 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7888 buf_ptr += sizeof(enlo_candidate_score_params);
7889
7890 if (ie_whitelist->white_list) {
7891 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7892 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7893 &cmd->num_vendor_oui,
7894 ie_whitelist);
7895 }
7896
7897 /* ie white list */
7898 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7899 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7900 buf_ptr += WMI_TLV_HDR_SIZE;
7901 if (cmd->num_vendor_oui != 0) {
7902 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7903 ie_whitelist->voui);
7904 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7905 }
7906
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307907 if (pno->relative_rssi_set)
7908 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7909
7910 /*
7911 * Firmware calculation using connected PNO params:
7912 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7913 * deduction of rssi_pref for chosen band_pref and
7914 * addition of rssi_pref for remaining bands (other than chosen band).
7915 */
7916 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7917 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7918 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7919 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7920 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7921 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7922 buf_ptr += sizeof(*nlo_relative_rssi);
7923
7924 /*
7925 * As of now Kernel and Host supports one band and rssi preference.
7926 * Firmware supports array of band and rssi preferences
7927 */
7928 cmd->num_cnlo_band_pref = 1;
7929 WMITLV_SET_HDR(buf_ptr,
7930 WMITLV_TAG_ARRAY_STRUC,
7931 cmd->num_cnlo_band_pref *
7932 sizeof(connected_nlo_bss_band_rssi_pref));
7933 buf_ptr += WMI_TLV_HDR_SIZE;
7934
7935 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7936 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7937 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7938 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7939 WMITLV_GET_STRUCT_TLVLEN(
7940 connected_nlo_bss_band_rssi_pref));
7941 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7942 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7943 WMI_LOGI("band_pref %d, rssi_pref %d",
7944 nlo_band_rssi[i].band,
7945 nlo_band_rssi[i].rssi_pref);
7946 }
7947 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7948
Govind Singh4eacd2b2016-03-07 14:24:22 +05307949 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7950 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7951 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307952 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307953 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307954 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307955 }
7956
Govind Singhb53420c2016-03-09 14:32:57 +05307957 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307958}
7959
7960/* send_set_ric_req_cmd_tlv() - set ric request element
7961 * @wmi_handle: wmi handle
7962 * @msg: message
7963 * @is_add_ts: is addts required
7964 *
7965 * This function sets ric request element for 11r roaming.
7966 *
7967 * Return: CDF status
7968 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307969static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307970 void *msg, uint8_t is_add_ts)
7971{
7972 wmi_ric_request_fixed_param *cmd;
7973 wmi_ric_tspec *tspec_param;
7974 wmi_buf_t buf;
7975 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307976 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307977 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7978 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7979
7980 buf = wmi_buf_alloc(wmi_handle, len);
7981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307982 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7983 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307984 }
7985
7986 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7987
7988 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7989 WMITLV_SET_HDR(&cmd->tlv_header,
7990 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7991 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7992 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007993 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307994 else
7995 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7996 cmd->num_ric_request = 1;
7997 cmd->is_add_ric = is_add_ts;
7998
7999 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8000 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8001
8002 buf_ptr += WMI_TLV_HDR_SIZE;
8003 tspec_param = (wmi_ric_tspec *) buf_ptr;
8004 WMITLV_SET_HDR(&tspec_param->tlv_header,
8005 WMITLV_TAG_STRUC_wmi_ric_tspec,
8006 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8007
8008 if (is_add_ts)
8009 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308010#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308011 else
8012 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308013#endif
8014 if (ptspecIE) {
8015 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308016#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308017 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8018 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308019#else
Govind Singh87542482016-06-08 19:40:11 +05308020 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8021 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308022#endif /* ANI_LITTLE_BIT_ENDIAN */
8023
Govind Singh87542482016-06-08 19:40:11 +05308024 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8025 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8026 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8027 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8028 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8029 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8030 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8031 tspec_param->min_data_rate = ptspecIE->minDataRate;
8032 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8033 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8034 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8035 tspec_param->delay_bound = ptspecIE->delayBound;
8036 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8037 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8038 tspec_param->medium_time = 0;
8039 }
Govind Singhb53420c2016-03-09 14:32:57 +05308040 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308041
8042 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8043 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308044 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308045 __func__);
8046 if (is_add_ts)
8047 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308048 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308049 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308050 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308051 }
8052
Govind Singhb53420c2016-03-09 14:32:57 +05308053 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308054}
8055
8056/**
8057 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8058 * @wmi_handle: wmi handle
8059 * @clear_req: ll stats clear request command params
8060 *
Govind Singhb53420c2016-03-09 14:32:57 +05308061 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308062 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308063static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308064 const struct ll_stats_clear_params *clear_req,
8065 uint8_t addr[IEEE80211_ADDR_LEN])
8066{
8067 wmi_clear_link_stats_cmd_fixed_param *cmd;
8068 int32_t len;
8069 wmi_buf_t buf;
8070 uint8_t *buf_ptr;
8071 int ret;
8072
8073 len = sizeof(*cmd);
8074 buf = wmi_buf_alloc(wmi_handle, len);
8075
8076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308077 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8078 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308079 }
8080
8081 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308082 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308083 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8084
8085 WMITLV_SET_HDR(&cmd->tlv_header,
8086 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8087 WMITLV_GET_STRUCT_TLVLEN
8088 (wmi_clear_link_stats_cmd_fixed_param));
8089
8090 cmd->stop_stats_collection_req = clear_req->stop_req;
8091 cmd->vdev_id = clear_req->sta_id;
8092 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8093
8094 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8095 &cmd->peer_macaddr);
8096
Govind Singhb53420c2016-03-09 14:32:57 +05308097 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8098 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8099 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8100 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8101 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308102 cmd->peer_macaddr); */
8103
8104 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8105 WMI_CLEAR_LINK_STATS_CMDID);
8106 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308107 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308108 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308109 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308110 }
8111
Govind Singhb53420c2016-03-09 14:32:57 +05308112 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8113 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308114}
8115
8116/**
8117 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8118 * @wmi_handle: wmi handle
8119 * @setReq: ll stats set request command params
8120 *
Govind Singhb53420c2016-03-09 14:32:57 +05308121 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308122 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308123static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308124 const struct ll_stats_set_params *set_req)
8125{
8126 wmi_start_link_stats_cmd_fixed_param *cmd;
8127 int32_t len;
8128 wmi_buf_t buf;
8129 uint8_t *buf_ptr;
8130 int ret;
8131
8132 len = sizeof(*cmd);
8133 buf = wmi_buf_alloc(wmi_handle, len);
8134
8135 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308136 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8137 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308138 }
8139
8140 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308141 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308142 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8143
8144 WMITLV_SET_HDR(&cmd->tlv_header,
8145 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8146 WMITLV_GET_STRUCT_TLVLEN
8147 (wmi_start_link_stats_cmd_fixed_param));
8148
8149 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8150 cmd->aggressive_statistics_gathering =
8151 set_req->aggressive_statistics_gathering;
8152
Govind Singhb53420c2016-03-09 14:32:57 +05308153 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8154 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8155 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308156
8157 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8158 WMI_START_LINK_STATS_CMDID);
8159 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308160 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308161 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308162 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308163 }
8164
Govind Singhb53420c2016-03-09 14:32:57 +05308165 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308166}
8167
8168/**
8169 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8170 * @wmi_handle:wmi handle
8171 * @get_req:ll stats get request command params
8172 * @addr: mac address
8173 *
Govind Singhb53420c2016-03-09 14:32:57 +05308174 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308175 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308176static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308177 const struct ll_stats_get_params *get_req,
8178 uint8_t addr[IEEE80211_ADDR_LEN])
8179{
8180 wmi_request_link_stats_cmd_fixed_param *cmd;
8181 int32_t len;
8182 wmi_buf_t buf;
8183 uint8_t *buf_ptr;
8184 int ret;
8185
8186 len = sizeof(*cmd);
8187 buf = wmi_buf_alloc(wmi_handle, len);
8188
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308189 if (!buf) {
8190 WMI_LOGE("%s: buf allocation failed", __func__);
8191 return QDF_STATUS_E_NOMEM;
8192 }
8193
Govind Singh4eacd2b2016-03-07 14:24:22 +05308194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308195 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308196 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8197
8198 WMITLV_SET_HDR(&cmd->tlv_header,
8199 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8200 WMITLV_GET_STRUCT_TLVLEN
8201 (wmi_request_link_stats_cmd_fixed_param));
8202
8203 cmd->request_id = get_req->req_id;
8204 cmd->stats_type = get_req->param_id_mask;
8205 cmd->vdev_id = get_req->sta_id;
8206
8207 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8208 &cmd->peer_macaddr);
8209
Govind Singhb53420c2016-03-09 14:32:57 +05308210 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008211 WMI_LOGD("Request ID : %u", cmd->request_id);
8212 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308213 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8214 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308215
8216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8217 WMI_REQUEST_LINK_STATS_CMDID);
8218 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308219 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308220 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308221 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308222 }
8223
Govind Singhb53420c2016-03-09 14:32:57 +05308224 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308225}
8226
Govind Singh4eacd2b2016-03-07 14:24:22 +05308227
Govind Singh20c5dac2016-03-07 15:33:31 +05308228/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308229 * send_congestion_cmd_tlv() - send request to fw to get CCA
8230 * @wmi_handle: wmi handle
8231 * @vdev_id: vdev id
8232 *
8233 * Return: CDF status
8234 */
8235static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
8236 A_UINT8 vdev_id)
8237{
8238 wmi_buf_t buf;
8239 wmi_request_stats_cmd_fixed_param *cmd;
8240 uint8_t len;
8241 uint8_t *buf_ptr;
8242
8243 len = sizeof(*cmd);
8244 buf = wmi_buf_alloc(wmi_handle, len);
8245 if (!buf) {
8246 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8247 return QDF_STATUS_E_FAILURE;
8248 }
8249
8250 buf_ptr = wmi_buf_data(buf);
8251 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8252 WMITLV_SET_HDR(&cmd->tlv_header,
8253 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8254 WMITLV_GET_STRUCT_TLVLEN
8255 (wmi_request_stats_cmd_fixed_param));
8256
8257 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8258 cmd->vdev_id = vdev_id;
8259 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8260 cmd->vdev_id, cmd->stats_id);
8261
8262 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8263 WMI_REQUEST_STATS_CMDID)) {
8264 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8265 __func__);
8266 wmi_buf_free(buf);
8267 return QDF_STATUS_E_FAILURE;
8268 }
8269
8270 return QDF_STATUS_SUCCESS;
8271}
8272
8273/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308274 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8275 * @wmi_handle: wmi handle
8276 * @rssi_req: get RSSI request
8277 *
8278 * Return: CDF status
8279 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308280static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308281{
8282 wmi_buf_t buf;
8283 wmi_request_stats_cmd_fixed_param *cmd;
8284 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8285
8286 buf = wmi_buf_alloc(wmi_handle, len);
8287 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308288 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8289 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308290 }
8291
8292 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8293 WMITLV_SET_HDR(&cmd->tlv_header,
8294 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8295 WMITLV_GET_STRUCT_TLVLEN
8296 (wmi_request_stats_cmd_fixed_param));
8297 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8298 if (wmi_unified_cmd_send
8299 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308300 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308301 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308302 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308303 }
8304
Govind Singhb53420c2016-03-09 14:32:57 +05308305 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308306}
8307
8308/**
8309 * send_snr_cmd_tlv() - get RSSI from fw
8310 * @wmi_handle: wmi handle
8311 * @vdev_id: vdev id
8312 *
8313 * Return: CDF status
8314 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308315static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308316{
8317 wmi_buf_t buf;
8318 wmi_request_stats_cmd_fixed_param *cmd;
8319 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8320
8321 buf = wmi_buf_alloc(wmi_handle, len);
8322 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308323 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8324 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308325 }
8326
8327 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8328 cmd->vdev_id = vdev_id;
8329
8330 WMITLV_SET_HDR(&cmd->tlv_header,
8331 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8332 WMITLV_GET_STRUCT_TLVLEN
8333 (wmi_request_stats_cmd_fixed_param));
8334 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8335 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8336 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308337 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308338 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308339 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308340 }
8341
Govind Singhb53420c2016-03-09 14:32:57 +05308342 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308343}
8344
8345/**
8346 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8347 * @wmi_handle: wmi handle
8348 * @link_status: get link params
8349 *
8350 * Return: CDF status
8351 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308352static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308353 struct link_status_params *link_status)
8354{
8355 wmi_buf_t buf;
8356 wmi_request_stats_cmd_fixed_param *cmd;
8357 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8358
8359 buf = wmi_buf_alloc(wmi_handle, len);
8360 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308361 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8362 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308363 }
8364
8365 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8366 WMITLV_SET_HDR(&cmd->tlv_header,
8367 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8368 WMITLV_GET_STRUCT_TLVLEN
8369 (wmi_request_stats_cmd_fixed_param));
8370 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8371 cmd->vdev_id = link_status->session_id;
8372 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8373 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308374 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308376 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308377 }
8378
Govind Singhb53420c2016-03-09 14:32:57 +05308379 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308380}
8381
Govind Singh20c5dac2016-03-07 15:33:31 +05308382/**
8383 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8384 * @wmi_handle: wmi handle
8385 * @ta_dhcp_ind: DHCP indication parameter
8386 *
8387 * Return: CDF Status
8388 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308389static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8391{
Govind Singh67922e82016-04-01 16:48:57 +05308392 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308393 wmi_buf_t buf = NULL;
8394 uint8_t *buf_ptr;
8395 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8396 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8397
8398
8399 buf = wmi_buf_alloc(wmi_handle, len);
8400 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308401 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8402 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308403 }
8404
8405 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8406 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8407 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8408 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8409 WMITLV_GET_STRUCT_TLVLEN
8410 (wmi_peer_set_param_cmd_fixed_param));
8411
8412 /* fill in values */
8413 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8414 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8415 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308416 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308417 &ta_dhcp_ind->peer_macaddr,
8418 sizeof(ta_dhcp_ind->peer_macaddr));
8419
8420 status = wmi_unified_cmd_send(wmi_handle, buf,
8421 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308422 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308423 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308424 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308425 wmi_buf_free(buf);
8426 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308427
Govind Singh67922e82016-04-01 16:48:57 +05308428 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308429}
8430
8431/**
8432 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8433 * @wmi_handle: wmi handle
8434 * @pLinkSpeed: link speed info
8435 *
8436 * Return: CDF status
8437 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308438static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308439 wmi_mac_addr peer_macaddr)
8440{
8441 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8442 wmi_buf_t wmi_buf;
8443 uint32_t len;
8444 uint8_t *buf_ptr;
8445
8446 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8447 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8448 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308449 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8450 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308451 }
8452 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8453
8454 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8455 WMITLV_SET_HDR(&cmd->tlv_header,
8456 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8457 WMITLV_GET_STRUCT_TLVLEN
8458 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8459
8460 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308461 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308462 &peer_macaddr,
8463 sizeof(peer_macaddr));
8464
8465
8466 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8467 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308468 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308469 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308470 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308471 }
Govind Singhb53420c2016-03-09 14:32:57 +05308472 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308473}
8474
8475/**
8476 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8477 * @wmi_handle: wmi handler
8478 * @egap_params: pointer to egap_params
8479 *
8480 * Return: 0 for success, otherwise appropriate error code
8481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308482static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308483 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
8484{
8485 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8486 wmi_buf_t buf;
8487 int32_t err;
8488
8489 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308491 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8492 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308493 }
8494 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8495 WMITLV_SET_HDR(&cmd->tlv_header,
8496 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8497 WMITLV_GET_STRUCT_TLVLEN(
8498 wmi_ap_ps_egap_param_cmd_fixed_param));
8499
8500 cmd->enable = egap_params->enable;
8501 cmd->inactivity_time = egap_params->inactivity_time;
8502 cmd->wait_time = egap_params->wait_time;
8503 cmd->flags = egap_params->flags;
8504 err = wmi_unified_cmd_send(wmi_handle, buf,
8505 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8506 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308507 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308508 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308509 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308510 }
8511
Govind Singhb53420c2016-03-09 14:32:57 +05308512 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513}
8514
8515/**
8516 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8517 * @wmi_handl: wmi handle
8518 * @cmd: Profiling command index
8519 * @value1: parameter1 value
8520 * @value2: parameter2 value
8521 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308522 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308523 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308524static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308525 uint32_t cmd, uint32_t value1, uint32_t value2)
8526{
8527 wmi_buf_t buf;
8528 int32_t len = 0;
8529 int ret;
8530 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8531 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8532 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8533 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8534
8535 switch (cmd) {
8536 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8537 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8538 buf = wmi_buf_alloc(wmi_handle, len);
8539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308540 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308541 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308542 }
8543 prof_trig_cmd =
8544 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8545 wmi_buf_data(buf);
8546 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8547 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8548 WMITLV_GET_STRUCT_TLVLEN
8549 (wmi_wlan_profile_trigger_cmd_fixed_param));
8550 prof_trig_cmd->enable = value1;
8551 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8552 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8553 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308554 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308555 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308556 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308557 return ret;
8558 }
8559 break;
8560
8561 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8562 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8563 buf = wmi_buf_alloc(wmi_handle, len);
8564 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308565 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308566 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308567 }
8568 profile_getdata_cmd =
8569 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8570 wmi_buf_data(buf);
8571 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8572 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8573 WMITLV_GET_STRUCT_TLVLEN
8574 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8575 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8576 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8577 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308578 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308579 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308580 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308581 return ret;
8582 }
8583 break;
8584
8585 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8586 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8587 buf = wmi_buf_alloc(wmi_handle, len);
8588 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308589 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308590 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308591 }
8592 hist_intvl_cmd =
8593 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8594 wmi_buf_data(buf);
8595 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8596 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8597 WMITLV_GET_STRUCT_TLVLEN
8598 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8599 hist_intvl_cmd->profile_id = value1;
8600 hist_intvl_cmd->value = value2;
8601 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8602 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8603 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308604 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308605 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308606 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308607 return ret;
8608 }
8609 break;
8610
8611 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8612 len =
8613 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8614 buf = wmi_buf_alloc(wmi_handle, len);
8615 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308616 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308617 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308618 }
8619 profile_enable_cmd =
8620 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8621 wmi_buf_data(buf);
8622 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8623 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8624 WMITLV_GET_STRUCT_TLVLEN
8625 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8626 profile_enable_cmd->profile_id = value1;
8627 profile_enable_cmd->enable = value2;
8628 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8629 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8630 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308631 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308632 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308633 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308634 return ret;
8635 }
8636 break;
8637
8638 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308639 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308640 break;
8641 }
8642
8643 return 0;
8644}
8645
Paul Zhang92ab8d32017-12-08 16:08:00 +08008646static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8647 struct wlm_latency_level_param *params)
8648{
8649 wmi_wlm_config_cmd_fixed_param *cmd;
8650 wmi_buf_t buf;
8651 uint32_t len = sizeof(*cmd);
8652 static uint32_t ll[4] = {100, 60, 40, 20};
8653
8654 buf = wmi_buf_alloc(wmi_handle, len);
8655 if (!buf) {
8656 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8657 return QDF_STATUS_E_NOMEM;
8658 }
8659 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8660 WMITLV_SET_HDR(&cmd->tlv_header,
8661 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8662 WMITLV_GET_STRUCT_TLVLEN
8663 (wmi_wlm_config_cmd_fixed_param));
8664 cmd->vdev_id = params->vdev_id;
8665 cmd->latency_level = params->wlm_latency_level;
8666 cmd->ul_latency = ll[params->wlm_latency_level];
8667 cmd->dl_latency = ll[params->wlm_latency_level];
8668 cmd->flags = params->wlm_latency_flags;
8669 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8670 WMI_WLM_CONFIG_CMDID)) {
8671 WMI_LOGE("%s: Failed to send setting latency config command",
8672 __func__);
8673 wmi_buf_free(buf);
8674 return QDF_STATUS_E_FAILURE;
8675 }
8676
8677 return 0;
8678}
Govind Singh20c5dac2016-03-07 15:33:31 +05308679/**
8680 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8681 * @wmi_handle: wmi handle
8682 * @vdev_id: vdev id
8683 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308684 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308685 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308686static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308687{
8688 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8689 wmi_buf_t buf;
8690 int32_t len = sizeof(*cmd);
8691
Govind Singhb53420c2016-03-09 14:32:57 +05308692 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308693 buf = wmi_buf_alloc(wmi_handle, len);
8694 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308695 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308696 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308697 }
8698 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8699 wmi_buf_data(buf);
8700 WMITLV_SET_HDR(&cmd->tlv_header,
8701 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8702 WMITLV_GET_STRUCT_TLVLEN
8703 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8704 cmd->vdev_id = vdev_id;
8705 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8706 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8707 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308708 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308709 __func__);
8710 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308711 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 }
8713
8714 return 0;
8715}
8716
8717/**
8718 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8719 * @wmi_handle: wmi handle
8720 * @vdev_id: vdev id
8721 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308722 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308724static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308725 uint8_t vdev_id)
8726{
8727 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8728 wmi_buf_t buf;
8729 int32_t len = sizeof(*cmd);
8730
Govind Singhb53420c2016-03-09 14:32:57 +05308731 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308732 buf = wmi_buf_alloc(wmi_handle, len);
8733 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308734 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308735 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308736 }
8737 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8738 WMITLV_SET_HDR(&cmd->tlv_header,
8739 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8740 WMITLV_GET_STRUCT_TLVLEN
8741 (wmi_csa_offload_enable_cmd_fixed_param));
8742 cmd->vdev_id = vdev_id;
8743 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8744 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8745 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308746 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308747 __func__);
8748 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308749 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308750 }
8751
8752 return 0;
8753}
8754
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008755#ifdef WLAN_FEATURE_CIF_CFR
8756/**
8757 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8758 * @wmi_handle: wmi handle
8759 * @data_len: len of dma cfg req
8760 * @data: dma cfg req
8761 *
8762 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8763 */
8764static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8765 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8766{
8767 wmi_buf_t buf;
8768 uint8_t *cmd;
8769 QDF_STATUS ret;
8770
8771 WMITLV_SET_HDR(cfg,
8772 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8773 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8774
8775 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8776 if (!buf) {
8777 WMI_LOGE(FL("wmi_buf_alloc failed"));
8778 return QDF_STATUS_E_FAILURE;
8779 }
8780
8781 cmd = (uint8_t *) wmi_buf_data(buf);
8782 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8783 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8784 sizeof(*cfg));
8785 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8786 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8787 if (QDF_IS_STATUS_ERROR(ret)) {
8788 WMI_LOGE(FL(":wmi cmd send failed"));
8789 wmi_buf_free(buf);
8790 }
8791
8792 return ret;
8793}
8794#endif
8795
Govind Singh20c5dac2016-03-07 15:33:31 +05308796/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308797 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8798 * @wmi_handle: wmi handle
8799 * @data_len: len of dma cfg req
8800 * @data: dma cfg req
8801 *
8802 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8803 */
8804static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8805 struct direct_buf_rx_cfg_req *cfg)
8806{
8807 wmi_buf_t buf;
8808 wmi_dma_ring_cfg_req_fixed_param *cmd;
8809 QDF_STATUS ret;
8810 int32_t len = sizeof(*cmd);
8811
8812 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8813 if (!buf) {
8814 WMI_LOGE(FL("wmi_buf_alloc failed"));
8815 return QDF_STATUS_E_FAILURE;
8816 }
8817
8818 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8819
8820 WMITLV_SET_HDR(&cmd->tlv_header,
8821 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8822 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8823
8824 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8825 cfg->pdev_id);
8826 cmd->mod_id = cfg->mod_id;
8827 cmd->base_paddr_lo = cfg->base_paddr_lo;
8828 cmd->base_paddr_hi = cfg->base_paddr_hi;
8829 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8830 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8831 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8832 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8833 cmd->num_elems = cfg->num_elems;
8834 cmd->buf_size = cfg->buf_size;
8835 cmd->num_resp_per_event = cfg->num_resp_per_event;
8836 cmd->event_timeout_ms = cfg->event_timeout_ms;
8837
8838 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8839 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8840 "head idx paddr hi %x tail idx paddr lo %x"
8841 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8842 "event timeout %d\n", __func__, cmd->pdev_id,
8843 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8844 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8845 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8846 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8847 cmd->event_timeout_ms);
8848 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8849 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8850 if (QDF_IS_STATUS_ERROR(ret)) {
8851 WMI_LOGE(FL(":wmi cmd send failed"));
8852 wmi_buf_free(buf);
8853 }
8854
8855 return ret;
8856}
8857
8858/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008859 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8860 * @wmi_handle: wmi handle
8861 * @start_11d_scan: 11d scan start request parameters
8862 *
8863 * This function request FW to start 11d scan.
8864 *
8865 * Return: QDF status
8866 */
8867static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8868 struct reg_start_11d_scan_req *start_11d_scan)
8869{
8870 wmi_11d_scan_start_cmd_fixed_param *cmd;
8871 int32_t len;
8872 wmi_buf_t buf;
8873 int ret;
8874
8875 len = sizeof(*cmd);
8876 buf = wmi_buf_alloc(wmi_handle, len);
8877 if (!buf) {
8878 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8879 return QDF_STATUS_E_NOMEM;
8880 }
8881
8882 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8883
8884 WMITLV_SET_HDR(&cmd->tlv_header,
8885 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8886 WMITLV_GET_STRUCT_TLVLEN
8887 (wmi_11d_scan_start_cmd_fixed_param));
8888
8889 cmd->vdev_id = start_11d_scan->vdev_id;
8890 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8891 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8892
8893 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8894
8895 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8896 WMI_11D_SCAN_START_CMDID);
8897 if (ret) {
8898 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8899 wmi_buf_free(buf);
8900 return QDF_STATUS_E_FAILURE;
8901 }
8902
8903 return QDF_STATUS_SUCCESS;
8904}
8905
8906/**
8907 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8908 * @wmi_handle: wmi handle
8909 * @start_11d_scan: 11d scan stop request parameters
8910 *
8911 * This function request FW to stop 11d scan.
8912 *
8913 * Return: QDF status
8914 */
8915static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8916 struct reg_stop_11d_scan_req *stop_11d_scan)
8917{
8918 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8919 int32_t len;
8920 wmi_buf_t buf;
8921 int ret;
8922
8923 len = sizeof(*cmd);
8924 buf = wmi_buf_alloc(wmi_handle, len);
8925 if (!buf) {
8926 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8927 return QDF_STATUS_E_NOMEM;
8928 }
8929
8930 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8931
8932 WMITLV_SET_HDR(&cmd->tlv_header,
8933 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8934 WMITLV_GET_STRUCT_TLVLEN
8935 (wmi_11d_scan_stop_cmd_fixed_param));
8936
8937 cmd->vdev_id = stop_11d_scan->vdev_id;
8938
8939 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8940
8941 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8942 WMI_11D_SCAN_STOP_CMDID);
8943 if (ret) {
8944 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8945 wmi_buf_free(buf);
8946 return QDF_STATUS_E_FAILURE;
8947 }
8948
8949 return QDF_STATUS_SUCCESS;
8950}
8951
8952/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308953 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8954 * @wmi_handle: wmi handle
8955 * @startOemDataReq: start request params
8956 *
8957 * Return: CDF status
8958 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308959static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008960 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308961 uint8_t *data)
8962{
8963 wmi_buf_t buf;
8964 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308965 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308966
8967 buf = wmi_buf_alloc(wmi_handle,
8968 (data_len + WMI_TLV_HDR_SIZE));
8969 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308970 WMI_LOGE(FL("wmi_buf_alloc failed"));
8971 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308972 }
8973
8974 cmd = (uint8_t *) wmi_buf_data(buf);
8975
8976 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8977 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308978 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308979 data_len);
8980
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008981 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308982 data_len);
8983
8984 ret = wmi_unified_cmd_send(wmi_handle, buf,
8985 (data_len +
8986 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8987
Govind Singh67922e82016-04-01 16:48:57 +05308988 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308989 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308990 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308991 }
8992
Govind Singh67922e82016-04-01 16:48:57 +05308993 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308994}
8995
8996/**
8997 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8998 * @wmi_handle: wmi handle
8999 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9000 *
9001 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9002 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9003 * to firmware based on phyerr filtering
9004 * offload status.
9005 *
9006 * Return: 1 success, 0 failure
9007 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309008static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309009send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9010 bool dfs_phyerr_filter_offload)
9011{
9012 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9013 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9014 wmi_buf_t buf;
9015 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309016 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309017
9018
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009019 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309020 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309021 __func__);
9022 len = sizeof(*disable_phyerr_offload_cmd);
9023 buf = wmi_buf_alloc(wmi_handle, len);
9024 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309025 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309026 return 0;
9027 }
9028 disable_phyerr_offload_cmd =
9029 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9030 wmi_buf_data(buf);
9031
9032 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9033 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9034 WMITLV_GET_STRUCT_TLVLEN
9035 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9036
9037 /*
9038 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9039 * to the firmware to disable the phyerror
9040 * filtering offload.
9041 */
9042 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9043 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309044 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309045 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309046 __func__, ret);
9047 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309048 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309049 }
Govind Singhb53420c2016-03-09 14:32:57 +05309050 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309051 __func__);
9052 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309053 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309054 __func__);
9055
9056 len = sizeof(*enable_phyerr_offload_cmd);
9057 buf = wmi_buf_alloc(wmi_handle, len);
9058 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309059 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9060 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061 }
9062
9063 enable_phyerr_offload_cmd =
9064 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9065 wmi_buf_data(buf);
9066
9067 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9068 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9069 WMITLV_GET_STRUCT_TLVLEN
9070 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9071
9072 /*
9073 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9074 * to the firmware to enable the phyerror
9075 * filtering offload.
9076 */
9077 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9078 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9079
Govind Singh67922e82016-04-01 16:48:57 +05309080 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309081 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309082 __func__, ret);
9083 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309084 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309085 }
Govind Singhb53420c2016-03-09 14:32:57 +05309086 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309087 __func__);
9088 }
9089
Govind Singhb53420c2016-03-09 14:32:57 +05309090 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309091}
9092
Naveen Rawata5817e72017-10-26 18:50:19 -07009093/**
9094 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9095 * will wake up host after specified time is elapsed
9096 * @wmi_handle: wmi handle
9097 * @vdev_id: vdev id
9098 * @cookie: value to identify reason why host set up wake call.
9099 * @time: time in ms
9100 *
9101 * Return: QDF status
9102 */
9103static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9104 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9105{
9106 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9107 wmi_buf_t buf;
9108 uint8_t *buf_ptr;
9109 int32_t len;
9110 int ret;
9111
9112 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9113 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9114 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9115 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9116 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
9117 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) +
9118 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
9119
9120 buf = wmi_buf_alloc(wmi_handle, len);
9121 if (!buf) {
9122 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9123 return QDF_STATUS_E_NOMEM;
9124 }
9125
9126 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9127 buf_ptr = (uint8_t *) cmd;
9128
9129 WMITLV_SET_HDR(&cmd->tlv_header,
9130 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9131 WMITLV_GET_STRUCT_TLVLEN
9132 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9133 cmd->vdev_id = vdev_id;
9134 cmd->pattern_id = cookie,
9135 cmd->pattern_type = WOW_TIMER_PATTERN;
9136 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9137
9138 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9140 buf_ptr += WMI_TLV_HDR_SIZE;
9141
9142 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9144 buf_ptr += WMI_TLV_HDR_SIZE;
9145
9146 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9148 buf_ptr += WMI_TLV_HDR_SIZE;
9149
9150 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9152 buf_ptr += WMI_TLV_HDR_SIZE;
9153
9154 /* Fill TLV for pattern_info_timeout, and time value */
9155 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9156 buf_ptr += WMI_TLV_HDR_SIZE;
9157 *((A_UINT32 *) buf_ptr) = time;
9158 buf_ptr += sizeof(A_UINT32);
9159
9160 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
9161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9162 buf_ptr += WMI_TLV_HDR_SIZE;
9163 *((A_UINT32 *) buf_ptr) = 0;
9164
9165 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9166 __func__, time, vdev_id);
9167
9168 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9169 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9170 if (ret) {
9171 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9172 __func__);
9173 wmi_buf_free(buf);
9174 return QDF_STATUS_E_FAILURE;
9175 }
9176
9177 return QDF_STATUS_SUCCESS;
9178}
9179
Govind Singh20c5dac2016-03-07 15:33:31 +05309180#if !defined(REMOVE_PKT_LOG)
9181/**
9182 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9183 * @wmi_handle: wmi handle
9184 * @pktlog_event: pktlog event
9185 * @cmd_id: pktlog cmd id
9186 *
9187 * Return: CDF status
9188 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309189static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309191 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309192{
9193 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9194 WMI_CMD_ID CMD_ID;
9195 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9196 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9197 int len = 0;
9198 wmi_buf_t buf;
9199
9200 PKTLOG_EVENT = pktlog_event;
9201 CMD_ID = cmd_id;
9202
9203 switch (CMD_ID) {
9204 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9205 len = sizeof(*cmd);
9206 buf = wmi_buf_alloc(wmi_handle, len);
9207 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309208 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9209 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309210 }
9211 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9212 wmi_buf_data(buf);
9213 WMITLV_SET_HDR(&cmd->tlv_header,
9214 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9215 WMITLV_GET_STRUCT_TLVLEN
9216 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9217 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309218 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9219 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309220 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9221 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9223 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309224 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309225 goto wmi_send_failed;
9226 }
9227 break;
9228 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9229 len = sizeof(*disable_cmd);
9230 buf = wmi_buf_alloc(wmi_handle, len);
9231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309232 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9233 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309234 }
9235 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9236 wmi_buf_data(buf);
9237 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9238 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9239 WMITLV_GET_STRUCT_TLVLEN
9240 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309241 disable_cmd->pdev_id =
9242 wmi_handle->ops->convert_pdev_id_host_to_target(
9243 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309244 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9245 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309246 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309247 goto wmi_send_failed;
9248 }
9249 break;
9250 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309251 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309252 break;
9253 }
9254
Govind Singhb53420c2016-03-09 14:32:57 +05309255 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309256
9257wmi_send_failed:
9258 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309259 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309260}
9261#endif /* REMOVE_PKT_LOG */
9262
9263/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309264 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9265 * @wmi_handle: wmi handle
9266 * @ptrn_id: pattern id
9267 * @vdev_id: vdev id
9268 *
9269 * Return: CDF status
9270 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309271static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9272 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309273{
9274 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9275 wmi_buf_t buf;
9276 int32_t len;
9277 int ret;
9278
9279 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9280
9281
9282 buf = wmi_buf_alloc(wmi_handle, len);
9283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309284 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9285 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309286 }
9287
9288 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9289
9290 WMITLV_SET_HDR(&cmd->tlv_header,
9291 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9292 WMITLV_GET_STRUCT_TLVLEN(
9293 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9294 cmd->vdev_id = vdev_id;
9295 cmd->pattern_id = ptrn_id;
9296 cmd->pattern_type = WOW_BITMAP_PATTERN;
9297
Govind Singhb53420c2016-03-09 14:32:57 +05309298 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309299 cmd->pattern_id, vdev_id);
9300
9301 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9302 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9303 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309304 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 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 }
9308
Govind Singhb53420c2016-03-09 14:32:57 +05309309 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309310}
9311
9312/**
9313 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9314 * @wmi_handle: wmi handle
9315 *
9316 * Sends host wakeup indication to FW. On receiving this indication,
9317 * FW will come out of WOW.
9318 *
9319 * Return: CDF status
9320 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309321static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309322{
9323 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9324 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309325 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309326 int32_t len;
9327 int ret;
9328
9329 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9330
9331 buf = wmi_buf_alloc(wmi_handle, len);
9332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309333 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9334 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309335 }
9336
9337 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9338 wmi_buf_data(buf);
9339 WMITLV_SET_HDR(&cmd->tlv_header,
9340 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9341 WMITLV_GET_STRUCT_TLVLEN
9342 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9343
9344
9345 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9346 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9347 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309348 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309349 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309350 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309351 }
9352
Govind Singhb53420c2016-03-09 14:32:57 +05309353 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309354}
9355
9356/**
9357 * send_del_ts_cmd_tlv() - send DELTS request to fw
9358 * @wmi_handle: wmi handle
9359 * @msg: delts params
9360 *
9361 * Return: CDF status
9362 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309363static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309364 uint8_t ac)
9365{
9366 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9367 wmi_buf_t buf;
9368 int32_t len = sizeof(*cmd);
9369
9370 buf = wmi_buf_alloc(wmi_handle, len);
9371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309372 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9373 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309374 }
9375 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9376 WMITLV_SET_HDR(&cmd->tlv_header,
9377 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9378 WMITLV_GET_STRUCT_TLVLEN
9379 (wmi_vdev_wmm_delts_cmd_fixed_param));
9380 cmd->vdev_id = vdev_id;
9381 cmd->ac = ac;
9382
Govind Singhb53420c2016-03-09 14:32:57 +05309383 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309384 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9385 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9386 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309387 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309388 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309389 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 }
9391
Govind Singhb53420c2016-03-09 14:32:57 +05309392 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309393}
9394
9395/**
9396 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9397 * @wmi_handle: handle to wmi
9398 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9399 *
Govind Singhb53420c2016-03-09 14:32:57 +05309400 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309401 * ADD_TS requestes to firmware in loop for all the ACs with
9402 * active flow.
9403 *
9404 * Return: CDF status
9405 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309406static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309407 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9408{
9409 int i = 0;
9410 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9411 wmi_buf_t buf;
9412 int32_t len = sizeof(*cmd);
9413
9414 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9415 /* if flow in this AC is active */
9416 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9417 /*
9418 * as per implementation of wma_add_ts_req() we
9419 * are not waiting any response from firmware so
9420 * apart from sending ADDTS to firmware just send
9421 * success to upper layers
9422 */
Govind Singhb53420c2016-03-09 14:32:57 +05309423 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309424
9425 buf = wmi_buf_alloc(wmi_handle, len);
9426 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309427 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9428 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309429 }
9430 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9431 wmi_buf_data(buf);
9432 WMITLV_SET_HDR(&cmd->tlv_header,
9433 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9434 WMITLV_GET_STRUCT_TLVLEN
9435 (wmi_vdev_wmm_addts_cmd_fixed_param));
9436 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9437 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309438 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309439 traffic.userPrio);
9440 cmd->medium_time_us =
9441 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9442 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309443 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309444 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9445 cmd->medium_time_us, cmd->downgrade_type);
9446 if (wmi_unified_cmd_send
9447 (wmi_handle, buf, len,
9448 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309449 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309450 __func__);
9451 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309452 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309453 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309454 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309455 }
9456 }
9457 }
9458
Govind Singhb53420c2016-03-09 14:32:57 +05309459 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309460}
9461
9462/**
9463 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9464 * @wmi_handle: wmi handle
9465 * @msg: ADDTS params
9466 *
9467 * Return: CDF status
9468 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309469static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309470 struct add_ts_param *msg)
9471{
9472 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9473 wmi_buf_t buf;
9474 int32_t len = sizeof(*cmd);
9475
Govind Singhb53420c2016-03-09 14:32:57 +05309476 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309477
9478 buf = wmi_buf_alloc(wmi_handle, len);
9479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309480 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9481 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309482 }
9483 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9484 WMITLV_SET_HDR(&cmd->tlv_header,
9485 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9486 WMITLV_GET_STRUCT_TLVLEN
9487 (wmi_vdev_wmm_addts_cmd_fixed_param));
9488 cmd->vdev_id = msg->sme_session_id;
9489 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9490 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9491 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309492 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309493 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9494 cmd->downgrade_type, __func__, __LINE__);
9495 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9496 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309497 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9498 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309499 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309500 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 }
9502
Govind Singhb53420c2016-03-09 14:32:57 +05309503 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309504}
9505
9506/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309507 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9508 * @wmi_handle: wmi handle
9509 * @pAddPeriodicTxPtrnParams: tx ptrn params
9510 *
9511 * Retrun: CDF status
9512 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309513static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309514 struct periodic_tx_pattern *
9515 pAddPeriodicTxPtrnParams,
9516 uint8_t vdev_id)
9517{
9518 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9519 wmi_buf_t wmi_buf;
9520 uint32_t len;
9521 uint8_t *buf_ptr;
9522 uint32_t ptrn_len, ptrn_len_aligned;
9523 int j;
9524
9525 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9526 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9527 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9528 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9529
9530 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9531 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309532 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9533 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309534 }
9535
9536 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9537
9538 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9539 WMITLV_SET_HDR(&cmd->tlv_header,
9540 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9541 WMITLV_GET_STRUCT_TLVLEN
9542 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9543
9544 /* Pass the pattern id to delete for the corresponding vdev id */
9545 cmd->vdev_id = vdev_id;
9546 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9547 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9548 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9549
9550 /* Pattern info */
9551 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9552 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9553 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309554 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309555 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309556 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309557
Govind Singhb53420c2016-03-09 14:32:57 +05309558 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309559 __func__, cmd->pattern_id, cmd->vdev_id);
9560
9561 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9562 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309563 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309564 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309565 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309566 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309567 }
Govind Singhb53420c2016-03-09 14:32:57 +05309568 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309569}
9570
9571/**
9572 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9573 * @wmi_handle: wmi handle
9574 * @vdev_id: vdev id
9575 * @pattern_id: pattern id
9576 *
9577 * Retrun: CDF status
9578 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309579static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309580 uint8_t vdev_id,
9581 uint8_t pattern_id)
9582{
9583 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9584 wmi_buf_t wmi_buf;
9585 uint32_t len =
9586 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9587
9588 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9589 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309590 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9591 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309592 }
9593
9594 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9595 wmi_buf_data(wmi_buf);
9596 WMITLV_SET_HDR(&cmd->tlv_header,
9597 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9598 WMITLV_GET_STRUCT_TLVLEN
9599 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9600
9601 /* Pass the pattern id to delete for the corresponding vdev id */
9602 cmd->vdev_id = vdev_id;
9603 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309604 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309605 __func__, cmd->pattern_id, cmd->vdev_id);
9606
9607 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9608 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309609 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309610 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309611 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309612 }
Govind Singhb53420c2016-03-09 14:32:57 +05309613 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309614}
9615
9616/**
9617 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9618 * @wmi_handle: wmi handle
9619 * @preq: stats ext params
9620 *
9621 * Return: CDF status
9622 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309623static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309624 struct stats_ext_params *preq)
9625{
Govind Singh67922e82016-04-01 16:48:57 +05309626 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309627 wmi_req_stats_ext_cmd_fixed_param *cmd;
9628 wmi_buf_t buf;
9629 uint16_t len;
9630 uint8_t *buf_ptr;
9631
9632 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9633
9634 buf = wmi_buf_alloc(wmi_handle, len);
9635 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309636 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309637 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309638 }
9639
9640 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9641 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9642
9643 WMITLV_SET_HDR(&cmd->tlv_header,
9644 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9645 WMITLV_GET_STRUCT_TLVLEN
9646 (wmi_req_stats_ext_cmd_fixed_param));
9647 cmd->vdev_id = preq->vdev_id;
9648 cmd->data_len = preq->request_data_len;
9649
Govind Singhb53420c2016-03-09 14:32:57 +05309650 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309651 __func__, preq->request_data_len, preq->vdev_id);
9652
9653 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9654 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9655
9656 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309657 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309658
9659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9660 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309661 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309662 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309663 ret);
9664 wmi_buf_free(buf);
9665 }
9666
9667 return ret;
9668}
9669
9670/**
9671 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9672 * @wmi_handle: wmi handle
9673 * @params: ext wow params
9674 *
9675 * Return:0 for success or error code
9676 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309677static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309678 struct ext_wow_params *params)
9679{
9680 wmi_extwow_enable_cmd_fixed_param *cmd;
9681 wmi_buf_t buf;
9682 int32_t len;
9683 int ret;
9684
9685 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9686 buf = wmi_buf_alloc(wmi_handle, len);
9687 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309688 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9689 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309690 }
9691
9692 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9693
9694 WMITLV_SET_HDR(&cmd->tlv_header,
9695 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9696 WMITLV_GET_STRUCT_TLVLEN
9697 (wmi_extwow_enable_cmd_fixed_param));
9698
9699 cmd->vdev_id = params->vdev_id;
9700 cmd->type = params->type;
9701 cmd->wakeup_pin_num = params->wakeup_pin_num;
9702
Govind Singhb53420c2016-03-09 14:32:57 +05309703 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309704 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9705
9706 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9707 WMI_EXTWOW_ENABLE_CMDID);
9708 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309709 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309710 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309711 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309712 }
9713
Govind Singhb53420c2016-03-09 14:32:57 +05309714 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309715
9716}
9717
9718/**
9719 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9720 * @wmi_handle: wmi handle
9721 * @app_type1_params: app type1 params
9722 *
9723 * Return: CDF status
9724 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309725static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309726 struct app_type1_params *app_type1_params)
9727{
9728 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9729 wmi_buf_t buf;
9730 int32_t len;
9731 int ret;
9732
9733 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9734 buf = wmi_buf_alloc(wmi_handle, len);
9735 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309736 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9737 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309738 }
9739
9740 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9741 wmi_buf_data(buf);
9742
9743 WMITLV_SET_HDR(&cmd->tlv_header,
9744 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9745 WMITLV_GET_STRUCT_TLVLEN
9746 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9747
9748 cmd->vdev_id = app_type1_params->vdev_id;
9749 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9750 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309751 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309752 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309753 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309754 cmd->passwd_len = app_type1_params->pass_length;
9755
Govind Singhb53420c2016-03-09 14:32:57 +05309756 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309757 "identification_id %.8s id_length %u "
9758 "password %.16s pass_length %u",
9759 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9760 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9761
9762 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9763 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9764 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309765 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309766 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309768 }
9769
Govind Singhb53420c2016-03-09 14:32:57 +05309770 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309771}
9772
9773/**
9774 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9775 * @wmi_handle: wmi handle
9776 * @appType2Params: app type2 params
9777 *
9778 * Return: CDF status
9779 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309780static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309781 struct app_type2_params *appType2Params)
9782{
9783 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9784 wmi_buf_t buf;
9785 int32_t len;
9786 int ret;
9787
9788 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9789 buf = wmi_buf_alloc(wmi_handle, len);
9790 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309791 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9792 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309793 }
9794
9795 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9796 wmi_buf_data(buf);
9797
9798 WMITLV_SET_HDR(&cmd->tlv_header,
9799 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9800 WMITLV_GET_STRUCT_TLVLEN
9801 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9802
9803 cmd->vdev_id = appType2Params->vdev_id;
9804
Govind Singhb53420c2016-03-09 14:32:57 +05309805 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309806 cmd->rc4_key_len = appType2Params->rc4_key_len;
9807
9808 cmd->ip_id = appType2Params->ip_id;
9809 cmd->ip_device_ip = appType2Params->ip_device_ip;
9810 cmd->ip_server_ip = appType2Params->ip_server_ip;
9811
9812 cmd->tcp_src_port = appType2Params->tcp_src_port;
9813 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9814 cmd->tcp_seq = appType2Params->tcp_seq;
9815 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9816
9817 cmd->keepalive_init = appType2Params->keepalive_init;
9818 cmd->keepalive_min = appType2Params->keepalive_min;
9819 cmd->keepalive_max = appType2Params->keepalive_max;
9820 cmd->keepalive_inc = appType2Params->keepalive_inc;
9821
9822 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9823 &cmd->gateway_mac);
9824 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9825 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9826
Govind Singhb53420c2016-03-09 14:32:57 +05309827 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309828 "rc4_key %.16s rc4_key_len %u "
9829 "ip_id %x ip_device_ip %x ip_server_ip %x "
9830 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9831 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9832 "keepalive_max %u keepalive_inc %u "
9833 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9834 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9835 cmd->rc4_key, cmd->rc4_key_len,
9836 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9837 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9838 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9839 cmd->keepalive_max, cmd->keepalive_inc,
9840 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9841
9842 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9843 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9844 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309845 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309846 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309847 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309848 }
9849
Govind Singhb53420c2016-03-09 14:32:57 +05309850 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309851
9852}
9853
9854/**
9855 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9856 * @wmi_handle: wmi handle
9857 * @timer_val: auto shutdown timer value
9858 *
9859 * Return: CDF status
9860 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309861static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309862 uint32_t timer_val)
9863{
Govind Singh67922e82016-04-01 16:48:57 +05309864 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309865 wmi_buf_t buf = NULL;
9866 uint8_t *buf_ptr;
9867 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9868 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9869
Govind Singhb53420c2016-03-09 14:32:57 +05309870 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309871 __func__, timer_val);
9872
9873 buf = wmi_buf_alloc(wmi_handle, len);
9874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309875 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9876 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309877 }
9878
9879 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9880 wmi_auto_sh_cmd =
9881 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9882 wmi_auto_sh_cmd->timer_value = timer_val;
9883
9884 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9885 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9886 WMITLV_GET_STRUCT_TLVLEN
9887 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9888
9889 status = wmi_unified_cmd_send(wmi_handle, buf,
9890 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309891 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309892 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309893 __func__, status);
9894 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309895 }
9896
Govind Singh67922e82016-04-01 16:48:57 +05309897 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309898}
9899
9900/**
9901 * send_nan_req_cmd_tlv() - to send nan request to target
9902 * @wmi_handle: wmi handle
9903 * @nan_req: request data which will be non-null
9904 *
9905 * Return: CDF status
9906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309907static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309908 struct nan_req_params *nan_req)
9909{
Govind Singh67922e82016-04-01 16:48:57 +05309910 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309911 wmi_nan_cmd_param *cmd;
9912 wmi_buf_t buf;
9913 uint16_t len = sizeof(*cmd);
9914 uint16_t nan_data_len, nan_data_len_aligned;
9915 uint8_t *buf_ptr;
9916
9917 /*
9918 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9919 * +------------+----------+-----------------------+--------------+
9920 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9921 * +------------+----------+-----------------------+--------------+
9922 */
9923 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309924 WMI_LOGE("%s:nan req is not valid", __func__);
9925 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309926 }
9927 nan_data_len = nan_req->request_data_len;
9928 nan_data_len_aligned = roundup(nan_req->request_data_len,
9929 sizeof(uint32_t));
9930 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9931 buf = wmi_buf_alloc(wmi_handle, len);
9932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309933 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9934 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309935 }
9936 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9937 cmd = (wmi_nan_cmd_param *) buf_ptr;
9938 WMITLV_SET_HDR(&cmd->tlv_header,
9939 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9940 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9941 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309942 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309943 __func__, nan_req->request_data_len);
9944 buf_ptr += sizeof(wmi_nan_cmd_param);
9945 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9946 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309947 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309948
9949 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9950 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309951 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309952 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309953 __func__, ret);
9954 wmi_buf_free(buf);
9955 }
9956
9957 return ret;
9958}
9959
9960/**
9961 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9962 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009963 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309964 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309965 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309966 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009967static QDF_STATUS
9968send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9969 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309970{
9971 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9972 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309973 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309974
9975 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9976 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309977 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309978 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309979 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309980 }
9981
9982 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309983
9984 WMITLV_SET_HDR(&cmd->tlv_header,
9985 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9986 WMITLV_GET_STRUCT_TLVLEN
9987 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009988 cmd->vdev_id = params->vdev_id;
9989 cmd->enable = params->dhcp_offload_enabled;
9990 cmd->num_client = params->dhcp_client_num;
9991 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309992 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309993 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309994 sizeof(*cmd),
9995 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309996 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309997 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309998 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309999 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010000 }
Govind Singhb53420c2016-03-09 14:32:57 +053010001 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010002 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010003
10004 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010005}
10006
10007/**
10008 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10009 * @wmi_handle: wmi handle
10010 * @flashing: flashing request
10011 *
10012 * Return: CDF status
10013 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010014static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010015 struct flashing_req_params *flashing)
10016{
10017 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010018 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010019 wmi_buf_t buf;
10020 uint8_t *buf_ptr;
10021 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10022
10023 buf = wmi_buf_alloc(wmi_handle, len);
10024 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010025 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010026 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010027 }
10028 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10029 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10030 WMITLV_SET_HDR(&cmd->tlv_header,
10031 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10032 WMITLV_GET_STRUCT_TLVLEN
10033 (wmi_set_led_flashing_cmd_fixed_param));
10034 cmd->pattern_id = flashing->pattern_id;
10035 cmd->led_x0 = flashing->led_x0;
10036 cmd->led_x1 = flashing->led_x1;
10037
10038 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10039 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010040 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010041 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010042 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010043 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010044 }
Govind Singh67922e82016-04-01 16:48:57 +053010045
10046 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010047}
10048
10049/**
10050 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10051 * @wmi_handle: wmi handle
10052 * @ch_avoid_update_req: channel avoid update params
10053 *
10054 * Return: CDF status
10055 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010056static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010057{
Govind Singh67922e82016-04-01 16:48:57 +053010058 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010059 wmi_buf_t buf = NULL;
10060 uint8_t *buf_ptr;
10061 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10062 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10063
10064
10065 buf = wmi_buf_alloc(wmi_handle, len);
10066 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010067 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10068 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010069 }
10070
10071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10072 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10073 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10074 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10075 WMITLV_GET_STRUCT_TLVLEN
10076 (wmi_chan_avoid_update_cmd_param));
10077
10078 status = wmi_unified_cmd_send(wmi_handle, buf,
10079 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010080 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010081 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010082 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10083 " returned Error %d", status);
10084 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010085 }
10086
Govind Singh67922e82016-04-01 16:48:57 +053010087 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010088}
10089
10090/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010091 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10092 * @wmi_handle: wmi handle
10093 * @param: pointer to pdev regdomain params
10094 *
10095 * Return: 0 for success or error code
10096 */
10097static QDF_STATUS
10098send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10099 struct pdev_set_regdomain_params *param)
10100{
10101 wmi_buf_t buf;
10102 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10103 int32_t len = sizeof(*cmd);
10104
10105
10106 buf = wmi_buf_alloc(wmi_handle, len);
10107 if (!buf) {
10108 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10109 return QDF_STATUS_E_NOMEM;
10110 }
10111 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10112 WMITLV_SET_HDR(&cmd->tlv_header,
10113 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10114 WMITLV_GET_STRUCT_TLVLEN
10115 (wmi_pdev_set_regdomain_cmd_fixed_param));
10116
10117 cmd->reg_domain = param->currentRDinuse;
10118 cmd->reg_domain_2G = param->currentRD2G;
10119 cmd->reg_domain_5G = param->currentRD5G;
10120 cmd->conformance_test_limit_2G = param->ctl_2G;
10121 cmd->conformance_test_limit_5G = param->ctl_5G;
10122 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010123 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10124 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010125
10126 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10127 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10128 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10129 __func__);
10130 wmi_buf_free(buf);
10131 return QDF_STATUS_E_FAILURE;
10132 }
10133
10134 return QDF_STATUS_SUCCESS;
10135}
10136
10137/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010138 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10139 * @wmi_handle: wmi handle
10140 * @reg_dmn: reg domain
10141 * @regdmn2G: 2G reg domain
10142 * @regdmn5G: 5G reg domain
10143 * @ctl2G: 2G test limit
10144 * @ctl5G: 5G test limit
10145 *
10146 * Return: none
10147 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010148static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010149 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010150 uint16_t regdmn5G, uint8_t ctl2G,
10151 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010152{
10153 wmi_buf_t buf;
10154 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10155 int32_t len = sizeof(*cmd);
10156
10157
10158 buf = wmi_buf_alloc(wmi_handle, len);
10159 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010160 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10161 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010162 }
10163 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10164 WMITLV_SET_HDR(&cmd->tlv_header,
10165 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10166 WMITLV_GET_STRUCT_TLVLEN
10167 (wmi_pdev_set_regdomain_cmd_fixed_param));
10168 cmd->reg_domain = reg_dmn;
10169 cmd->reg_domain_2G = regdmn2G;
10170 cmd->reg_domain_5G = regdmn5G;
10171 cmd->conformance_test_limit_2G = ctl2G;
10172 cmd->conformance_test_limit_5G = ctl5G;
10173
10174 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10175 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010176 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010177 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010178 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010179 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010180 }
10181
Govind Singhb53420c2016-03-09 14:32:57 +053010182 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010183}
10184
10185
10186/**
10187 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10188 * @wmi_handle: wmi handle
10189 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10190 *
10191 * This function sets tdls off channel mode
10192 *
10193 * Return: 0 on success; Negative errno otherwise
10194 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010195static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010196 struct tdls_channel_switch_params *chan_switch_params)
10197{
10198 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10199 wmi_buf_t wmi_buf;
10200 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10201
10202 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10203 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010204 WMI_LOGE(FL("wmi_buf_alloc failed"));
10205 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010206 }
10207 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10208 wmi_buf_data(wmi_buf);
10209 WMITLV_SET_HDR(&cmd->tlv_header,
10210 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10211 WMITLV_GET_STRUCT_TLVLEN(
10212 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10213
10214 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10215 &cmd->peer_macaddr);
10216 cmd->vdev_id = chan_switch_params->vdev_id;
10217 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10218 cmd->is_peer_responder = chan_switch_params->is_responder;
10219 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10220 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10221 cmd->offchan_oper_class = chan_switch_params->oper_class;
10222
Govind Singhb53420c2016-03-09 14:32:57 +053010223 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010224 cmd->peer_macaddr.mac_addr31to0,
10225 cmd->peer_macaddr.mac_addr47to32);
10226
Govind Singhb53420c2016-03-09 14:32:57 +053010227 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010228 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10229 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10230 ),
10231 cmd->vdev_id,
10232 cmd->offchan_mode,
10233 cmd->offchan_num,
10234 cmd->offchan_bw_bitmap,
10235 cmd->is_peer_responder,
10236 cmd->offchan_oper_class);
10237
10238 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10239 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010240 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010241 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010242 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010243 }
10244
10245
Govind Singhb53420c2016-03-09 14:32:57 +053010246 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010247}
10248
10249/**
10250 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10251 * @wmi_handle: wmi handle
10252 * @pwmaTdlsparams: TDLS params
10253 *
10254 * Return: 0 for sucess or error code
10255 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010256static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010257 void *tdls_param, uint8_t tdls_state)
10258{
10259 wmi_tdls_set_state_cmd_fixed_param *cmd;
10260 wmi_buf_t wmi_buf;
10261
10262 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10263 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10264
10265 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10266 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010267 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10268 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010269 }
10270 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10271 WMITLV_SET_HDR(&cmd->tlv_header,
10272 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10273 WMITLV_GET_STRUCT_TLVLEN
10274 (wmi_tdls_set_state_cmd_fixed_param));
10275 cmd->vdev_id = wmi_tdls->vdev_id;
10276 cmd->state = tdls_state;
10277 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10278 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10279 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10280 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10281 cmd->rssi_delta = wmi_tdls->rssi_delta;
10282 cmd->tdls_options = wmi_tdls->tdls_options;
10283 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10284 cmd->tdls_peer_traffic_response_timeout_ms =
10285 wmi_tdls->peer_traffic_response_timeout;
10286 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10287 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10288 cmd->tdls_puapsd_rx_frame_threshold =
10289 wmi_tdls->puapsd_rx_frame_threshold;
10290 cmd->teardown_notification_ms =
10291 wmi_tdls->teardown_notification_ms;
10292 cmd->tdls_peer_kickout_threshold =
10293 wmi_tdls->tdls_peer_kickout_threshold;
10294
Govind Singhb53420c2016-03-09 14:32:57 +053010295 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010296 "notification_interval_ms: %d, "
10297 "tx_discovery_threshold: %d, "
10298 "tx_teardown_threshold: %d, "
10299 "rssi_teardown_threshold: %d, "
10300 "rssi_delta: %d, "
10301 "tdls_options: 0x%x, "
10302 "tdls_peer_traffic_ind_window: %d, "
10303 "tdls_peer_traffic_response_timeout: %d, "
10304 "tdls_puapsd_mask: 0x%x, "
10305 "tdls_puapsd_inactivity_time: %d, "
10306 "tdls_puapsd_rx_frame_threshold: %d, "
10307 "teardown_notification_ms: %d, "
10308 "tdls_peer_kickout_threshold: %d",
10309 __func__, tdls_state, cmd->state,
10310 cmd->notification_interval_ms,
10311 cmd->tx_discovery_threshold,
10312 cmd->tx_teardown_threshold,
10313 cmd->rssi_teardown_threshold,
10314 cmd->rssi_delta,
10315 cmd->tdls_options,
10316 cmd->tdls_peer_traffic_ind_window,
10317 cmd->tdls_peer_traffic_response_timeout_ms,
10318 cmd->tdls_puapsd_mask,
10319 cmd->tdls_puapsd_inactivity_time_ms,
10320 cmd->tdls_puapsd_rx_frame_threshold,
10321 cmd->teardown_notification_ms,
10322 cmd->tdls_peer_kickout_threshold);
10323
10324 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10325 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010326 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010327 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010328 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010329 }
Govind Singhb53420c2016-03-09 14:32:57 +053010330 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010331
Govind Singhb53420c2016-03-09 14:32:57 +053010332 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010333}
10334
10335/**
10336 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10337 * @wmi_handle: wmi handle
10338 * @peerStateParams: TDLS peer state params
10339 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010340 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010341 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010342static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010343 struct tdls_peer_state_params *peerStateParams,
10344 uint32_t *ch_mhz)
10345{
10346 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10347 wmi_tdls_peer_capabilities *peer_cap;
10348 wmi_channel *chan_info;
10349 wmi_buf_t wmi_buf;
10350 uint8_t *buf_ptr;
10351 uint32_t i;
10352 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10353 sizeof(wmi_tdls_peer_capabilities);
10354
10355
10356 len += WMI_TLV_HDR_SIZE +
10357 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10358
10359 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10360 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010361 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10362 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010363 }
10364
10365 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10366 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10367 WMITLV_SET_HDR(&cmd->tlv_header,
10368 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10369 WMITLV_GET_STRUCT_TLVLEN
10370 (wmi_tdls_peer_update_cmd_fixed_param));
10371
10372 cmd->vdev_id = peerStateParams->vdevId;
10373 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10374 &cmd->peer_macaddr);
10375
10376
10377 cmd->peer_state = peerStateParams->peerState;
10378
Govind Singhb53420c2016-03-09 14:32:57 +053010379 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010380 "peer_macaddr.mac_addr31to0: 0x%x, "
10381 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10382 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10383 cmd->peer_macaddr.mac_addr31to0,
10384 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10385
10386 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10387 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10388 WMITLV_SET_HDR(&peer_cap->tlv_header,
10389 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10390 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10391
10392 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10393 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10394 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10395 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10396 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10397 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10398 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10399 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10400
10401 /* Ack and More Data Ack are sent as 0, so no need to set
10402 * but fill SP
10403 */
10404 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10405 peerStateParams->peerCap.peerMaxSp);
10406
10407 peer_cap->buff_sta_support =
10408 peerStateParams->peerCap.peerBuffStaSupport;
10409 peer_cap->off_chan_support =
10410 peerStateParams->peerCap.peerOffChanSupport;
10411 peer_cap->peer_curr_operclass =
10412 peerStateParams->peerCap.peerCurrOperClass;
10413 /* self curr operclass is not being used and so pass op class for
10414 * preferred off chan in it.
10415 */
10416 peer_cap->self_curr_operclass =
10417 peerStateParams->peerCap.opClassForPrefOffChan;
10418 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10419 peer_cap->peer_operclass_len =
10420 peerStateParams->peerCap.peerOperClassLen;
10421
Govind Singhb53420c2016-03-09 14:32:57 +053010422 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010423 __func__, peer_cap->peer_operclass_len);
10424 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10425 peer_cap->peer_operclass[i] =
10426 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010427 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010428 __func__, i, peer_cap->peer_operclass[i]);
10429 }
10430
10431 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10432 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10433 peer_cap->pref_offchan_bw =
10434 peerStateParams->peerCap.prefOffChanBandwidth;
10435
Govind Singhb53420c2016-03-09 14:32:57 +053010436 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010437 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10438 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10439 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10440 " %d, pref_offchan_bw: %d",
10441 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10442 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10443 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10444 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10445 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10446
10447 /* next fill variable size array of peer chan info */
10448 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10449 WMITLV_SET_HDR(buf_ptr,
10450 WMITLV_TAG_ARRAY_STRUC,
10451 sizeof(wmi_channel) *
10452 peerStateParams->peerCap.peerChanLen);
10453 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10454
10455 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10456 WMITLV_SET_HDR(&chan_info->tlv_header,
10457 WMITLV_TAG_STRUC_wmi_channel,
10458 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10459 chan_info->mhz = ch_mhz[i];
10460 chan_info->band_center_freq1 = chan_info->mhz;
10461 chan_info->band_center_freq2 = 0;
10462
Govind Singhb53420c2016-03-09 14:32:57 +053010463 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010464
10465 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10466 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010467 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010468 peerStateParams->peerCap.peerChan[i].chanId,
10469 peerStateParams->peerCap.peerChan[i].dfsSet);
10470 }
10471
10472 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10473 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10474 else
10475 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10476
10477 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10478 peerStateParams->peerCap.
10479 peerChan[i].pwr);
10480
10481 WMI_SET_CHANNEL_REG_POWER(chan_info,
10482 peerStateParams->peerCap.peerChan[i].
10483 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010484 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010485 peerStateParams->peerCap.peerChan[i].pwr);
10486
10487 chan_info++;
10488 }
10489
10490 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10491 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010492 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010493 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010494 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010495 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010496 }
10497
10498
Govind Singhb53420c2016-03-09 14:32:57 +053010499 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010500}
10501
10502/*
10503 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
10504 * firmware
10505 * @wmi_handle: Pointer to wmi handle
10506 * @mem_dump_req: Pointer for mem_dump_req
10507 *
10508 * This function sends memory dump request to firmware
10509 *
Govind Singhb53420c2016-03-09 14:32:57 +053010510 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010511 *
10512 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010513static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010514 struct fw_dump_req_param *mem_dump_req)
10515{
10516 wmi_get_fw_mem_dump_fixed_param *cmd;
10517 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +053010518 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +053010519 int32_t len;
10520 wmi_buf_t buf;
10521 u_int8_t *buf_ptr;
10522 int ret, loop;
10523
10524 /*
10525 * len = sizeof(fixed param) that includes tlv header +
10526 * tlv header for array of struc +
10527 * sizeof (each struct)
10528 */
10529 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10530 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
10531 buf = wmi_buf_alloc(wmi_handle, len);
10532
10533 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010534 WMI_LOGE(FL("Failed allocate wmi buffer"));
10535 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010536 }
10537
10538 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010539 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010540 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
10541
10542 WMITLV_SET_HDR(&cmd->tlv_header,
10543 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
10544 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
10545
10546 cmd->request_id = mem_dump_req->request_id;
10547 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
10548
10549 /* TLV indicating array of structures to follow */
10550 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
10551 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10552 sizeof(wmi_fw_mem_dump) *
10553 cmd->num_fw_mem_dump_segs);
10554
10555 buf_ptr += WMI_TLV_HDR_SIZE;
10556 dump_params = (wmi_fw_mem_dump *) buf_ptr;
10557
Govind Singhb53420c2016-03-09 14:32:57 +053010558 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010559 mem_dump_req->request_id, mem_dump_req->num_seg);
10560 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +053010561 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +053010562 ((uint8_t *)(mem_dump_req->segment) +
10563 loop * sizeof(*seg_req));
10564 WMITLV_SET_HDR(&dump_params->tlv_header,
10565 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
10566 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
10567 dump_params->seg_id = seg_req->seg_id;
10568 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
10569 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
10570 dump_params->seg_length = seg_req->seg_length;
10571 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
10572 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +053010573 WMI_LOGI(FL("seg_number:%d"), loop);
10574 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010575 dump_params->seg_id, dump_params->seg_start_addr_lo,
10576 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +053010577 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010578 dump_params->seg_length, dump_params->dest_addr_lo,
10579 dump_params->dest_addr_hi);
10580 dump_params++;
10581 }
10582
10583 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10584 WMI_GET_FW_MEM_DUMP_CMDID);
10585 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010586 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +053010587 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010588 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010589 }
10590
Govind Singhb53420c2016-03-09 14:32:57 +053010591 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
10592 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010593}
10594
10595/*
10596 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10597 * @wmi_handle: Pointer to WMi handle
10598 * @ie_data: Pointer for ie data
10599 *
10600 * This function sends IE information to firmware
10601 *
Govind Singhb53420c2016-03-09 14:32:57 +053010602 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010603 *
10604 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010605static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010606 struct vdev_ie_info_param *ie_info)
10607{
10608 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10609 wmi_buf_t buf;
10610 uint8_t *buf_ptr;
10611 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010612 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010613
10614
10615 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10616 /* Allocate memory for the WMI command */
10617 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10618
10619 buf = wmi_buf_alloc(wmi_handle, len);
10620 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010621 WMI_LOGE(FL("wmi_buf_alloc failed"));
10622 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010623 }
10624
10625 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010626 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010627
10628 /* Populate the WMI command */
10629 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10630
10631 WMITLV_SET_HDR(&cmd->tlv_header,
10632 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10633 WMITLV_GET_STRUCT_TLVLEN(
10634 wmi_vdev_set_ie_cmd_fixed_param));
10635 cmd->vdev_id = ie_info->vdev_id;
10636 cmd->ie_id = ie_info->ie_id;
10637 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010638 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010639
Govind Singhb53420c2016-03-09 14:32:57 +053010640 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010641 ie_info->length, ie_info->vdev_id);
10642
10643 buf_ptr += sizeof(*cmd);
10644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10645 buf_ptr += WMI_TLV_HDR_SIZE;
10646
Govind Singhb53420c2016-03-09 14:32:57 +053010647 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010648
10649 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10650 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010651 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010652 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010653 wmi_buf_free(buf);
10654 }
10655
10656 return ret;
10657}
10658
Sathish Kumar497bef42017-03-01 14:02:36 +053010659/**
10660 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10661 *
10662 * @param wmi_handle : handle to WMI.
10663 * @param param : pointer to antenna param
10664 *
10665 * This function sends smart antenna enable command to FW
10666 *
10667 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10668 */
10669static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10670 struct smart_ant_enable_params *param)
10671{
10672 /* Send WMI COMMAND to Enable */
10673 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10674 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10675 wmi_buf_t buf;
10676 uint8_t *buf_ptr;
10677 int len = 0;
10678 QDF_STATUS ret;
10679 int loop = 0;
10680
10681 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10682 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10683 buf = wmi_buf_alloc(wmi_handle, len);
10684
10685 if (!buf) {
10686 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10687 return QDF_STATUS_E_NOMEM;
10688 }
10689
10690 buf_ptr = wmi_buf_data(buf);
10691 qdf_mem_zero(buf_ptr, len);
10692 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10693
10694 WMITLV_SET_HDR(&cmd->tlv_header,
10695 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10696 WMITLV_GET_STRUCT_TLVLEN(
10697 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10698
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010699 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10700 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010701 cmd->enable = param->enable;
10702 cmd->mode = param->mode;
10703 cmd->rx_antenna = param->rx_antenna;
10704 cmd->tx_default_antenna = param->rx_antenna;
10705
10706 /* TLV indicating array of structures to follow */
10707 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10708 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10709 WMI_HAL_MAX_SANTENNA *
10710 sizeof(wmi_pdev_smart_ant_gpio_handle));
10711
10712 buf_ptr += WMI_TLV_HDR_SIZE;
10713 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10714
10715 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10716 WMITLV_SET_HDR(&gpio_param->tlv_header,
10717 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10718 WMITLV_GET_STRUCT_TLVLEN(
10719 wmi_pdev_smart_ant_gpio_handle));
10720 if (param->mode == SMART_ANT_MODE_SERIAL) {
10721 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10722 gpio_param->gpio_pin = param->gpio_pin[loop];
10723 gpio_param->gpio_func = param->gpio_func[loop];
10724 } else {
10725 gpio_param->gpio_pin = 0;
10726 gpio_param->gpio_func = 0;
10727 }
10728 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10729 gpio_param->gpio_pin = param->gpio_pin[loop];
10730 gpio_param->gpio_func = param->gpio_func[loop];
10731 }
10732 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010733 gpio_param->pdev_id =
10734 wmi_handle->ops->convert_pdev_id_host_to_target(
10735 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010736 gpio_param++;
10737 }
10738
10739 ret = wmi_unified_cmd_send(wmi_handle,
10740 buf,
10741 len,
10742 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10743
10744 if (ret != 0) {
10745 WMI_LOGE(" %s :WMI Failed\n", __func__);
10746 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10747 cmd->enable,
10748 cmd->mode,
10749 cmd->rx_antenna,
10750 param->gpio_pin[0], param->gpio_pin[1],
10751 param->gpio_pin[2], param->gpio_pin[3],
10752 param->gpio_func[0], param->gpio_func[1],
10753 param->gpio_func[2], param->gpio_func[3],
10754 ret);
10755 wmi_buf_free(buf);
10756 }
10757
10758 return ret;
10759}
10760
10761/**
10762 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10763 *
10764 * @param wmi_handle : handle to WMI.
10765 * @param param : pointer to rx antenna param
10766 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10767 */
10768static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10769 struct smart_ant_rx_ant_params *param)
10770{
10771 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10772 wmi_buf_t buf;
10773 uint8_t *buf_ptr;
10774 uint32_t len;
10775 QDF_STATUS ret;
10776
10777 len = sizeof(*cmd);
10778 buf = wmi_buf_alloc(wmi_handle, len);
10779 WMI_LOGD("%s:\n", __func__);
10780 if (!buf) {
10781 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10782 return QDF_STATUS_E_NOMEM;
10783 }
10784
10785 buf_ptr = wmi_buf_data(buf);
10786 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10787 WMITLV_SET_HDR(&cmd->tlv_header,
10788 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10789 WMITLV_GET_STRUCT_TLVLEN(
10790 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10791 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010792 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10793 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010794
10795 ret = wmi_unified_cmd_send(wmi_handle,
10796 buf,
10797 len,
10798 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10799
10800 if (ret != 0) {
10801 WMI_LOGE(" %s :WMI Failed\n", __func__);
10802 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10803 __func__,
10804 cmd->rx_antenna,
10805 ret);
10806 wmi_buf_free(buf);
10807 }
10808
10809 return ret;
10810}
10811
10812/**
10813 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10814 * @wmi_handle: wmi handle
10815 * @param: pointer to hold ctl table param
10816 *
10817 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10818 */
10819static QDF_STATUS
10820send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10821 struct ctl_table_params *param)
10822{
10823 uint16_t len, ctl_tlv_len;
10824 uint8_t *buf_ptr;
10825 wmi_buf_t buf;
10826 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10827 uint32_t *ctl_array;
10828
10829 if (!param->ctl_array)
10830 return QDF_STATUS_E_FAILURE;
10831
10832 if (param->ctl_cmd_len !=
10833 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10834 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
10835 qdf_print("CTL array len not correct\n");
10836 return QDF_STATUS_E_FAILURE;
10837 }
10838
10839 ctl_tlv_len = WMI_TLV_HDR_SIZE +
10840 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
10841 len = sizeof(*cmd) + ctl_tlv_len;
10842
10843 buf = wmi_buf_alloc(wmi_handle, len);
10844 if (!buf) {
10845 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10846 return QDF_STATUS_E_FAILURE;
10847 }
10848
10849 buf_ptr = wmi_buf_data(buf);
10850 qdf_mem_zero(buf_ptr, len);
10851
10852 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10853
10854 WMITLV_SET_HDR(&cmd->tlv_header,
10855 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10856 WMITLV_GET_STRUCT_TLVLEN(
10857 wmi_pdev_set_ctl_table_cmd_fixed_param));
10858 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010859 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10860 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010861
10862 buf_ptr += sizeof(*cmd);
10863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10864 (cmd->ctl_len));
10865 buf_ptr += WMI_TLV_HDR_SIZE;
10866 ctl_array = (uint32_t *)buf_ptr;
10867
10868 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10869 sizeof(param->ctl_band));
10870 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10871 param->ctl_cmd_len -
10872 sizeof(param->ctl_band));
10873
10874 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10875 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10876 WMI_LOGE("%s:Failed to send command\n", __func__);
10877 wmi_buf_free(buf);
10878 return QDF_STATUS_E_FAILURE;
10879 }
10880
10881 return QDF_STATUS_SUCCESS;
10882}
10883
10884/**
10885 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10886 * @wmi_handle: wmi handle
10887 * @param: pointer to hold mimogain table param
10888 *
10889 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10890 */
10891static QDF_STATUS
10892send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10893 struct mimogain_table_params *param)
10894{
10895 uint16_t len, table_tlv_len;
10896 wmi_buf_t buf;
10897 uint8_t *buf_ptr;
10898 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10899 uint32_t *gain_table;
10900
10901 if (!param->array_gain)
10902 return QDF_STATUS_E_FAILURE;
10903
10904 /* len must be multiple of a single array gain table */
10905 if (param->tbl_len %
10906 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10907 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10908 WMI_LOGE("Array gain table len not correct\n");
10909 return QDF_STATUS_E_FAILURE;
10910 }
10911
10912 table_tlv_len = WMI_TLV_HDR_SIZE +
10913 roundup(param->tbl_len, sizeof(uint32_t));
10914 len = sizeof(*cmd) + table_tlv_len;
10915
10916 buf = wmi_buf_alloc(wmi_handle, len);
10917 if (!buf) {
10918 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10919 return QDF_STATUS_E_FAILURE;
10920 }
10921
10922 buf_ptr = wmi_buf_data(buf);
10923 qdf_mem_zero(buf_ptr, len);
10924
10925 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10926
10927 WMITLV_SET_HDR(&cmd->tlv_header,
10928 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10929 WMITLV_GET_STRUCT_TLVLEN(
10930 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10931
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010932 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10933 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010934 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10935 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10936 param->multichain_gain_bypass);
10937
10938 buf_ptr += sizeof(*cmd);
10939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10940 (param->tbl_len));
10941 buf_ptr += WMI_TLV_HDR_SIZE;
10942 gain_table = (uint32_t *)buf_ptr;
10943
10944 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10945 param->array_gain,
10946 param->tbl_len);
10947
10948 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10949 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10950 return QDF_STATUS_E_FAILURE;
10951 }
10952
10953 return QDF_STATUS_SUCCESS;
10954}
10955
10956/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010957 * enum packet_power_tlv_flags: target defined
10958 * packet power rate flags for TLV
10959 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10960 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10961 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10962 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10963 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10964 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10965 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10966 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10967 * @WMI_TLV_FLAG_STBC: STBC is set
10968 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10969 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10970 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10971 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10972 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10973 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10974 * @WMI_TLV_FLAG_LDPC: LDPC is set
10975 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10976 * @WMI_TLV_FLAG_SU: SU Data
10977 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10978 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10979 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10980 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10981 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10982 *
10983 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10984 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10985 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10986 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10987 */
10988enum packet_power_tlv_flags {
10989 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10990 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10991 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10992 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10993 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10994 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10995 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10996 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10997 WMI_TLV_FLAG_STBC = 0x00000100,
10998 WMI_TLV_FLAG_40MHZ = 0x00000200,
10999 WMI_TLV_FLAG_80MHZ = 0x00000300,
11000 WMI_TLV_FLAG_160MHZ = 0x00000400,
11001 WMI_TLV_FLAG_TXBF = 0x00000800,
11002 WMI_TLV_FLAG_RTSENA = 0x00001000,
11003 WMI_TLV_FLAG_CTSENA = 0x00002000,
11004 WMI_TLV_FLAG_LDPC = 0x00004000,
11005 WMI_TLV_FLAG_SGI = 0x00008000,
11006 WMI_TLV_FLAG_SU = 0x00100000,
11007 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11008 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11009 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11010 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11011 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11012
11013 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11014 WMI_TLV_FLAG_BW_MASK = 0x3,
11015 WMI_TLV_FLAG_BW_SHIFT = 9,
11016 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11017 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11018};
11019
11020/**
11021 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11022 * to FW understandable format
11023 * @param: pointer to hold packet power info param
11024 *
11025 * @return FW understandable 32 bit rate flags
11026 */
11027static uint32_t
11028convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11029{
11030 uint32_t rateflags = 0;
11031
11032 if (param->chainmask)
11033 rateflags |=
11034 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11035 if (param->chan_width)
11036 rateflags |=
11037 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11038 << WMI_TLV_FLAG_BW_SHIFT);
11039 if (param->su_mu_ofdma)
11040 rateflags |=
11041 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11042 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11043 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11044 rateflags |= WMI_TLV_FLAG_STBC;
11045 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11046 rateflags |= WMI_TLV_FLAG_LDPC;
11047 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11048 rateflags |= WMI_TLV_FLAG_TXBF;
11049 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11050 rateflags |= WMI_TLV_FLAG_RTSENA;
11051 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11052 rateflags |= WMI_TLV_FLAG_CTSENA;
11053 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11054 rateflags |= WMI_TLV_FLAG_SGI;
11055
11056 return rateflags;
11057}
11058
11059/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011060 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11061 * info to fw
11062 * @wmi_handle: wmi handle
11063 * @param: pointer to hold packet power info param
11064 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011065 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011066 */
11067static QDF_STATUS
11068send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11069 struct packet_power_info_params *param)
11070{
11071 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11072 wmi_buf_t wmibuf;
11073 uint8_t *buf_ptr;
11074 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11075
11076 wmibuf = wmi_buf_alloc(wmi_handle, len);
11077 if (wmibuf == NULL)
11078 return QDF_STATUS_E_NOMEM;
11079
11080 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11081
11082 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11083 WMITLV_SET_HDR(&cmd->tlv_header,
11084 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11085 WMITLV_GET_STRUCT_TLVLEN(
11086 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011087 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11088 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011089 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011090 cmd->nss = param->nss;
11091 cmd->preamble = param->preamble;
11092 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011093
11094 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11095 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11096 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11097 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11098
Sathish Kumar497bef42017-03-01 14:02:36 +053011099 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11100 WMI_PDEV_GET_TPC_CMDID)) {
11101 WMI_LOGE(FL("Failed to get tpc command\n"));
11102 wmi_buf_free(wmibuf);
11103 return QDF_STATUS_E_FAILURE;
11104 }
11105
11106 return QDF_STATUS_SUCCESS;
11107}
11108
11109/**
11110 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11111 * @wmi_handle: wmi handle
11112 * @param: pointer to hold config ratemask params
11113 *
11114 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11115 */
11116static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11117 struct config_ratemask_params *param)
11118{
11119 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11120 wmi_buf_t buf;
11121 int32_t len = sizeof(*cmd);
11122
11123 buf = wmi_buf_alloc(wmi_handle, len);
11124 if (!buf) {
11125 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11126 return QDF_STATUS_E_FAILURE;
11127 }
11128 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11129 WMITLV_SET_HDR(&cmd->tlv_header,
11130 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11131 WMITLV_GET_STRUCT_TLVLEN(
11132 wmi_vdev_config_ratemask_cmd_fixed_param));
11133 cmd->vdev_id = param->vdev_id;
11134 cmd->type = param->type;
11135 cmd->mask_lower32 = param->lower32;
11136 cmd->mask_higher32 = param->higher32;
11137 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11138 param->vdev_id, param->type, param->lower32, param->higher32);
11139
11140 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11141 WMI_VDEV_RATEMASK_CMDID)) {
11142 WMI_LOGE("Seting vdev ratemask failed\n");
11143 wmi_buf_free(buf);
11144 return QDF_STATUS_E_FAILURE;
11145 }
11146
11147 return QDF_STATUS_SUCCESS;
11148}
11149
11150/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011151 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11152 * @param: param sent from the host side
11153 * @cmd: param to be sent to the fw side
11154 */
11155static inline void copy_custom_aggr_bitmap(
11156 struct set_custom_aggr_size_params *param,
11157 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11158{
11159 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11160 param->ac);
11161 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11162 param->aggr_type);
11163 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11164 param->tx_aggr_size_disable);
11165 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11166 param->rx_aggr_size_disable);
11167 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11168 param->tx_ac_enable);
11169}
11170
11171/**
11172 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11173 * @wmi_handle: wmi handle
11174 * @param: pointer to hold custom aggr size params
11175 *
11176 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11177 */
11178static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11179 wmi_unified_t wmi_handle,
11180 struct set_custom_aggr_size_params *param)
11181{
11182 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11183 wmi_buf_t buf;
11184 int32_t len = sizeof(*cmd);
11185
11186 buf = wmi_buf_alloc(wmi_handle, len);
11187 if (!buf) {
11188 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11189 return QDF_STATUS_E_FAILURE;
11190 }
11191 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11192 wmi_buf_data(buf);
11193 WMITLV_SET_HDR(&cmd->tlv_header,
11194 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11195 WMITLV_GET_STRUCT_TLVLEN(
11196 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11197 cmd->vdev_id = param->vdev_id;
11198 cmd->tx_aggr_size = param->tx_aggr_size;
11199 cmd->rx_aggr_size = param->rx_aggr_size;
11200 copy_custom_aggr_bitmap(param, cmd);
11201
11202 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11203 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11204 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11205 "tx_ac_enable=0x%X\n",
11206 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11207 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11208 param->rx_aggr_size_disable, param->tx_ac_enable);
11209
11210 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11211 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11212 WMI_LOGE("Seting custom aggregation size failed\n");
11213 wmi_buf_free(buf);
11214 return QDF_STATUS_E_FAILURE;
11215 }
11216
11217 return QDF_STATUS_SUCCESS;
11218}
11219
11220/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011221 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11222 * @param wmi_handle : handle to WMI.
11223 * @param param : pointer to tx antenna param
11224 *
11225 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11226 */
11227
11228static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11229 struct set_qdepth_thresh_params *param)
11230{
11231 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11232 wmi_msduq_qdepth_thresh_update *cmd_update;
11233 wmi_buf_t buf;
11234 int32_t len = 0;
11235 int i;
11236 uint8_t *buf_ptr;
11237 QDF_STATUS ret;
11238
11239 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11240 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11241 return QDF_STATUS_E_INVAL;
11242 }
11243
11244 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11245 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11246 param->num_of_msduq_updates);
11247 buf = wmi_buf_alloc(wmi_handle, len);
11248
11249 if (!buf) {
11250 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11251 return QDF_STATUS_E_NOMEM;
11252 }
11253
11254 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11255 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11256 buf_ptr;
11257
11258 WMITLV_SET_HDR(&cmd->tlv_header,
11259 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11260 , WMITLV_GET_STRUCT_TLVLEN(
11261 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11262
11263 cmd->pdev_id =
11264 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11265 cmd->vdev_id = param->vdev_id;
11266 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11267 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11268
11269 buf_ptr += sizeof(
11270 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11271 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11272 param->num_of_msduq_updates *
11273 sizeof(wmi_msduq_qdepth_thresh_update));
11274 buf_ptr += WMI_TLV_HDR_SIZE;
11275 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11276
11277 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11278 WMITLV_SET_HDR(&cmd_update->tlv_header,
11279 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11280 WMITLV_GET_STRUCT_TLVLEN(
11281 wmi_msduq_qdepth_thresh_update));
11282 cmd_update->tid_num = param->update_params[i].tid_num;
11283 cmd_update->msduq_update_mask =
11284 param->update_params[i].msduq_update_mask;
11285 cmd_update->qdepth_thresh_value =
11286 param->update_params[i].qdepth_thresh_value;
11287 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11288 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11289 " update mask=0x%X thresh val=0x%X\n",
11290 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11291 cmd->peer_mac_address.mac_addr31to0,
11292 cmd->peer_mac_address.mac_addr47to32,
11293 cmd_update->msduq_update_mask,
11294 cmd_update->qdepth_thresh_value);
11295 cmd_update++;
11296 }
11297
11298 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11299 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11300
11301 if (ret != 0) {
11302 WMI_LOGE(" %s :WMI Failed\n", __func__);
11303 wmi_buf_free(buf);
11304 }
11305
11306 return ret;
11307}
11308
11309/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011310 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11311 * @wmi_handle: wmi handle
11312 * @param: pointer to hold vap dscp tid map param
11313 *
11314 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11315 */
11316static QDF_STATUS
11317send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11318 struct vap_dscp_tid_map_params *param)
11319{
11320 wmi_buf_t buf;
11321 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11322 int32_t len = sizeof(*cmd);
11323
11324 buf = wmi_buf_alloc(wmi_handle, len);
11325 if (!buf) {
11326 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11327 return QDF_STATUS_E_FAILURE;
11328 }
11329
11330 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11331 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
11332 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
11333
11334 cmd->vdev_id = param->vdev_id;
11335 cmd->enable_override = 0;
11336
11337 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11338 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11339 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11340 WMI_LOGE("Failed to set dscp cmd\n");
11341 wmi_buf_free(buf);
11342 return QDF_STATUS_E_FAILURE;
11343 }
11344
11345 return QDF_STATUS_SUCCESS;
11346}
11347
11348/**
11349 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11350 * @wmi_handle: wmi handle
11351 * @macaddr: vdev mac address
11352 * @param: pointer to hold neigbour rx param
11353 *
11354 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11355 */
11356static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11357 uint8_t macaddr[IEEE80211_ADDR_LEN],
11358 struct set_neighbour_rx_params *param)
11359{
11360 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11361 wmi_buf_t buf;
11362 int32_t len = sizeof(*cmd);
11363
11364 buf = wmi_buf_alloc(wmi_handle, len);
11365 if (!buf) {
11366 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11367 return QDF_STATUS_E_FAILURE;
11368 }
11369 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11370 WMITLV_SET_HDR(&cmd->tlv_header,
11371 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11372 WMITLV_GET_STRUCT_TLVLEN(
11373 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11374 cmd->vdev_id = param->vdev_id;
11375 cmd->bssid_idx = param->idx;
11376 cmd->action = param->action;
11377 cmd->type = param->type;
11378 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11379 cmd->flag = 0;
11380
11381 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11382 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11383 WMI_LOGE("Failed to set neighbour rx param\n");
11384 wmi_buf_free(buf);
11385 return QDF_STATUS_E_FAILURE;
11386 }
11387
11388 return QDF_STATUS_SUCCESS;
11389}
11390
11391/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011392 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011393 * @param wmi_handle : handle to WMI.
11394 * @param macaddr : vdev mac address
11395 * @param param : pointer to tx antenna param
11396 *
11397 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11398 */
11399static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11400 uint8_t macaddr[IEEE80211_ADDR_LEN],
11401 struct smart_ant_tx_ant_params *param)
11402{
11403 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11404 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11405 wmi_buf_t buf;
11406 int32_t len = 0;
11407 int i;
11408 uint8_t *buf_ptr;
11409 QDF_STATUS ret;
11410
11411 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11412 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11413 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11414 buf = wmi_buf_alloc(wmi_handle, len);
11415
11416 if (!buf) {
11417 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11418 return QDF_STATUS_E_NOMEM;
11419 }
11420
11421 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11422 qdf_mem_zero(buf_ptr, len);
11423 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11424
11425 WMITLV_SET_HDR(&cmd->tlv_header,
11426 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11427 WMITLV_GET_STRUCT_TLVLEN(
11428 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11429
11430 cmd->vdev_id = param->vdev_id;
11431 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11432
11433 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11435 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11436 buf_ptr += WMI_TLV_HDR_SIZE;
11437 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11438
11439 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11440 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11441 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11442 WMITLV_GET_STRUCT_TLVLEN(
11443 wmi_peer_smart_ant_set_tx_antenna_series));
11444 ant_tx_series->antenna_series = param->antenna_array[i];
11445 ant_tx_series++;
11446 }
11447
11448 ret = wmi_unified_cmd_send(wmi_handle,
11449 buf,
11450 len,
11451 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11452
11453 if (ret != 0) {
11454 WMI_LOGE(" %s :WMI Failed\n", __func__);
11455 wmi_buf_free(buf);
11456 }
11457
11458 return ret;
11459}
11460
Sathish Kumar02c3b542017-02-22 17:24:45 +053011461/**
11462 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11463 * @wmi_handle: wmi handle
11464 * @param: pointer to hold ant switch tbl param
11465 *
11466 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11467 */
11468static QDF_STATUS
11469send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11470 struct ant_switch_tbl_params *param)
11471{
11472 uint8_t len;
11473 wmi_buf_t buf;
11474 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11475 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11476 uint8_t *buf_ptr;
11477
11478 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11479 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11480 buf = wmi_buf_alloc(wmi_handle, len);
11481
11482 if (!buf) {
11483 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11484 return QDF_STATUS_E_NOMEM;
11485 }
11486
11487 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11488 qdf_mem_zero(buf_ptr, len);
11489 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11490
11491 WMITLV_SET_HDR(&cmd->tlv_header,
11492 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11493 WMITLV_GET_STRUCT_TLVLEN(
11494 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11495
11496 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11497 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011498 cmd->mac_id =
11499 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011500
11501 /* TLV indicating array of structures to follow */
11502 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11503 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11504 sizeof(wmi_pdev_set_ant_ctrl_chain));
11505 buf_ptr += WMI_TLV_HDR_SIZE;
11506 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11507
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011508 ctrl_chain->pdev_id =
11509 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011510 ctrl_chain->antCtrlChain = param->antCtrlChain;
11511
11512 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11513 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11514 wmi_buf_free(buf);
11515 return QDF_STATUS_E_FAILURE;
11516 }
11517
11518 return QDF_STATUS_SUCCESS;
11519}
11520
11521/**
11522 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11523 * training information function
11524 * @param wmi_handle : handle to WMI.
11525 * @macaddr : vdev mac address
11526 * @param param : pointer to tx antenna param
11527 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11528 */
11529static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11530 wmi_unified_t wmi_handle,
11531 uint8_t macaddr[IEEE80211_ADDR_LEN],
11532 struct smart_ant_training_info_params *param)
11533{
11534 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11535 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11536 wmi_buf_t buf;
11537 uint8_t *buf_ptr;
11538 int32_t len = 0;
11539 QDF_STATUS ret;
11540 int loop;
11541
11542 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11543 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11544 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11545 buf = wmi_buf_alloc(wmi_handle, len);
11546
11547 if (!buf) {
11548 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11549 return QDF_STATUS_E_NOMEM;
11550 }
11551
11552 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11553 qdf_mem_zero(buf_ptr, len);
11554 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11555
11556 WMITLV_SET_HDR(&cmd->tlv_header,
11557 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11558 WMITLV_GET_STRUCT_TLVLEN(
11559 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11560
11561 cmd->vdev_id = param->vdev_id;
11562 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11563 cmd->num_pkts = param->numpkts;
11564
11565 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11566 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11567 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11568 WMI_SMART_ANT_MAX_RATE_SERIES);
11569
11570 buf_ptr += WMI_TLV_HDR_SIZE;
11571 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11572
11573 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11574 WMITLV_SET_HDR(&train_param->tlv_header,
11575 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11576 WMITLV_GET_STRUCT_TLVLEN(
11577 wmi_peer_smart_ant_set_train_antenna_param));
11578 train_param->train_rate_series = param->rate_array[loop];
11579 train_param->train_antenna_series = param->antenna_array[loop];
11580 train_param->rc_flags = 0;
11581 WMI_LOGI(FL("Series number:%d\n"), loop);
11582 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11583 train_param->train_rate_series,
11584 train_param->train_antenna_series);
11585 train_param++;
11586 }
11587
11588 ret = wmi_unified_cmd_send(wmi_handle,
11589 buf,
11590 len,
11591 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11592
11593 if (ret != 0) {
11594 WMI_LOGE(" %s :WMI Failed\n", __func__);
11595 wmi_buf_free(buf);
11596 return QDF_STATUS_E_FAILURE;
11597 }
11598
11599 return ret;
11600}
11601
11602/**
11603 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11604 * configuration function
11605 * @param wmi_handle : handle to WMI.
11606 * @macaddr : vdev mad address
11607 * @param param : pointer to tx antenna param
11608 *
11609 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11610 */
11611static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11612 wmi_unified_t wmi_handle,
11613 uint8_t macaddr[IEEE80211_ADDR_LEN],
11614 struct smart_ant_node_config_params *param)
11615{
11616 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11617 wmi_buf_t buf;
11618 uint8_t *buf_ptr;
11619 int32_t len = 0, args_tlv_len;
11620 int ret;
11621 int i = 0;
11622 A_UINT32 *node_config_args;
11623
11624 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
11625 len = sizeof(*cmd) + args_tlv_len;
11626
11627 if ((param->args_count == 0)) {
11628 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11629 __func__, param->args_count);
11630 return QDF_STATUS_E_FAILURE;
11631 }
11632
11633 buf = wmi_buf_alloc(wmi_handle, len);
11634 if (!buf) {
11635 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11636 return QDF_STATUS_E_NOMEM;
11637 }
11638
11639 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11640 wmi_buf_data(buf);
11641 buf_ptr = (uint8_t *)cmd;
11642 WMITLV_SET_HDR(&cmd->tlv_header,
11643 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11644 WMITLV_GET_STRUCT_TLVLEN(
11645 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11646 cmd->vdev_id = param->vdev_id;
11647 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11648 cmd->cmd_id = param->cmd_id;
11649 cmd->args_count = param->args_count;
11650 buf_ptr += sizeof(
11651 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11652 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11653 (cmd->args_count * sizeof(A_UINT32)));
11654 buf_ptr += WMI_TLV_HDR_SIZE;
11655 node_config_args = (A_UINT32 *)buf_ptr;
11656
11657 for (i = 0; i < param->args_count; i++) {
11658 node_config_args[i] = param->args_arr[i];
11659 WMI_LOGI("%d", param->args_arr[i]);
11660 }
11661
11662 ret = wmi_unified_cmd_send(wmi_handle,
11663 buf,
11664 len,
11665 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11666
11667 if (ret != 0) {
11668 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11669 __func__, param->cmd_id, macaddr[0],
11670 macaddr[1], macaddr[2], macaddr[3],
11671 macaddr[4], macaddr[5], ret);
11672 wmi_buf_free(buf);
11673 }
11674
11675 return ret;
11676}
11677
11678/**
11679 * send_set_atf_cmd_tlv() - send set atf command to fw
11680 * @wmi_handle: wmi handle
11681 * @param: pointer to set atf param
11682 *
11683 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11684 */
11685static QDF_STATUS
11686send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11687 struct set_atf_params *param)
11688{
11689 wmi_atf_peer_info *peer_info;
11690 wmi_peer_atf_request_fixed_param *cmd;
11691 wmi_buf_t buf;
11692 uint8_t *buf_ptr;
11693 int i;
11694 int32_t len = 0;
11695 QDF_STATUS retval;
11696
11697 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11698 len += param->num_peers * sizeof(wmi_atf_peer_info);
11699 buf = wmi_buf_alloc(wmi_handle, len);
11700 if (!buf) {
11701 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11702 return QDF_STATUS_E_FAILURE;
11703 }
11704 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11705 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11706 WMITLV_SET_HDR(&cmd->tlv_header,
11707 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11708 WMITLV_GET_STRUCT_TLVLEN(
11709 wmi_peer_atf_request_fixed_param));
11710 cmd->num_peers = param->num_peers;
11711
11712 buf_ptr += sizeof(*cmd);
11713 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11714 sizeof(wmi_atf_peer_info) *
11715 cmd->num_peers);
11716 buf_ptr += WMI_TLV_HDR_SIZE;
11717 peer_info = (wmi_atf_peer_info *)buf_ptr;
11718
11719 for (i = 0; i < cmd->num_peers; i++) {
11720 WMITLV_SET_HDR(&peer_info->tlv_header,
11721 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11722 WMITLV_GET_STRUCT_TLVLEN(
11723 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011724 qdf_mem_copy(&(peer_info->peer_macaddr),
11725 &(param->peer_info[i].peer_macaddr),
11726 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011727 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011728 peer_info->vdev_id = param->peer_info[i].vdev_id;
11729 peer_info->pdev_id =
11730 wmi_handle->ops->convert_pdev_id_host_to_target(
11731 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011732 /*
11733 * TLV definition for peer atf request fixed param combines
11734 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11735 * stats and atf extension stats as two different
11736 * implementations.
11737 * Need to discuss with FW on this.
11738 *
11739 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11740 * peer_info->atf_units_reserved =
11741 * param->peer_ext_info[i].atf_index_reserved;
11742 */
11743 peer_info++;
11744 }
11745
11746 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11747 WMI_PEER_ATF_REQUEST_CMDID);
11748
11749 if (retval != QDF_STATUS_SUCCESS) {
11750 WMI_LOGE("%s : WMI Failed\n", __func__);
11751 wmi_buf_free(buf);
11752 }
11753
11754 return retval;
11755}
11756
11757/**
11758 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11759 * @wmi_handle: wmi handle
11760 * @param: pointer to hold fwtest param
11761 *
11762 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11763 */
11764static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11765 struct set_fwtest_params *param)
11766{
11767 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11768 wmi_buf_t buf;
11769 int32_t len = sizeof(*cmd);
11770
11771 buf = wmi_buf_alloc(wmi_handle, len);
11772
11773 if (!buf) {
11774 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11775 return QDF_STATUS_E_FAILURE;
11776 }
11777
11778 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11779 WMITLV_SET_HDR(&cmd->tlv_header,
11780 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11781 WMITLV_GET_STRUCT_TLVLEN(
11782 wmi_fwtest_set_param_cmd_fixed_param));
11783 cmd->param_id = param->arg;
11784 cmd->param_value = param->value;
11785
11786 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11787 WMI_LOGE("Setting FW test param failed\n");
11788 wmi_buf_free(buf);
11789 return QDF_STATUS_E_FAILURE;
11790 }
11791
11792 return QDF_STATUS_SUCCESS;
11793}
11794
11795/**
11796 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11797 * @wmi_handle: wmi handle
11798 * @param: pointer to qboost params
11799 * @macaddr: vdev mac address
11800 *
11801 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11802 */
11803static QDF_STATUS
11804send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11805 uint8_t macaddr[IEEE80211_ADDR_LEN],
11806 struct set_qboost_params *param)
11807{
11808 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11809 wmi_buf_t buf;
11810 int32_t len;
11811 QDF_STATUS ret;
11812
11813 len = sizeof(*cmd);
11814
11815 buf = wmi_buf_alloc(wmi_handle, len);
11816 if (!buf) {
11817 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11818 return QDF_STATUS_E_FAILURE;
11819 }
11820
11821 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11822 WMITLV_SET_HDR(&cmd->tlv_header,
11823 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11824 WMITLV_GET_STRUCT_TLVLEN(
11825 WMI_QBOOST_CFG_CMD_fixed_param));
11826 cmd->vdev_id = param->vdev_id;
11827 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11828 cmd->qb_enable = param->value;
11829
11830 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11831 WMI_QBOOST_CFG_CMDID);
11832
11833 if (ret != 0) {
11834 WMI_LOGE("Setting qboost cmd failed\n");
11835 wmi_buf_free(buf);
11836 }
11837
11838 return ret;
11839}
11840
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011841/**
11842 * send_gpio_config_cmd_tlv() - send gpio config to fw
11843 * @wmi_handle: wmi handle
11844 * @param: pointer to hold gpio config param
11845 *
11846 * Return: 0 for success or error code
11847 */
11848static QDF_STATUS
11849send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11850 struct gpio_config_params *param)
11851{
11852 wmi_gpio_config_cmd_fixed_param *cmd;
11853 wmi_buf_t buf;
11854 int32_t len;
11855 QDF_STATUS ret;
11856
11857 len = sizeof(*cmd);
11858
11859 /* Sanity Checks */
11860 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11861 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11862 return QDF_STATUS_E_FAILURE;
11863 }
11864
11865 buf = wmi_buf_alloc(wmi_handle, len);
11866 if (!buf) {
11867 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11868 return QDF_STATUS_E_FAILURE;
11869 }
11870
11871 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11872 WMITLV_SET_HDR(&cmd->tlv_header,
11873 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11874 WMITLV_GET_STRUCT_TLVLEN(
11875 wmi_gpio_config_cmd_fixed_param));
11876 cmd->gpio_num = param->gpio_num;
11877 cmd->input = param->input;
11878 cmd->pull_type = param->pull_type;
11879 cmd->intr_mode = param->intr_mode;
11880
11881 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11882 WMI_GPIO_CONFIG_CMDID);
11883
11884 if (ret != 0) {
11885 WMI_LOGE("Sending GPIO config cmd failed\n");
11886 wmi_buf_free(buf);
11887 }
11888
11889 return ret;
11890}
11891
11892/**
11893 * send_gpio_output_cmd_tlv() - send gpio output to fw
11894 * @wmi_handle: wmi handle
11895 * @param: pointer to hold gpio output param
11896 *
11897 * Return: 0 for success or error code
11898 */
11899static QDF_STATUS
11900send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11901 struct gpio_output_params *param)
11902{
11903 wmi_gpio_output_cmd_fixed_param *cmd;
11904 wmi_buf_t buf;
11905 int32_t len;
11906 QDF_STATUS ret;
11907
11908 len = sizeof(*cmd);
11909
11910 buf = wmi_buf_alloc(wmi_handle, len);
11911 if (!buf) {
11912 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11913 return QDF_STATUS_E_FAILURE;
11914 }
11915
11916 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11917 WMITLV_SET_HDR(&cmd->tlv_header,
11918 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11919 WMITLV_GET_STRUCT_TLVLEN(
11920 wmi_gpio_output_cmd_fixed_param));
11921 cmd->gpio_num = param->gpio_num;
11922 cmd->set = param->set;
11923
11924 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11925 WMI_GPIO_OUTPUT_CMDID);
11926
11927 if (ret != 0) {
11928 WMI_LOGE("Sending GPIO output cmd failed\n");
11929 wmi_buf_free(buf);
11930 }
11931
11932 return ret;
11933
11934}
11935
11936/**
11937 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11938 *
11939 * @param wmi_handle : handle to WMI.
11940 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11941 */
11942static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11943{
11944 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11945 wmi_buf_t buf;
11946 QDF_STATUS ret;
11947 int32_t len;
11948
11949 len = sizeof(*cmd);
11950
11951 buf = wmi_buf_alloc(wmi_handle, len);
11952 if (!buf) {
11953 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11954 return QDF_STATUS_E_FAILURE;
11955 }
11956
11957 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11958 WMITLV_SET_HDR(&cmd->tlv_header,
11959 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11960 WMITLV_GET_STRUCT_TLVLEN(
11961 wmi_pdev_dfs_disable_cmd_fixed_param));
11962 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011963 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11964 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011965
11966 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11967 WMI_PDEV_DFS_DISABLE_CMDID);
11968
11969 if (ret != 0) {
11970 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11971 wmi_buf_free(buf);
11972 }
11973
11974 return ret;
11975}
11976
11977/**
11978 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11979 *
11980 * @param wmi_handle : handle to WMI.
11981 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11982 */
11983static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11984{
11985 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11986 wmi_buf_t buf;
11987 QDF_STATUS ret;
11988 int32_t len;
11989
11990 len = sizeof(*cmd);
11991
11992 buf = wmi_buf_alloc(wmi_handle, len);
11993 if (!buf) {
11994 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11995 return QDF_STATUS_E_FAILURE;
11996 }
11997
11998 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11999 WMITLV_SET_HDR(&cmd->tlv_header,
12000 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12001 WMITLV_GET_STRUCT_TLVLEN(
12002 wmi_pdev_dfs_enable_cmd_fixed_param));
12003 /* Reserved for future use */
12004 cmd->reserved0 = 0;
12005
12006 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12007 WMI_PDEV_DFS_ENABLE_CMDID);
12008
12009 if (ret != 0) {
12010 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12011 wmi_buf_free(buf);
12012 }
12013
12014 return ret;
12015}
12016
12017/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012018 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12019 * to fw
12020 * @wmi_handle: wmi handle
12021 * @param: pointer to hold periodic chan stats param
12022 *
12023 * Return: 0 for success or error code
12024 */
12025static QDF_STATUS
12026send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12027 struct periodic_chan_stats_params *param)
12028{
12029 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12030 wmi_buf_t buf;
12031 QDF_STATUS ret;
12032 int32_t len;
12033
12034 len = sizeof(*cmd);
12035
12036 buf = wmi_buf_alloc(wmi_handle, len);
12037 if (!buf) {
12038 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12039 return QDF_STATUS_E_FAILURE;
12040 }
12041
12042 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12043 wmi_buf_data(buf);
12044 WMITLV_SET_HDR(&cmd->tlv_header,
12045 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12046 WMITLV_GET_STRUCT_TLVLEN(
12047 wmi_set_periodic_channel_stats_config_fixed_param));
12048 cmd->enable = param->enable;
12049 cmd->stats_period = param->stats_period;
12050 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12051 param->pdev_id);
12052
12053 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12054 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12055
12056 if (ret != 0) {
12057 WMI_LOGE("Sending periodic chan stats config failed");
12058 wmi_buf_free(buf);
12059 }
12060
12061 return ret;
12062}
12063
12064/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012065 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12066 * @wmi_handle: wmi handle
12067 *
12068 * Return: 0 for success or error code
12069 */
12070static QDF_STATUS
12071send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
12072{
12073 wmi_buf_t buf;
12074 QDF_STATUS ret;
12075
12076 buf = wmi_buf_alloc(wmi_handle, 0);
12077 if (buf == NULL)
12078 return QDF_STATUS_E_NOMEM;
12079
12080 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
12081 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12082 if (ret != 0) {
12083 WMI_LOGE("Sending get nfcal power cmd failed\n");
12084 wmi_buf_free(buf);
12085 }
12086
12087 return ret;
12088}
12089
12090/**
12091 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12092 * @wmi_handle: wmi handle
12093 * @param: pointer to ht ie param
12094 *
12095 * Return: 0 for success or error code
12096 */
12097static QDF_STATUS
12098send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12099 struct ht_ie_params *param)
12100{
12101 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12102 wmi_buf_t buf;
12103 QDF_STATUS ret;
12104 int32_t len;
12105 uint8_t *buf_ptr;
12106
12107 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12108 roundup(param->ie_len, sizeof(uint32_t));
12109
12110 buf = wmi_buf_alloc(wmi_handle, len);
12111 if (!buf) {
12112 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12113 return QDF_STATUS_E_FAILURE;
12114 }
12115
12116 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12117 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12118 WMITLV_SET_HDR(&cmd->tlv_header,
12119 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12120 WMITLV_GET_STRUCT_TLVLEN(
12121 wmi_pdev_set_ht_ie_cmd_fixed_param));
12122 cmd->reserved0 = 0;
12123 cmd->ie_len = param->ie_len;
12124 cmd->tx_streams = param->tx_streams;
12125 cmd->rx_streams = param->rx_streams;
12126
12127 buf_ptr += sizeof(*cmd);
12128 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12129 buf_ptr += WMI_TLV_HDR_SIZE;
12130 if (param->ie_len)
12131 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12132 cmd->ie_len);
12133
12134 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12135 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12136
12137 if (ret != 0) {
12138 WMI_LOGE("Sending set ht ie cmd failed\n");
12139 wmi_buf_free(buf);
12140 }
12141
12142 return ret;
12143}
12144
12145/**
12146 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12147 * @wmi_handle: wmi handle
12148 * @param: pointer to vht ie param
12149 *
12150 * Return: 0 for success or error code
12151 */
12152static QDF_STATUS
12153send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12154 struct vht_ie_params *param)
12155{
12156 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12157 wmi_buf_t buf;
12158 QDF_STATUS ret;
12159 int32_t len;
12160 uint8_t *buf_ptr;
12161
12162 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12163 roundup(param->ie_len, sizeof(uint32_t));
12164
12165 buf = wmi_buf_alloc(wmi_handle, len);
12166 if (!buf) {
12167 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12168 return QDF_STATUS_E_FAILURE;
12169 }
12170
12171 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12172 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12173 WMITLV_SET_HDR(&cmd->tlv_header,
12174 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12175 WMITLV_GET_STRUCT_TLVLEN(
12176 wmi_pdev_set_vht_ie_cmd_fixed_param));
12177 cmd->reserved0 = 0;
12178 cmd->ie_len = param->ie_len;
12179 cmd->tx_streams = param->tx_streams;
12180 cmd->rx_streams = param->rx_streams;
12181
12182 buf_ptr += sizeof(*cmd);
12183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12184 buf_ptr += WMI_TLV_HDR_SIZE;
12185 if (param->ie_len)
12186 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12187 cmd->ie_len);
12188
12189 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12190 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12191
12192 if (ret != 0) {
12193 WMI_LOGE("Sending set vht ie cmd failed\n");
12194 wmi_buf_free(buf);
12195 }
12196
12197 return ret;
12198}
12199
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012200/**
12201 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12202 * @wmi_handle: wmi handle
12203 * @param: pointer to quiet mode params
12204 *
12205 * Return: 0 for success or error code
12206 */
12207static QDF_STATUS
12208send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12209 struct set_quiet_mode_params *param)
12210{
12211 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12212 wmi_buf_t buf;
12213 QDF_STATUS ret;
12214 int32_t len;
12215
12216 len = sizeof(*quiet_cmd);
12217 buf = wmi_buf_alloc(wmi_handle, len);
12218 if (!buf) {
12219 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12220 return QDF_STATUS_E_FAILURE;
12221 }
12222
12223 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12224 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12225 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12226 WMITLV_GET_STRUCT_TLVLEN(
12227 wmi_pdev_set_quiet_cmd_fixed_param));
12228 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12229 quiet_cmd->enabled = param->enabled;
12230 quiet_cmd->period = (param->period)*(param->intval);
12231 quiet_cmd->duration = param->duration;
12232 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012233 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12234 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012235
12236 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12237 WMI_PDEV_SET_QUIET_MODE_CMDID);
12238
12239 if (ret != 0) {
12240 WMI_LOGE("Sending set quiet cmd failed\n");
12241 wmi_buf_free(buf);
12242 }
12243
12244 return ret;
12245}
12246
12247/**
12248 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12249 * @wmi_handle: wmi handle
12250 * @param: pointer to set bwf param
12251 *
12252 * Return: 0 for success or error code
12253 */
12254static QDF_STATUS
12255send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12256 struct set_bwf_params *param)
12257{
12258 wmi_bwf_peer_info *peer_info;
12259 wmi_peer_bwf_request_fixed_param *cmd;
12260 wmi_buf_t buf;
12261 QDF_STATUS retval;
12262 int32_t len;
12263 uint8_t *buf_ptr;
12264 int i;
12265
12266 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12267 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12268 buf = wmi_buf_alloc(wmi_handle, len);
12269 if (!buf) {
12270 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12271 return QDF_STATUS_E_FAILURE;
12272 }
12273 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12274 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12275 WMITLV_SET_HDR(&cmd->tlv_header,
12276 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12277 WMITLV_GET_STRUCT_TLVLEN(
12278 wmi_peer_bwf_request_fixed_param));
12279 cmd->num_peers = param->num_peers;
12280
12281 buf_ptr += sizeof(*cmd);
12282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12283 sizeof(wmi_bwf_peer_info) *
12284 cmd->num_peers);
12285 buf_ptr += WMI_TLV_HDR_SIZE;
12286 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12287
12288 for (i = 0; i < cmd->num_peers; i++) {
12289 WMITLV_SET_HDR(&peer_info->tlv_header,
12290 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12291 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12292 peer_info->bwf_guaranteed_bandwidth =
12293 param->peer_info[i].throughput;
12294 peer_info->bwf_max_airtime =
12295 param->peer_info[i].max_airtime;
12296 peer_info->bwf_peer_priority =
12297 param->peer_info[i].priority;
12298 qdf_mem_copy(&peer_info->peer_macaddr,
12299 &param->peer_info[i].peer_macaddr,
12300 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012301 peer_info->vdev_id =
12302 param->peer_info[i].vdev_id;
12303 peer_info->pdev_id =
12304 wmi_handle->ops->convert_pdev_id_host_to_target(
12305 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012306 peer_info++;
12307 }
12308
12309 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12310 WMI_PEER_BWF_REQUEST_CMDID);
12311
12312 if (retval != QDF_STATUS_SUCCESS) {
12313 WMI_LOGE("%s : WMI Failed\n", __func__);
12314 wmi_buf_free(buf);
12315 }
12316
12317 return retval;
12318}
12319
12320/**
12321 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12322 * @wmi_handle: wmi handle
12323 * @param: pointer to hold mcast update param
12324 *
12325 * Return: 0 for success or error code
12326 */
12327static QDF_STATUS
12328send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12329 struct mcast_group_update_params *param)
12330{
12331 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12332 wmi_buf_t buf;
12333 QDF_STATUS ret;
12334 int32_t len;
12335 int offset = 0;
12336 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12337
12338 len = sizeof(*cmd);
12339 buf = wmi_buf_alloc(wmi_handle, len);
12340 if (!buf) {
12341 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12342 return QDF_STATUS_E_FAILURE;
12343 }
12344 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12345 WMITLV_SET_HDR(&cmd->tlv_header,
12346 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12347 WMITLV_GET_STRUCT_TLVLEN(
12348 wmi_peer_mcast_group_cmd_fixed_param));
12349 /* confirm the buffer is 4-byte aligned */
12350 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12351 qdf_mem_zero(cmd, sizeof(*cmd));
12352
12353 cmd->vdev_id = param->vap_id;
12354 /* construct the message assuming our endianness matches the target */
12355 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12356 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12357 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12358 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12359 if (param->is_action_delete)
12360 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12361
12362 if (param->is_mcast_addr_len)
12363 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12364
12365 if (param->is_filter_mode_snoop)
12366 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12367
12368 /* unicast address spec only applies for non-wildcard cases */
12369 if (!param->wildcard && param->ucast_mac_addr) {
12370 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12371 &cmd->ucast_mac_addr);
12372 }
Amar Singhal5593c902017-10-03 13:00:29 -070012373
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012374 if (param->mcast_ip_addr) {
12375 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12376 sizeof(cmd->mcast_ip_addr));
12377 offset = sizeof(cmd->mcast_ip_addr) -
12378 param->mcast_ip_addr_bytes;
12379 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12380 param->mcast_ip_addr,
12381 param->mcast_ip_addr_bytes);
12382 }
12383 if (!param->mask)
12384 param->mask = &dummymask[0];
12385
12386 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12387 param->mask,
12388 param->mcast_ip_addr_bytes);
12389
12390 if (param->srcs && param->nsrcs) {
12391 cmd->num_filter_addr = param->nsrcs;
12392 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12393 sizeof(cmd->filter_addr));
12394
12395 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12396 param->nsrcs * param->mcast_ip_addr_bytes);
12397 }
12398
12399 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12400 WMI_PEER_MCAST_GROUP_CMDID);
12401
12402 if (ret != QDF_STATUS_SUCCESS) {
12403 WMI_LOGE("%s : WMI Failed\n", __func__);
12404 wmi_buf_free(buf);
12405 }
12406
12407 return ret;
12408}
12409
12410/**
12411 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12412 * command to fw
12413 * @wmi_handle: wmi handle
12414 * @param: pointer to hold spectral config parameter
12415 *
12416 * Return: 0 for success or error code
12417 */
12418static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12419 struct vdev_spectral_configure_params *param)
12420{
12421 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12422 wmi_buf_t buf;
12423 QDF_STATUS ret;
12424 int32_t len;
12425
12426 len = sizeof(*cmd);
12427 buf = wmi_buf_alloc(wmi_handle, len);
12428 if (!buf) {
12429 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12430 return QDF_STATUS_E_FAILURE;
12431 }
12432
12433 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12434 WMITLV_SET_HDR(&cmd->tlv_header,
12435 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12436 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012437 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012438
12439 cmd->vdev_id = param->vdev_id;
12440 cmd->spectral_scan_count = param->count;
12441 cmd->spectral_scan_period = param->period;
12442 cmd->spectral_scan_priority = param->spectral_pri;
12443 cmd->spectral_scan_fft_size = param->fft_size;
12444 cmd->spectral_scan_gc_ena = param->gc_enable;
12445 cmd->spectral_scan_restart_ena = param->restart_enable;
12446 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12447 cmd->spectral_scan_init_delay = param->init_delay;
12448 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12449 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12450 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12451 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12452 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12453 cmd->spectral_scan_pwr_format = param->pwr_format;
12454 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12455 cmd->spectral_scan_bin_scale = param->bin_scale;
12456 cmd->spectral_scan_dBm_adj = param->dBm_adj;
12457 cmd->spectral_scan_chn_mask = param->chn_mask;
12458
12459 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12460 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12461
12462 if (ret != 0) {
12463 WMI_LOGE("Sending set quiet cmd failed\n");
12464 wmi_buf_free(buf);
12465 }
12466
12467 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12468 __func__);
12469
12470 WMI_LOGI("vdev_id = %u\n"
12471 "spectral_scan_count = %u\n"
12472 "spectral_scan_period = %u\n"
12473 "spectral_scan_priority = %u\n"
12474 "spectral_scan_fft_size = %u\n"
12475 "spectral_scan_gc_ena = %u\n"
12476 "spectral_scan_restart_ena = %u\n"
12477 "spectral_scan_noise_floor_ref = %u\n"
12478 "spectral_scan_init_delay = %u\n"
12479 "spectral_scan_nb_tone_thr = %u\n"
12480 "spectral_scan_str_bin_thr = %u\n"
12481 "spectral_scan_wb_rpt_mode = %u\n"
12482 "spectral_scan_rssi_rpt_mode = %u\n"
12483 "spectral_scan_rssi_thr = %u\n"
12484 "spectral_scan_pwr_format = %u\n"
12485 "spectral_scan_rpt_mode = %u\n"
12486 "spectral_scan_bin_scale = %u\n"
12487 "spectral_scan_dBm_adj = %u\n"
12488 "spectral_scan_chn_mask = %u\n",
12489 param->vdev_id,
12490 param->count,
12491 param->period,
12492 param->spectral_pri,
12493 param->fft_size,
12494 param->gc_enable,
12495 param->restart_enable,
12496 param->noise_floor_ref,
12497 param->init_delay,
12498 param->nb_tone_thr,
12499 param->str_bin_thr,
12500 param->wb_rpt_mode,
12501 param->rssi_rpt_mode,
12502 param->rssi_thr,
12503 param->pwr_format,
12504 param->rpt_mode,
12505 param->bin_scale,
12506 param->dBm_adj,
12507 param->chn_mask);
12508 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12509
12510 return ret;
12511}
12512
12513/**
12514 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12515 * command to fw
12516 * @wmi_handle: wmi handle
12517 * @param: pointer to hold spectral enable parameter
12518 *
12519 * Return: 0 for success or error code
12520 */
12521static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12522 struct vdev_spectral_enable_params *param)
12523{
12524 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12525 wmi_buf_t buf;
12526 QDF_STATUS ret;
12527 int32_t len;
12528
12529 len = sizeof(*cmd);
12530 buf = wmi_buf_alloc(wmi_handle, len);
12531 if (!buf) {
12532 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12533 return QDF_STATUS_E_FAILURE;
12534 }
12535
12536 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12537 WMITLV_SET_HDR(&cmd->tlv_header,
12538 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12539 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012540 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012541
12542 cmd->vdev_id = param->vdev_id;
12543
12544 if (param->active_valid) {
12545 cmd->trigger_cmd = param->active ? 1 : 2;
12546 /* 1: Trigger, 2: Clear Trigger */
12547 } else {
12548 cmd->trigger_cmd = 0; /* 0: Ignore */
12549 }
12550
12551 if (param->enabled_valid) {
12552 cmd->enable_cmd = param->enabled ? 1 : 2;
12553 /* 1: Enable 2: Disable */
12554 } else {
12555 cmd->enable_cmd = 0; /* 0: Ignore */
12556 }
12557
12558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12559 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12560
12561 if (ret != 0) {
12562 WMI_LOGE("Sending scan enable CMD failed\n");
12563 wmi_buf_free(buf);
12564 }
12565
12566 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12567
12568 WMI_LOGI("vdev_id = %u\n"
12569 "trigger_cmd = %u\n"
12570 "enable_cmd = %u\n",
12571 cmd->vdev_id,
12572 cmd->trigger_cmd,
12573 cmd->enable_cmd);
12574
12575 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12576
12577 return ret;
12578}
12579
12580/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012581 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12582 * @param wmi_handle : handle to WMI.
12583 * @param param : pointer to hold thermal mitigation param
12584 *
12585 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12586 */
12587static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12588 wmi_unified_t wmi_handle,
12589 struct thermal_mitigation_params *param)
12590{
12591 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12592 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12593 wmi_buf_t buf = NULL;
12594 uint8_t *buf_ptr = NULL;
12595 int error;
12596 int32_t len;
12597 int i;
12598
12599 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12600 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12601
12602 buf = wmi_buf_alloc(wmi_handle, len);
12603 if (!buf) {
12604 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12605 return QDF_STATUS_E_NOMEM;
12606 }
12607 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12608
12609 /* init fixed params */
12610 WMITLV_SET_HDR(tt_conf,
12611 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12612 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12613
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012614 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12615 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012616 tt_conf->enable = param->enable;
12617 tt_conf->dc = param->dc;
12618 tt_conf->dc_per_event = param->dc_per_event;
12619 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12620
12621 buf_ptr = (uint8_t *) ++tt_conf;
12622 /* init TLV params */
12623 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12624 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12625
12626 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12627 for (i = 0; i < THERMAL_LEVELS; i++) {
12628 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12629 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12630 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12631 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12632 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12633 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12634 lvl_conf->prio = param->levelconf[i].priority;
12635 lvl_conf++;
12636 }
12637
12638 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12639 WMI_THERM_THROT_SET_CONF_CMDID);
12640 if (QDF_IS_STATUS_ERROR(error)) {
12641 wmi_buf_free(buf);
12642 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12643 }
12644
12645 return error;
12646}
12647
12648/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012649 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12650 * @wmi_handle: wmi handle
12651 * @param: pointer to pdev_qvit_params
12652 *
12653 * Return: 0 for success or error code
12654 */
12655static QDF_STATUS
12656send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12657 struct pdev_qvit_params *param)
12658{
12659 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012660 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012661 uint8_t *cmd;
12662 static uint8_t msgref = 1;
12663 uint8_t segnumber = 0, seginfo, numsegments;
12664 uint16_t chunk_len, total_bytes;
12665 uint8_t *bufpos;
12666 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12667
12668 bufpos = param->utf_payload;
12669 total_bytes = param->len;
12670 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12671 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12672 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12673
12674 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12675 numsegments++;
12676
12677 while (param->len) {
12678 if (param->len > MAX_WMI_QVIT_LEN)
12679 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
12680 else
12681 chunk_len = param->len;
12682
12683 buf = wmi_buf_alloc(wmi_handle,
12684 (chunk_len + sizeof(seghdrinfo) +
12685 WMI_TLV_HDR_SIZE));
12686 if (!buf) {
12687 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12688 return QDF_STATUS_E_NOMEM;
12689 }
12690
12691 cmd = (uint8_t *) wmi_buf_data(buf);
12692
12693 seghdrinfo.len = total_bytes;
12694 seghdrinfo.msgref = msgref;
12695 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12696 seghdrinfo.segmentInfo = seginfo;
12697
12698 segnumber++;
12699
12700 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12701 (chunk_len + sizeof(seghdrinfo)));
12702 cmd += WMI_TLV_HDR_SIZE;
12703 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12704 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12705
12706 ret = wmi_unified_cmd_send(wmi_handle, buf,
12707 (chunk_len + sizeof(seghdrinfo) +
12708 WMI_TLV_HDR_SIZE),
12709 WMI_PDEV_QVIT_CMDID);
12710
12711 if (ret != 0) {
12712 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12713 wmi_buf_free(buf);
12714 break;
12715 }
12716
12717 param->len -= chunk_len;
12718 bufpos += chunk_len;
12719 }
12720 msgref++;
12721
12722 return ret;
12723}
12724
12725/**
12726 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12727 * @wmi_handle: wmi handle
12728 * @param: pointer to wmm update param
12729 *
12730 * Return: 0 for success or error code
12731 */
12732static QDF_STATUS
12733send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12734 struct wmm_update_params *param)
12735{
12736 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12737 wmi_wmm_params *wmm_param;
12738 wmi_buf_t buf;
12739 QDF_STATUS ret;
12740 int32_t len;
12741 int ac = 0;
12742 struct wmi_host_wmeParams *wmep;
12743 uint8_t *buf_ptr;
12744
12745 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12746 buf = wmi_buf_alloc(wmi_handle, len);
12747 if (!buf) {
12748 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12749 return QDF_STATUS_E_FAILURE;
12750 }
12751
12752 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12753 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12754 WMITLV_SET_HDR(&cmd->tlv_header,
12755 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12756 WMITLV_GET_STRUCT_TLVLEN
12757 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12758
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012759 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012760
12761 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12762
12763 for (ac = 0; ac < WME_NUM_AC; ac++) {
12764 wmep = &param->wmep_array[ac];
12765 wmm_param = (wmi_wmm_params *)buf_ptr;
12766 WMITLV_SET_HDR(&wmm_param->tlv_header,
12767 WMITLV_TAG_STRUC_wmi_wmm_params,
12768 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12769 wmm_param->aifs = wmep->wmep_aifsn;
12770 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12771 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12772 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12773 wmm_param->acm = wmep->wmep_acm;
12774 wmm_param->no_ack = wmep->wmep_noackPolicy;
12775 buf_ptr += sizeof(wmi_wmm_params);
12776 }
12777 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12778 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12779
12780 if (ret != 0) {
12781 WMI_LOGE("Sending WMM update CMD failed\n");
12782 wmi_buf_free(buf);
12783 }
12784
12785 return ret;
12786}
12787
Sathish Kumar80f4f382017-04-24 11:36:00 +053012788/**
12789 * send_coex_config_cmd_tlv() - send coex config command to fw
12790 * @wmi_handle: wmi handle
12791 * @param: pointer to coex config param
12792 *
12793 * Return: 0 for success or error code
12794 */
12795static QDF_STATUS
12796send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12797 struct coex_config_params *param)
12798{
12799 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12800 wmi_buf_t buf;
12801 QDF_STATUS ret;
12802 int32_t len;
12803
12804 len = sizeof(*cmd);
12805 buf = wmi_buf_alloc(wmi_handle, len);
12806 if (!buf) {
12807 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12808 return QDF_STATUS_E_FAILURE;
12809 }
12810
12811 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12812 WMITLV_SET_HDR(&cmd->tlv_header,
12813 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12814 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012815 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012816
12817 cmd->vdev_id = param->vdev_id;
12818 cmd->config_type = param->config_type;
12819 cmd->config_arg1 = param->config_arg1;
12820 cmd->config_arg2 = param->config_arg2;
12821 cmd->config_arg3 = param->config_arg3;
12822 cmd->config_arg4 = param->config_arg4;
12823 cmd->config_arg5 = param->config_arg5;
12824 cmd->config_arg6 = param->config_arg6;
12825
12826 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12827 WMI_COEX_CONFIG_CMDID);
12828
12829 if (ret != 0) {
12830 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12831 wmi_buf_free(buf);
12832 }
12833
12834 return ret;
12835}
12836
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012837static
Govind Singh9ddd5162016-03-07 16:30:32 +053012838void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012839 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012840{
Govind Singhe7f2f342016-05-23 12:12:52 +053012841 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012842 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12843 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12844 resource_cfg->num_offload_reorder_buffs =
12845 tgt_res_cfg->num_offload_reorder_buffs;
12846 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12847 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12848 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12849 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12850 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12851 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12852 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12853 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12854 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12855 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12856 resource_cfg->scan_max_pending_req =
12857 tgt_res_cfg->scan_max_pending_req;
12858 resource_cfg->bmiss_offload_max_vdev =
12859 tgt_res_cfg->bmiss_offload_max_vdev;
12860 resource_cfg->roam_offload_max_vdev =
12861 tgt_res_cfg->roam_offload_max_vdev;
12862 resource_cfg->roam_offload_max_ap_profiles =
12863 tgt_res_cfg->roam_offload_max_ap_profiles;
12864 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12865 resource_cfg->num_mcast_table_elems =
12866 tgt_res_cfg->num_mcast_table_elems;
12867 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12868 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12869 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12870 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12871 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12872 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12873 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12874 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12875 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12876 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12877 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12878 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12879 resource_cfg->num_tdls_conn_table_entries =
12880 tgt_res_cfg->num_tdls_conn_table_entries;
12881 resource_cfg->beacon_tx_offload_max_vdev =
12882 tgt_res_cfg->beacon_tx_offload_max_vdev;
12883 resource_cfg->num_multicast_filter_entries =
12884 tgt_res_cfg->num_multicast_filter_entries;
12885 resource_cfg->num_wow_filters =
12886 tgt_res_cfg->num_wow_filters;
12887 resource_cfg->num_keep_alive_pattern =
12888 tgt_res_cfg->num_keep_alive_pattern;
12889 resource_cfg->keep_alive_pattern_size =
12890 tgt_res_cfg->keep_alive_pattern_size;
12891 resource_cfg->max_tdls_concurrent_sleep_sta =
12892 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12893 resource_cfg->max_tdls_concurrent_buffer_sta =
12894 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12895 resource_cfg->wmi_send_separate =
12896 tgt_res_cfg->wmi_send_separate;
12897 resource_cfg->num_ocb_vdevs =
12898 tgt_res_cfg->num_ocb_vdevs;
12899 resource_cfg->num_ocb_channels =
12900 tgt_res_cfg->num_ocb_channels;
12901 resource_cfg->num_ocb_schedules =
12902 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012903 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
12904 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12905 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012906 resource_cfg->max_num_dbs_scan_duty_cycle =
12907 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012908 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012909
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012910 if (tgt_res_cfg->atf_config)
12911 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12912 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12913 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12914 resource_cfg->flag1, 1);
12915 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12916 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12917 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012918 if (tgt_res_cfg->cce_disable)
12919 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053012920}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012921
12922/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12923 * @wmi_handle: pointer to wmi handle
12924 * @buf_ptr: pointer to current position in init command buffer
12925 * @len: pointer to length. This will be updated with current lenght of cmd
12926 * @param: point host parameters for init command
12927 *
12928 * Return: Updated pointer of buf_ptr.
12929 */
12930static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12931 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12932{
12933 uint16_t idx;
12934
12935 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12936 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12937 wmi_pdev_band_to_mac *band_to_mac;
12938
12939 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12940 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12941 sizeof(wmi_resource_config) +
12942 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12943 sizeof(wlan_host_memory_chunk)));
12944
12945 WMITLV_SET_HDR(&hw_mode->tlv_header,
12946 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12947 (WMITLV_GET_STRUCT_TLVLEN
12948 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12949
12950 hw_mode->hw_mode_index = param->hw_mode_id;
12951 hw_mode->num_band_to_mac = param->num_band_to_mac;
12952
12953 buf_ptr = (uint8_t *) (hw_mode + 1);
12954 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12955 WMI_TLV_HDR_SIZE);
12956 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12957 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12958 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12959 WMITLV_GET_STRUCT_TLVLEN
12960 (wmi_pdev_band_to_mac));
12961 band_to_mac[idx].pdev_id =
12962 wmi_handle->ops->convert_pdev_id_host_to_target(
12963 param->band_to_mac[idx].pdev_id);
12964 band_to_mac[idx].start_freq =
12965 param->band_to_mac[idx].start_freq;
12966 band_to_mac[idx].end_freq =
12967 param->band_to_mac[idx].end_freq;
12968 }
12969 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12970 (param->num_band_to_mac *
12971 sizeof(wmi_pdev_band_to_mac)) +
12972 WMI_TLV_HDR_SIZE;
12973
12974 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12975 (param->num_band_to_mac *
12976 sizeof(wmi_pdev_band_to_mac)));
12977 }
12978
12979 return buf_ptr;
12980}
12981
12982static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12983 wmi_init_cmd_fixed_param *cmd)
12984{
12985 int num_whitelist;
12986 wmi_abi_version my_vers;
12987
12988 num_whitelist = sizeof(version_whitelist) /
12989 sizeof(wmi_whitelist_version_info);
12990 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12991 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12992 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12993 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12994 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12995 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12996
12997 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12998 &my_vers,
12999 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13000 &cmd->host_abi_vers);
13001
13002 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13003 __func__,
13004 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13005 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13006 cmd->host_abi_vers.abi_version_ns_0,
13007 cmd->host_abi_vers.abi_version_ns_1,
13008 cmd->host_abi_vers.abi_version_ns_2,
13009 cmd->host_abi_vers.abi_version_ns_3);
13010
13011 /* Save version sent from host -
13012 * Will be used to check ready event
13013 */
13014 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13015 sizeof(wmi_abi_version));
13016}
13017
Sathish Kumarfd347372017-02-13 12:29:09 +053013018static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013019{
13020 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13021 wmi_service_ready_event_fixed_param *ev;
13022
13023
13024 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13025
13026 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13027 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013028 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013029
13030 /*Save fw version from service ready message */
13031 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013032 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013033 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013034
Govind Singhb53420c2016-03-09 14:32:57 +053013035 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013036}
13037
13038/**
13039 * wmi_unified_save_fw_version_cmd() - save fw version
13040 * @wmi_handle: pointer to wmi handle
13041 * @res_cfg: resource config
13042 * @num_mem_chunks: no of mem chunck
13043 * @mem_chunk: pointer to mem chunck structure
13044 *
13045 * This function sends IE information to firmware
13046 *
Govind Singhb53420c2016-03-09 14:32:57 +053013047 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013048 *
13049 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013050static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013051 void *evt_buf)
13052{
13053 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13054 wmi_ready_event_fixed_param *ev = NULL;
13055
13056 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13057 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013058 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13059 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013060 &ev->fw_abi_vers)) {
13061 /*
13062 * Error: Our host version and the given firmware version
13063 * are incompatible.
13064 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013065 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013066 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13067 __func__,
13068 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13069 abi_version_0),
13070 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13071 abi_version_0),
13072 wmi_handle->final_abi_vers.abi_version_ns_0,
13073 wmi_handle->final_abi_vers.abi_version_ns_1,
13074 wmi_handle->final_abi_vers.abi_version_ns_2,
13075 wmi_handle->final_abi_vers.abi_version_ns_3,
13076 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13077 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13078 ev->fw_abi_vers.abi_version_ns_0,
13079 ev->fw_abi_vers.abi_version_ns_1,
13080 ev->fw_abi_vers.abi_version_ns_2,
13081 ev->fw_abi_vers.abi_version_ns_3);
13082
Govind Singhb53420c2016-03-09 14:32:57 +053013083 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013084 }
Govind Singhb53420c2016-03-09 14:32:57 +053013085 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013086 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013087 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013088 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013089
Govind Singhb53420c2016-03-09 14:32:57 +053013090 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013091}
Govind Singha4836fd2016-03-07 16:45:38 +053013092
13093/**
13094 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13095 * @wmi_handle: wmi handle
13096 * @custom_addr: base mac address
13097 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013098 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013099 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013100static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013101 uint8_t *custom_addr)
13102{
13103 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13104 wmi_buf_t buf;
13105 int err;
13106
13107 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13108 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013109 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013110 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013111 }
13112
13113 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013114 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013115
13116 WMITLV_SET_HDR(&cmd->tlv_header,
13117 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13118 WMITLV_GET_STRUCT_TLVLEN
13119 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13120 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013121 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13122 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013123 err = wmi_unified_cmd_send(wmi_handle, buf,
13124 sizeof(*cmd),
13125 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13126 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013127 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013128 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013129 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013130 }
13131
13132 return 0;
13133}
13134
13135/**
13136 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13137 * @handle: wmi handle
13138 * @event: Event received from FW
13139 * @len: Length of the event
13140 *
13141 * Enables the low frequency events and disables the high frequency
13142 * events. Bit 17 indicates if the event if low/high frequency.
13143 * 1 - high frequency, 0 - low frequency
13144 *
13145 * Return: 0 on successfully enabling/disabling the events
13146 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013147static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013148 uint8_t *event,
13149 uint32_t len)
13150{
13151 uint32_t num_of_diag_events_logs;
13152 wmi_diag_event_log_config_fixed_param *cmd;
13153 wmi_buf_t buf;
13154 uint8_t *buf_ptr;
13155 uint32_t *cmd_args, *evt_args;
13156 uint32_t buf_len, i;
13157
13158 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13159 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13160
Govind Singhb53420c2016-03-09 14:32:57 +053013161 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013162
13163 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13164 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013165 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013166 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013167 }
13168 wmi_event = param_buf->fixed_param;
13169 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013170
13171 if (num_of_diag_events_logs >
13172 param_buf->num_diag_events_logs_list) {
13173 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13174 num_of_diag_events_logs,
13175 param_buf->num_diag_events_logs_list);
13176 return QDF_STATUS_E_INVAL;
13177 }
13178
Govind Singha4836fd2016-03-07 16:45:38 +053013179 evt_args = param_buf->diag_events_logs_list;
13180 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013181 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013182 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013183 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013184 }
13185
Govind Singhb53420c2016-03-09 14:32:57 +053013186 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013187 __func__, num_of_diag_events_logs);
13188
13189 /* Free any previous allocation */
13190 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013191 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013192
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013193 if (num_of_diag_events_logs >
13194 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13195 WMI_LOGE("%s: excess num of logs:%d", __func__,
13196 num_of_diag_events_logs);
13197 QDF_ASSERT(0);
13198 return QDF_STATUS_E_INVAL;
13199 }
Govind Singha4836fd2016-03-07 16:45:38 +053013200 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013201 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013202 sizeof(uint32_t));
13203 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013204 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013205 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013206 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013207 }
13208 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13209
13210 /* Prepare the send buffer */
13211 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13212 (num_of_diag_events_logs * sizeof(uint32_t));
13213
13214 buf = wmi_buf_alloc(wmi_handle, buf_len);
13215 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013216 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13217 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013218 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013219 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013220 }
13221
13222 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13223 buf_ptr = (uint8_t *) cmd;
13224
13225 WMITLV_SET_HDR(&cmd->tlv_header,
13226 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13227 WMITLV_GET_STRUCT_TLVLEN(
13228 wmi_diag_event_log_config_fixed_param));
13229
13230 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13231
13232 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13233
13234 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13235 (num_of_diag_events_logs * sizeof(uint32_t)));
13236
13237 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13238
13239 /* Populate the events */
13240 for (i = 0; i < num_of_diag_events_logs; i++) {
13241 /* Low freq (0) - Enable (1) the event
13242 * High freq (1) - Disable (0) the event
13243 */
13244 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13245 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13246 /* Set the event ID */
13247 WMI_DIAG_ID_SET(cmd_args[i],
13248 WMI_DIAG_ID_GET(evt_args[i]));
13249 /* Set the type */
13250 WMI_DIAG_TYPE_SET(cmd_args[i],
13251 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013252 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013253 wmi_handle->events_logs_list[i] = evt_args[i];
13254 }
13255
13256 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13257 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013258 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013259 __func__);
13260 wmi_buf_free(buf);
13261 /* Not clearing events_logs_list, though wmi cmd failed.
13262 * Host can still have this list
13263 */
Govind Singh67922e82016-04-01 16:48:57 +053013264 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013265 }
13266
13267 return 0;
13268}
13269
13270/**
13271 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13272 * @wmi_handle: wmi handle
13273 * @start_log: Start logging related parameters
13274 *
13275 * Send the command to the FW based on which specific logging of diag
13276 * event/log id can be started/stopped
13277 *
13278 * Return: None
13279 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013280static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013281 struct wmi_wifi_start_log *start_log)
13282{
13283 wmi_diag_event_log_config_fixed_param *cmd;
13284 wmi_buf_t buf;
13285 uint8_t *buf_ptr;
13286 uint32_t len, count, log_level, i;
13287 uint32_t *cmd_args;
13288 uint32_t total_len;
13289 count = 0;
13290
13291 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013292 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013293 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013294 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013295 }
13296 /* total_len stores the number of events where BITS 17 and 18 are set.
13297 * i.e., events of high frequency (17) and for extended debugging (18)
13298 */
13299 total_len = 0;
13300 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13301 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13302 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13303 total_len++;
13304 }
13305
13306 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13307 (total_len * sizeof(uint32_t));
13308
13309 buf = wmi_buf_alloc(wmi_handle, len);
13310 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013311 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013312 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013313 }
13314 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13315 buf_ptr = (uint8_t *) cmd;
13316
13317 WMITLV_SET_HDR(&cmd->tlv_header,
13318 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13319 WMITLV_GET_STRUCT_TLVLEN(
13320 wmi_diag_event_log_config_fixed_param));
13321
13322 cmd->num_of_diag_events_logs = total_len;
13323
13324 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13325
13326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13327 (total_len * sizeof(uint32_t)));
13328
13329 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13330
Govind Singh224a7312016-06-21 14:33:26 +053013331 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013332 log_level = 1;
13333 else
13334 log_level = 0;
13335
Govind Singhb53420c2016-03-09 14:32:57 +053013336 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013337 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13338 uint32_t val = wmi_handle->events_logs_list[i];
13339 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13340 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13341
13342 WMI_DIAG_ID_SET(cmd_args[count],
13343 WMI_DIAG_ID_GET(val));
13344 WMI_DIAG_TYPE_SET(cmd_args[count],
13345 WMI_DIAG_TYPE_GET(val));
13346 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13347 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013348 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013349 count++;
13350 }
13351 }
13352
13353 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13354 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013355 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013356 __func__);
13357 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013358 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013359 }
13360
Govind Singhb53420c2016-03-09 14:32:57 +053013361 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013362}
13363
13364/**
13365 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13366 * @wmi_handle: WMI handle
13367 *
13368 * This function is used to send the flush command to the FW,
13369 * that will flush the fw logs that are residue in the FW
13370 *
13371 * Return: None
13372 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013373static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013374{
13375 wmi_debug_mesg_flush_fixed_param *cmd;
13376 wmi_buf_t buf;
13377 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013378 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013379
13380 buf = wmi_buf_alloc(wmi_handle, len);
13381 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013382 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013383 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013384 }
13385
13386 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13387 WMITLV_SET_HDR(&cmd->tlv_header,
13388 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13389 WMITLV_GET_STRUCT_TLVLEN(
13390 wmi_debug_mesg_flush_fixed_param));
13391 cmd->reserved0 = 0;
13392
13393 ret = wmi_unified_cmd_send(wmi_handle,
13394 buf,
13395 len,
13396 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013397 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013398 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013399 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013400 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013401 }
Govind Singhb53420c2016-03-09 14:32:57 +053013402 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013403
Govind Singh67922e82016-04-01 16:48:57 +053013404 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013405}
13406
13407/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013408 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013409 * @wmi_handle: wmi handle
13410 * @msg: PCL structure containing the PCL and the number of channels
13411 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013412 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013413 * firmware. The DBS Manager is the consumer of this information in the WLAN
13414 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13415 * to migrate to a new channel without host driver involvement. An example of
13416 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13417 * manage the channel selection without firmware involvement.
13418 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013419 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13420 * channel list. The weights corresponds to the channels sent in
13421 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13422 * weightage compared to the non PCL channels.
13423 *
Govind Singha4836fd2016-03-07 16:45:38 +053013424 * Return: Success if the cmd is sent successfully to the firmware
13425 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013426static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013427 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013428{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013429 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013430 wmi_buf_t buf;
13431 uint8_t *buf_ptr;
13432 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013433 uint32_t chan_len;
13434
13435 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013436
13437 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013438 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013439
13440 buf = wmi_buf_alloc(wmi_handle, len);
13441 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013442 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13443 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013444 }
13445
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013446 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013447 buf_ptr = (uint8_t *) cmd;
13448 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013449 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13450 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013451
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013452 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13453 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013454 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013455 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013456
13457 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013458 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013459 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013460 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013461 for (i = 0; i < chan_len ; i++) {
13462 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013463 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013464 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013465 }
13466 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013467 WMI_PDEV_SET_PCL_CMDID)) {
13468 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013469 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013470 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013471 }
Govind Singhb53420c2016-03-09 14:32:57 +053013472 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013473}
13474
13475/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013476 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013477 * @wmi_handle: wmi handle
13478 * @msg: Structure containing the following parameters
13479 *
13480 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13481 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13482 *
13483 * Provides notification to the WLAN firmware that host driver is requesting a
13484 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13485 * configurations that include the Dual Band Simultaneous (DBS) feature.
13486 *
13487 * Return: Success if the cmd is sent successfully to the firmware
13488 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013489static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013490 uint32_t hw_mode_index)
13491{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013492 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013493 wmi_buf_t buf;
13494 uint32_t len;
13495
13496 len = sizeof(*cmd);
13497
13498 buf = wmi_buf_alloc(wmi_handle, len);
13499 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013500 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13501 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013502 }
13503
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013504 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013505 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013506 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13507 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13508
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013509 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13510 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013511 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013512 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013513
13514 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013515 WMI_PDEV_SET_HW_MODE_CMDID)) {
13516 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013517 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013518 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013519 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013520 }
13521
Govind Singhb53420c2016-03-09 14:32:57 +053013522 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013523}
13524
13525/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013526 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013527 * @wmi_handle: wmi handle
13528 * @msg: Dual MAC config parameters
13529 *
13530 * Configures WLAN firmware with the dual MAC features
13531 *
Govind Singhb53420c2016-03-09 14:32:57 +053013532 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013533 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013534static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013535QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013536 struct wmi_dual_mac_config *msg)
13537{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013538 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013539 wmi_buf_t buf;
13540 uint32_t len;
13541
13542 len = sizeof(*cmd);
13543
13544 buf = wmi_buf_alloc(wmi_handle, len);
13545 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013546 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13547 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013548 }
13549
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013550 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013551 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013552 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013553 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013554 wmi_pdev_set_mac_config_cmd_fixed_param));
13555
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013556 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13557 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013558 cmd->concurrent_scan_config_bits = msg->scan_config;
13559 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013560 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013561 __func__, msg->scan_config, msg->fw_mode_config);
13562
13563 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013564 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13565 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013566 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013567 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013568 }
Govind Singhb53420c2016-03-09 14:32:57 +053013569 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013570}
13571
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013572#ifdef BIG_ENDIAN_HOST
13573/**
13574* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13575* @param data_len - data length
13576* @param data - pointer to data
13577*
13578* Return: QDF_STATUS - success or error status
13579*/
13580static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13581 struct fips_params *param)
13582{
13583 unsigned char *key_unaligned, *data_unaligned;
13584 int c;
13585 u_int8_t *key_aligned = NULL;
13586 u_int8_t *data_aligned = NULL;
13587
13588 /* Assigning unaligned space to copy the key */
13589 key_unaligned = qdf_mem_malloc(
13590 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13591 data_unaligned = qdf_mem_malloc(
13592 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13593
13594 /* Checking if kmalloc is succesful to allocate space */
13595 if (key_unaligned == NULL)
13596 return QDF_STATUS_SUCCESS;
13597 /* Checking if space is aligned */
13598 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13599 /* align to 4 */
13600 key_aligned =
13601 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13602 FIPS_ALIGN);
13603 } else {
13604 key_aligned = (u_int8_t *)key_unaligned;
13605 }
13606
13607 /* memset and copy content from key to key aligned */
13608 OS_MEMSET(key_aligned, 0, param->key_len);
13609 OS_MEMCPY(key_aligned, param->key, param->key_len);
13610
13611 /* print a hexdump for host debug */
13612 print_hex_dump(KERN_DEBUG,
13613 "\t Aligned and Copied Key:@@@@ ",
13614 DUMP_PREFIX_NONE,
13615 16, 1, key_aligned, param->key_len, true);
13616
13617 /* Checking if kmalloc is succesful to allocate space */
13618 if (data_unaligned == NULL)
13619 return QDF_STATUS_SUCCESS;
13620 /* Checking of space is aligned */
13621 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13622 /* align to 4 */
13623 data_aligned =
13624 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13625 FIPS_ALIGN);
13626 } else {
13627 data_aligned = (u_int8_t *)data_unaligned;
13628 }
13629
13630 /* memset and copy content from data to data aligned */
13631 OS_MEMSET(data_aligned, 0, param->data_len);
13632 OS_MEMCPY(data_aligned, param->data, param->data_len);
13633
13634 /* print a hexdump for host debug */
13635 print_hex_dump(KERN_DEBUG,
13636 "\t Properly Aligned and Copied Data:@@@@ ",
13637 DUMP_PREFIX_NONE,
13638 16, 1, data_aligned, param->data_len, true);
13639
13640 /* converting to little Endian both key_aligned and
13641 * data_aligned*/
13642 for (c = 0; c < param->key_len/4; c++) {
13643 *((u_int32_t *)key_aligned+c) =
13644 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13645 }
13646 for (c = 0; c < param->data_len/4; c++) {
13647 *((u_int32_t *)data_aligned+c) =
13648 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13649 }
13650
13651 /* update endian data to key and data vectors */
13652 OS_MEMCPY(param->key, key_aligned, param->key_len);
13653 OS_MEMCPY(param->data, data_aligned, param->data_len);
13654
13655 /* clean up allocated spaces */
13656 qdf_mem_free(key_unaligned);
13657 key_unaligned = NULL;
13658 key_aligned = NULL;
13659
13660 qdf_mem_free(data_unaligned);
13661 data_unaligned = NULL;
13662 data_aligned = NULL;
13663
13664 return QDF_STATUS_SUCCESS;
13665}
13666#else
13667/**
13668* fips_align_data_be() - DUMMY for LE platform
13669*
13670* Return: QDF_STATUS - success
13671*/
13672static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13673 struct fips_params *param)
13674{
13675 return QDF_STATUS_SUCCESS;
13676}
13677#endif
13678
13679
13680/**
13681 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13682 * @wmi_handle: wmi handle
13683 * @param: pointer to hold pdev fips param
13684 *
13685 * Return: 0 for success or error code
13686 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013687static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013688send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13689 struct fips_params *param)
13690{
13691 wmi_pdev_fips_cmd_fixed_param *cmd;
13692 wmi_buf_t buf;
13693 uint8_t *buf_ptr;
13694 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13695 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13696
13697 /* Length TLV placeholder for array of bytes */
13698 len += WMI_TLV_HDR_SIZE;
13699 if (param->data_len)
13700 len += (param->data_len*sizeof(uint8_t));
13701
13702 /*
13703 * Data length must be multiples of 16 bytes - checked against 0xF -
13704 * and must be less than WMI_SVC_MSG_SIZE - static size of
13705 * wmi_pdev_fips_cmd structure
13706 */
13707
13708 /* do sanity on the input */
13709 if (!(((param->data_len & 0xF) == 0) &&
13710 ((param->data_len > 0) &&
13711 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13712 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13713 return QDF_STATUS_E_INVAL;
13714 }
13715
13716 buf = wmi_buf_alloc(wmi_handle, len);
13717 if (!buf) {
13718 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13719 return QDF_STATUS_E_FAILURE;
13720 }
13721
13722 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13723 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13724 WMITLV_SET_HDR(&cmd->tlv_header,
13725 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13726 WMITLV_GET_STRUCT_TLVLEN
13727 (wmi_pdev_fips_cmd_fixed_param));
13728
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013729 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13730 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013731 if (param->key != NULL && param->data != NULL) {
13732 cmd->key_len = param->key_len;
13733 cmd->data_len = param->data_len;
13734 cmd->fips_cmd = !!(param->op);
13735
13736 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13737 return QDF_STATUS_E_FAILURE;
13738
13739 qdf_mem_copy(cmd->key, param->key, param->key_len);
13740
13741 if (param->mode == FIPS_ENGINE_AES_CTR ||
13742 param->mode == FIPS_ENGINE_AES_MIC) {
13743 cmd->mode = param->mode;
13744 } else {
13745 cmd->mode = FIPS_ENGINE_AES_CTR;
13746 }
13747 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13748 cmd->key_len, cmd->data_len);
13749
13750 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13751 cmd->key, cmd->key_len, true);
13752 buf_ptr += sizeof(*cmd);
13753
13754 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13755
13756 buf_ptr += WMI_TLV_HDR_SIZE;
13757 if (param->data_len)
13758 qdf_mem_copy(buf_ptr,
13759 (uint8_t *) param->data, param->data_len);
13760
13761 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13762 16, 1, buf_ptr, cmd->data_len, true);
13763
13764 buf_ptr += param->data_len;
13765
13766 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13767 WMI_PDEV_FIPS_CMDID);
13768 qdf_print("%s return value %d\n", __func__, retval);
13769 } else {
13770 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13771 wmi_buf_free(buf);
13772 retval = -QDF_STATUS_E_BADMSG;
13773 }
13774
13775 return retval;
13776}
13777
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013778#ifdef WLAN_PMO_ENABLE
13779/**
13780 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13781 * @wmi_handle: wmi handle
13782 * @vdev_id: vdev id
13783 * @bitmap: Event bitmap
13784 * @enable: enable/disable
13785 *
13786 * Return: CDF status
13787 */
13788static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13789 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013790 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013791 bool enable)
13792{
13793 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13794 uint16_t len;
13795 wmi_buf_t buf;
13796 int ret;
13797
13798 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13799 buf = wmi_buf_alloc(wmi_handle, len);
13800 if (!buf) {
13801 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13802 return QDF_STATUS_E_NOMEM;
13803 }
13804 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13805 WMITLV_SET_HDR(&cmd->tlv_header,
13806 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13807 WMITLV_GET_STRUCT_TLVLEN
13808 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13809 cmd->vdev_id = vdev_id;
13810 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013811 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13812 WMI_WOW_MAX_EVENT_BM_LEN);
13813
13814 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13815 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13816 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013817
13818 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13819 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13820 if (ret) {
13821 WMI_LOGE("Failed to config wow wakeup event");
13822 wmi_buf_free(buf);
13823 return QDF_STATUS_E_FAILURE;
13824 }
13825
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013826 return QDF_STATUS_SUCCESS;
13827}
13828
13829/**
13830 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13831 * @wmi_handle: wmi handle
13832 * @vdev_id: vdev id
13833 * @ptrn_id: pattern id
13834 * @ptrn: pattern
13835 * @ptrn_len: pattern length
13836 * @ptrn_offset: pattern offset
13837 * @mask: mask
13838 * @mask_len: mask length
13839 * @user: true for user configured pattern and false for default pattern
13840 * @default_patterns: default patterns
13841 *
13842 * Return: CDF status
13843 */
13844static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13845 uint8_t vdev_id, uint8_t ptrn_id,
13846 const uint8_t *ptrn, uint8_t ptrn_len,
13847 uint8_t ptrn_offset, const uint8_t *mask,
13848 uint8_t mask_len, bool user,
13849 uint8_t default_patterns)
13850{
13851 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13852 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13853 wmi_buf_t buf;
13854 uint8_t *buf_ptr;
13855 int32_t len;
13856 int ret;
13857
13858 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13859 WMI_TLV_HDR_SIZE +
13860 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13861 WMI_TLV_HDR_SIZE +
13862 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13863 WMI_TLV_HDR_SIZE +
13864 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13865 WMI_TLV_HDR_SIZE +
13866 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13867 WMI_TLV_HDR_SIZE +
13868 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13869
13870 buf = wmi_buf_alloc(wmi_handle, len);
13871 if (!buf) {
13872 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13873 return QDF_STATUS_E_NOMEM;
13874 }
13875
13876 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13877 buf_ptr = (uint8_t *) cmd;
13878
13879 WMITLV_SET_HDR(&cmd->tlv_header,
13880 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13881 WMITLV_GET_STRUCT_TLVLEN
13882 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13883 cmd->vdev_id = vdev_id;
13884 cmd->pattern_id = ptrn_id;
13885
13886 cmd->pattern_type = WOW_BITMAP_PATTERN;
13887 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13888
13889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13890 sizeof(WOW_BITMAP_PATTERN_T));
13891 buf_ptr += WMI_TLV_HDR_SIZE;
13892 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13893
13894 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13895 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13896 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13897
13898 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13899 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13900
13901 bitmap_pattern->pattern_offset = ptrn_offset;
13902 bitmap_pattern->pattern_len = ptrn_len;
13903
13904 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13905 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13906
13907 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13908 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13909
13910 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13911 bitmap_pattern->pattern_id = ptrn_id;
13912
13913 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13914 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13915 bitmap_pattern->pattern_offset, user);
13916 WMI_LOGI("Pattern : ");
13917 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13918 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13919
13920 WMI_LOGI("Mask : ");
13921 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13922 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13923
13924 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13925
13926 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13928 buf_ptr += WMI_TLV_HDR_SIZE;
13929
13930 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13931 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13932 buf_ptr += WMI_TLV_HDR_SIZE;
13933
13934 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13935 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13936 buf_ptr += WMI_TLV_HDR_SIZE;
13937
13938 /* Fill TLV for pattern_info_timeout but no data. */
13939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13940 buf_ptr += WMI_TLV_HDR_SIZE;
13941
13942 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
13943 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
13944 buf_ptr += WMI_TLV_HDR_SIZE;
13945 *(A_UINT32 *) buf_ptr = 0;
13946
13947 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13948 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13949 if (ret) {
13950 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13951 wmi_buf_free(buf);
13952 return QDF_STATUS_E_FAILURE;
13953 }
13954
13955 return QDF_STATUS_SUCCESS;
13956}
13957
Govind Singha4836fd2016-03-07 16:45:38 +053013958/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013959 * fill_arp_offload_params_tlv() - Fill ARP offload data
13960 * @wmi_handle: wmi handle
13961 * @offload_req: offload request
13962 * @buf_ptr: buffer pointer
13963 *
13964 * To fill ARP offload data to firmware
13965 * when target goes to wow mode.
13966 *
13967 * Return: None
13968 */
13969static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013970 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013971{
13972
13973 int i;
13974 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013975 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013976
13977 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13978 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13979 *buf_ptr += WMI_TLV_HDR_SIZE;
13980 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13981 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13982 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13983 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13984 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13985
13986 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013987 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013988 /* Copy the target ip addr and flags */
13989 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13990 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013991 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013992 WMI_IPV4_ADDR_LEN);
13993 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013994 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013995 }
13996 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13997 }
13998}
13999
14000#ifdef WLAN_NS_OFFLOAD
14001/**
14002 * fill_ns_offload_params_tlv() - Fill NS offload data
14003 * @wmi|_handle: wmi handle
14004 * @offload_req: offload request
14005 * @buf_ptr: buffer pointer
14006 *
14007 * To fill NS offload data to firmware
14008 * when target goes to wow mode.
14009 *
14010 * Return: None
14011 */
14012static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014013 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014014{
14015
14016 int i;
14017 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014018
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014019 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14020 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14021 *buf_ptr += WMI_TLV_HDR_SIZE;
14022 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14023 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14024 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14025 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14026 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14027
14028 /*
14029 * Fill data only for NS offload in the first ARP tuple for LA
14030 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014031 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014032 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14033 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014034 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014035 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014036 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014037 sizeof(WMI_IPV6_ADDR));
14038 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014039 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014040 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014041 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014042 ns_tuple->flags |=
14043 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14044 }
14045 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014046 i, &ns_req->self_ipv6_addr[i],
14047 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014048
14049 /* target MAC is optional, check if it is valid,
14050 * if this is not valid, the target will use the known
14051 * local MAC address rather than the tuple
14052 */
14053 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014054 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014055 &ns_tuple->target_mac);
14056 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14057 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14058 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14059 }
14060 }
14061 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14062 }
14063}
14064
14065
14066/**
14067 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14068 * @wmi: wmi handle
14069 * @offload_req: offload request
14070 * @buf_ptr: buffer pointer
14071 *
14072 * To fill extended NS offload extended data to firmware
14073 * when target goes to wow mode.
14074 *
14075 * Return: None
14076 */
14077static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014078 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014079{
14080 int i;
14081 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14082 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014083
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014084 count = ns_req->num_ns_offload_count;
14085 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014086 WMI_MAX_NS_OFFLOADS;
14087
14088 /* Populate extended NS offload tuples */
14089 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14090 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14091 *buf_ptr += WMI_TLV_HDR_SIZE;
14092 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14093 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14094 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14095 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14096 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14097
14098 /*
14099 * Fill data only for NS offload in the first ARP tuple for LA
14100 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014101 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014102 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14103 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014104 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014105 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014106 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014107 sizeof(WMI_IPV6_ADDR));
14108 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014109 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014110 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014111 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014112 ns_tuple->flags |=
14113 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14114 }
14115 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014116 i, &ns_req->self_ipv6_addr[i],
14117 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014118
14119 /* target MAC is optional, check if it is valid,
14120 * if this is not valid, the target will use the
14121 * known local MAC address rather than the tuple
14122 */
14123 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014124 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014125 &ns_tuple->target_mac);
14126 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14127 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14128 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14129 }
14130 }
14131 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14132 }
14133}
14134#else
14135static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014136 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014137{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014138}
14139
14140static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014141 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014142{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014143}
14144#endif
14145
14146/**
Govind Singha4836fd2016-03-07 16:45:38 +053014147 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14148 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014149 * @arp_offload_req: arp offload request
14150 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014151 * @arp_only: flag
14152 *
14153 * To configure ARP NS off load data to firmware
14154 * when target goes to wow mode.
14155 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014156 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014157 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014158static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014159 struct pmo_arp_offload_params *arp_offload_req,
14160 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014161 uint8_t vdev_id)
14162{
Govind Singha4836fd2016-03-07 16:45:38 +053014163 int32_t res;
14164 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053014165 A_UINT8 *buf_ptr;
14166 wmi_buf_t buf;
14167 int32_t len;
14168 uint32_t count = 0, num_ns_ext_tuples = 0;
14169
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014170 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014171
Govind Singha4836fd2016-03-07 16:45:38 +053014172 /*
14173 * TLV place holder size for array of NS tuples
14174 * TLV place holder size for array of ARP tuples
14175 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014176 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14177 WMI_TLV_HDR_SIZE +
14178 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14179 WMI_TLV_HDR_SIZE +
14180 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014181
14182 /*
14183 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14184 * extra length for extended NS offload tuples which follows ARP offload
14185 * tuples. Host needs to fill this structure in following format:
14186 * 2 NS ofload tuples
14187 * 2 ARP offload tuples
14188 * N numbers of extended NS offload tuples if HDD has given more than
14189 * 2 NS offload addresses
14190 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014191 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014192 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014193 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14194 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014195 }
14196
14197 buf = wmi_buf_alloc(wmi_handle, len);
14198 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014199 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014200 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014201 }
14202
14203 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14204 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14205 WMITLV_SET_HDR(&cmd->tlv_header,
14206 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14207 WMITLV_GET_STRUCT_TLVLEN
14208 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14209 cmd->flags = 0;
14210 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014211 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014212
Govind Singhb53420c2016-03-09 14:32:57 +053014213 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014214
Govind Singha4836fd2016-03-07 16:45:38 +053014215 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014216 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14217 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14218 if (num_ns_ext_tuples)
14219 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014220
14221 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14222 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14223 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014224 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014226 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014227 }
14228
Govind Singhb53420c2016-03-09 14:32:57 +053014229 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014230}
14231
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014232/**
14233 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14234 * @wmi_handle: wmi handle
14235 * @vdev_id: vdev id
14236 * @action: true for enable else false
14237 *
14238 * To enable enhance multicast offload to firmware
14239 * when target goes to wow mode.
14240 *
14241 * Return: QDF Status
14242 */
14243
14244static
14245QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14246 wmi_unified_t wmi_handle,
14247 uint8_t vdev_id, bool action)
14248{
14249 QDF_STATUS status;
14250 wmi_buf_t buf;
14251 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14252
14253 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14254 if (!buf) {
14255 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14256 return QDF_STATUS_E_NOMEM;
14257 }
14258
14259 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14260 wmi_buf_data(buf);
14261
14262 WMITLV_SET_HDR(&cmd->tlv_header,
14263 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14264 WMITLV_GET_STRUCT_TLVLEN(
14265 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14266
14267 cmd->vdev_id = vdev_id;
14268 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14269 ENHANCED_MCAST_FILTER_ENABLED);
14270 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14271 __func__, action, vdev_id);
14272 status = wmi_unified_cmd_send(wmi_handle, buf,
14273 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14274 if (status != QDF_STATUS_SUCCESS) {
14275 qdf_nbuf_free(buf);
14276 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14277 __func__);
14278 }
14279
14280 return status;
14281}
14282
14283/**
14284 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14285 * @wmi_handle: wmi handle
14286 * @param evt_buf: pointer to event buffer
14287 * @param hdr: Pointer to hold header
14288 * @param bufp: Pointer to hold pointer to rx param buffer
14289 *
14290 * Return: QDF_STATUS_SUCCESS for success or error code
14291 */
14292static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14293 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14294{
14295 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14296 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14297
14298 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14299 if (!param_buf) {
14300 WMI_LOGE("gtk param_buf is NULL");
14301 return QDF_STATUS_E_INVAL;
14302 }
14303
14304 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14305 WMI_LOGE("Invalid length for GTK status");
14306 return QDF_STATUS_E_INVAL;
14307 }
14308
14309 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14310 param_buf->fixed_param;
14311 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14312 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14313 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14314 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14315 &fixed_param->replay_counter,
14316 GTK_REPLAY_COUNTER_BYTES);
14317
14318 return QDF_STATUS_SUCCESS;
14319
14320}
14321
14322#ifdef FEATURE_WLAN_RA_FILTERING
14323/**
14324 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14325 * @wmi_handle: wmi handle
14326 * @vdev_id: vdev id
14327 *
14328 * Return: CDF status
14329 */
14330static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14331 uint8_t vdev_id, uint8_t default_pattern,
14332 uint16_t rate_limit_interval)
14333{
14334
14335 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14336 wmi_buf_t buf;
14337 uint8_t *buf_ptr;
14338 int32_t len;
14339 int ret;
14340
14341 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14342 WMI_TLV_HDR_SIZE +
14343 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14344 WMI_TLV_HDR_SIZE +
14345 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14346 WMI_TLV_HDR_SIZE +
14347 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14348 WMI_TLV_HDR_SIZE +
14349 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14350 WMI_TLV_HDR_SIZE +
14351 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14352
14353 buf = wmi_buf_alloc(wmi_handle, len);
14354 if (!buf) {
14355 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14356 return QDF_STATUS_E_NOMEM;
14357 }
14358
14359 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14360 buf_ptr = (uint8_t *) cmd;
14361
14362 WMITLV_SET_HDR(&cmd->tlv_header,
14363 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14364 WMITLV_GET_STRUCT_TLVLEN
14365 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14366 cmd->vdev_id = vdev_id;
14367 cmd->pattern_id = default_pattern,
14368 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14369 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14370
14371 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14373 buf_ptr += WMI_TLV_HDR_SIZE;
14374
14375 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14377 buf_ptr += WMI_TLV_HDR_SIZE;
14378
14379 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14381 buf_ptr += WMI_TLV_HDR_SIZE;
14382
14383 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14384 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14385 buf_ptr += WMI_TLV_HDR_SIZE;
14386
14387 /* Fill TLV for pattern_info_timeout but no data. */
14388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14389 buf_ptr += WMI_TLV_HDR_SIZE;
14390
14391 /* Fill TLV for ra_ratelimit_interval. */
14392 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
14393 buf_ptr += WMI_TLV_HDR_SIZE;
14394
14395 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
14396
14397 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14398 rate_limit_interval, vdev_id);
14399
14400 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14401 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14402 if (ret) {
14403 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14404 wmi_buf_free(buf);
14405 return QDF_STATUS_E_FAILURE;
14406 }
14407
14408 return QDF_STATUS_SUCCESS;
14409
14410}
14411#endif /* FEATURE_WLAN_RA_FILTERING */
14412
14413/**
14414 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14415 * @wmi_handle: wmi handle
14416 * @vdev_id: vdev id
14417 * @multicastAddr: mcast address
14418 * @clearList: clear list flag
14419 *
14420 * Return: QDF_STATUS_SUCCESS for success or error code
14421 */
14422static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14423 uint8_t vdev_id,
14424 struct qdf_mac_addr multicast_addr,
14425 bool clearList)
14426{
14427 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14428 wmi_buf_t buf;
14429 int err;
14430
14431 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14432 if (!buf) {
14433 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14434 return QDF_STATUS_E_NOMEM;
14435 }
14436
14437 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14438 qdf_mem_zero(cmd, sizeof(*cmd));
14439
14440 WMITLV_SET_HDR(&cmd->tlv_header,
14441 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14442 WMITLV_GET_STRUCT_TLVLEN
14443 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14444 cmd->action =
14445 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14446 cmd->vdev_id = vdev_id;
14447 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14448
14449 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14450 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14451
14452 err = wmi_unified_cmd_send(wmi_handle, buf,
14453 sizeof(*cmd),
14454 WMI_SET_MCASTBCAST_FILTER_CMDID);
14455 if (err) {
14456 WMI_LOGE("Failed to send set_param cmd");
14457 wmi_buf_free(buf);
14458 return QDF_STATUS_E_FAILURE;
14459 }
14460
14461 return QDF_STATUS_SUCCESS;
14462}
14463
14464/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014465 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14466 * command to fw
14467 * @wmi_handle: wmi handle
14468 * @vdev_id: vdev id
14469 * @mcast_filter_params: mcast filter params
14470 *
14471 * Return: QDF_STATUS_SUCCESS for success or error code
14472 */
14473static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14474 wmi_unified_t wmi_handle,
14475 uint8_t vdev_id,
14476 struct pmo_mcast_filter_params *filter_param)
14477
14478{
14479 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14480 uint8_t *buf_ptr;
14481 wmi_buf_t buf;
14482 int err;
14483 int i;
14484 uint8_t *mac_addr_src_ptr = NULL;
14485 wmi_mac_addr *mac_addr_dst_ptr;
14486 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14487 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14488
14489 buf = wmi_buf_alloc(wmi_handle, len);
14490 if (!buf) {
14491 WMI_LOGE("Failed to allocate memory");
14492 return QDF_STATUS_E_NOMEM;
14493 }
14494
14495 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14496 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14497 wmi_buf_data(buf);
14498 qdf_mem_zero(cmd, sizeof(*cmd));
14499
14500 WMITLV_SET_HDR(&cmd->tlv_header,
14501 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14502 WMITLV_GET_STRUCT_TLVLEN
14503 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14504 cmd->operation =
14505 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14506 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14507 cmd->vdev_id = vdev_id;
14508 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14509
14510 buf_ptr += sizeof(*cmd);
14511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14512 sizeof(wmi_mac_addr) *
14513 filter_param->multicast_addr_cnt);
14514
14515 if (filter_param->multicast_addr_cnt == 0)
14516 goto send_cmd;
14517
14518 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14519 mac_addr_dst_ptr = (wmi_mac_addr *)
14520 (buf_ptr + WMI_TLV_HDR_SIZE);
14521
14522 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14523 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14524 mac_addr_src_ptr += ATH_MAC_LEN;
14525 mac_addr_dst_ptr++;
14526 }
14527
14528send_cmd:
14529 err = wmi_unified_cmd_send(wmi_handle, buf,
14530 len,
14531 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14532 if (err) {
14533 WMI_LOGE("Failed to send set_param cmd");
14534 wmi_buf_free(buf);
14535 return QDF_STATUS_E_FAILURE;
14536 }
14537
14538 return QDF_STATUS_SUCCESS;
14539}
14540
14541
14542/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014543 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14544 * @wmi_handle: wmi handle
14545 * @vdev_id: vdev id
14546 * @params: GTK offload parameters
14547 *
14548 * Return: CDF status
14549 */
14550static
14551QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14552 struct pmo_gtk_req *params,
14553 bool enable_offload,
14554 uint32_t gtk_offload_opcode)
14555{
14556 int len;
14557 wmi_buf_t buf;
14558 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014559 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014560 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014561 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014562
14563 WMI_LOGD("%s Enter", __func__);
14564
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014565 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014566
14567 /* alloc wmi buffer */
14568 buf = wmi_buf_alloc(wmi_handle, len);
14569 if (!buf) {
14570 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14571 status = QDF_STATUS_E_NOMEM;
14572 goto out;
14573 }
14574
14575 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014576 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014577 WMITLV_SET_HDR(&cmd->tlv_header,
14578 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14579 WMITLV_GET_STRUCT_TLVLEN
14580 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14581
14582 cmd->vdev_id = vdev_id;
14583
14584 /* Request target to enable GTK offload */
14585 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14586 cmd->flags = gtk_offload_opcode;
14587
14588 /* Copy the keys and replay counter */
14589 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014590 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014591 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14592 GTK_REPLAY_COUNTER_BYTES);
14593 } else {
14594 cmd->flags = gtk_offload_opcode;
14595 }
14596
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014597 buf_ptr += sizeof(*cmd);
14598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
14599 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014600
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014601 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14602 WMITLV_SET_HDR(&ext_param->tlv_header,
14603 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14604 WMITLV_GET_STRUCT_TLVLEN(
14605 wmi_gtk_offload_fils_tlv_param));
14606 ext_param->vdev_id = vdev_id;
14607 ext_param->flags = cmd->flags;
14608 ext_param->kek_len = params->kek_len;
14609 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14610 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
14611 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14612 GTK_REPLAY_COUNTER_BYTES);
14613
14614 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 +053014615 /* send the wmi command */
14616 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14617 WMI_GTK_OFFLOAD_CMDID)) {
14618 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14619 wmi_buf_free(buf);
14620 status = QDF_STATUS_E_FAILURE;
14621 }
14622
14623out:
14624 WMI_LOGD("%s Exit", __func__);
14625 return status;
14626}
14627
14628/**
14629 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14630 * @wmi_handle: wmi handle
14631 * @params: GTK offload params
14632 *
14633 * Return: CDF status
14634 */
14635static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14636 wmi_unified_t wmi_handle,
14637 uint8_t vdev_id,
14638 uint64_t offload_req_opcode)
14639{
14640 int len;
14641 wmi_buf_t buf;
14642 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14643 QDF_STATUS status = QDF_STATUS_SUCCESS;
14644
14645 len = sizeof(*cmd);
14646
14647 /* alloc wmi buffer */
14648 buf = wmi_buf_alloc(wmi_handle, len);
14649 if (!buf) {
14650 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14651 status = QDF_STATUS_E_NOMEM;
14652 goto out;
14653 }
14654
14655 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14656 WMITLV_SET_HDR(&cmd->tlv_header,
14657 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14658 WMITLV_GET_STRUCT_TLVLEN
14659 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14660
14661 /* Request for GTK offload status */
14662 cmd->flags = offload_req_opcode;
14663 cmd->vdev_id = vdev_id;
14664
14665 /* send the wmi command */
14666 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14667 WMI_GTK_OFFLOAD_CMDID)) {
14668 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14669 wmi_buf_free(buf);
14670 status = QDF_STATUS_E_FAILURE;
14671 }
14672
14673out:
14674 return status;
14675}
14676
14677/**
14678 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14679 * @wmi_handle: wmi handler
14680 * @action_params: pointer to action_params
14681 *
14682 * Return: 0 for success, otherwise appropriate error code
14683 */
14684static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14685 struct pmo_action_wakeup_set_params *action_params)
14686{
14687 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14688 wmi_buf_t buf;
14689 int i;
14690 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014691 uint32_t len = 0, *cmd_args;
14692 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014693
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014694 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
14695 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14696 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014697 if (!buf) {
14698 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14699 return QDF_STATUS_E_NOMEM;
14700 }
14701 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014702 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014703 WMITLV_SET_HDR(&cmd->tlv_header,
14704 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14705 WMITLV_GET_STRUCT_TLVLEN(
14706 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14707
14708 cmd->vdev_id = action_params->vdev_id;
14709 cmd->operation = action_params->operation;
14710
14711 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14712 cmd->action_category_map[i] =
14713 action_params->action_category_map[i];
14714
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014715 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14717 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
14718 buf_ptr += WMI_TLV_HDR_SIZE;
14719 cmd_args = (uint32_t *) buf_ptr;
14720 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14721 cmd_args[i] = action_params->action_per_category[i];
14722
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014723 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014724 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014725 if (err) {
14726 WMI_LOGE("Failed to send ap_ps_egap cmd");
14727 wmi_buf_free(buf);
14728 return QDF_STATUS_E_FAILURE;
14729 }
14730
14731 return QDF_STATUS_SUCCESS;
14732}
14733
14734#ifdef FEATURE_WLAN_LPHB
14735
14736/**
14737 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14738 * @wmi_handle: wmi handle
14739 * @lphb_conf_req: configuration info
14740 *
14741 * Return: CDF status
14742 */
14743static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14744 wmi_hb_set_enable_cmd_fixed_param *params)
14745{
14746 QDF_STATUS status;
14747 wmi_buf_t buf = NULL;
14748 uint8_t *buf_ptr;
14749 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14750 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14751
14752
14753 buf = wmi_buf_alloc(wmi_handle, len);
14754 if (!buf) {
14755 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14756 return QDF_STATUS_E_NOMEM;
14757 }
14758
14759 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14760 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14761 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14762 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14763 WMITLV_GET_STRUCT_TLVLEN
14764 (wmi_hb_set_enable_cmd_fixed_param));
14765
14766 /* fill in values */
14767 hb_enable_fp->vdev_id = params->session;
14768 hb_enable_fp->enable = params->enable;
14769 hb_enable_fp->item = params->item;
14770 hb_enable_fp->session = params->session;
14771
14772 status = wmi_unified_cmd_send(wmi_handle, buf,
14773 len, WMI_HB_SET_ENABLE_CMDID);
14774 if (QDF_IS_STATUS_ERROR(status)) {
14775 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14776 status);
14777 wmi_buf_free(buf);
14778 }
14779
14780 return status;
14781}
14782
14783/**
14784 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14785 * @wmi_handle: wmi handle
14786 * @lphb_conf_req: lphb config request
14787 *
14788 * Return: CDF status
14789 */
14790static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14791 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14792{
14793 QDF_STATUS status;
14794 wmi_buf_t buf = NULL;
14795 uint8_t *buf_ptr;
14796 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14797 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14798
14799 buf = wmi_buf_alloc(wmi_handle, len);
14800 if (!buf) {
14801 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14802 return QDF_STATUS_E_NOMEM;
14803 }
14804
14805 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14806 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14807 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14808 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14809 WMITLV_GET_STRUCT_TLVLEN
14810 (wmi_hb_set_tcp_params_cmd_fixed_param));
14811
14812 /* fill in values */
14813 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14814 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14815 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14816 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14817 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14818 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14819 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14820 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14821 hb_tcp_params_fp->session = lphb_conf_req->session;
14822 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14823 &lphb_conf_req->gateway_mac,
14824 sizeof(hb_tcp_params_fp->gateway_mac));
14825
14826 status = wmi_unified_cmd_send(wmi_handle, buf,
14827 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14828 if (QDF_IS_STATUS_ERROR(status)) {
14829 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14830 status);
14831 wmi_buf_free(buf);
14832 }
14833
14834 return status;
14835}
14836
14837/**
14838 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14839 * @wmi_handle: wmi handle
14840 * @lphb_conf_req: lphb config request
14841 *
14842 * Return: CDF status
14843 */
14844static
14845QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14846 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14847{
14848 QDF_STATUS status;
14849 wmi_buf_t buf = NULL;
14850 uint8_t *buf_ptr;
14851 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14852 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14853
14854 buf = wmi_buf_alloc(wmi_handle, len);
14855 if (!buf) {
14856 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14857 return QDF_STATUS_E_NOMEM;
14858 }
14859
14860 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14861 hb_tcp_filter_fp =
14862 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14863 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14864 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14865 WMITLV_GET_STRUCT_TLVLEN
14866 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14867
14868 /* fill in values */
14869 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14870 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14871 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14872 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14873 memcpy((void *)&hb_tcp_filter_fp->filter,
14874 (void *)&g_hb_tcp_filter_fp->filter,
14875 WMI_WLAN_HB_MAX_FILTER_SIZE);
14876
14877 status = wmi_unified_cmd_send(wmi_handle, buf,
14878 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14879 if (QDF_IS_STATUS_ERROR(status)) {
14880 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14881 status);
14882 wmi_buf_free(buf);
14883 }
14884
14885 return status;
14886}
14887
14888/**
14889 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14890 * @wmi_handle: wmi handle
14891 * @lphb_conf_req: lphb config request
14892 *
14893 * Return: CDF status
14894 */
14895static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14896 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14897{
14898 QDF_STATUS status;
14899 wmi_buf_t buf = NULL;
14900 uint8_t *buf_ptr;
14901 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14902 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14903
14904 buf = wmi_buf_alloc(wmi_handle, len);
14905 if (!buf) {
14906 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14907 return QDF_STATUS_E_NOMEM;
14908 }
14909
14910 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14911 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14912 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14913 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14914 WMITLV_GET_STRUCT_TLVLEN
14915 (wmi_hb_set_udp_params_cmd_fixed_param));
14916
14917 /* fill in values */
14918 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14919 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14920 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14921 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14922 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14923 hb_udp_params_fp->interval = lphb_conf_req->interval;
14924 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14925 hb_udp_params_fp->session = lphb_conf_req->session;
14926 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14927 &lphb_conf_req->gateway_mac,
14928 sizeof(lphb_conf_req->gateway_mac));
14929
14930 status = wmi_unified_cmd_send(wmi_handle, buf,
14931 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14932 if (QDF_IS_STATUS_ERROR(status)) {
14933 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14934 status);
14935 wmi_buf_free(buf);
14936 }
14937
14938 return status;
14939}
14940
14941/**
14942 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14943 * @wmi_handle: wmi handle
14944 * @lphb_conf_req: lphb config request
14945 *
14946 * Return: CDF status
14947 */
14948static
14949QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14950 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14951{
14952 QDF_STATUS status;
14953 wmi_buf_t buf = NULL;
14954 uint8_t *buf_ptr;
14955 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14956 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14957
14958 buf = wmi_buf_alloc(wmi_handle, len);
14959 if (!buf) {
14960 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14961 return QDF_STATUS_E_NOMEM;
14962 }
14963
14964 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14965 hb_udp_filter_fp =
14966 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14967 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14968 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14969 WMITLV_GET_STRUCT_TLVLEN
14970 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14971
14972 /* fill in values */
14973 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14974 hb_udp_filter_fp->length = lphb_conf_req->length;
14975 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14976 hb_udp_filter_fp->session = lphb_conf_req->session;
14977 memcpy((void *)&hb_udp_filter_fp->filter,
14978 (void *)&lphb_conf_req->filter,
14979 WMI_WLAN_HB_MAX_FILTER_SIZE);
14980
14981 status = wmi_unified_cmd_send(wmi_handle, buf,
14982 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14983 if (QDF_IS_STATUS_ERROR(status)) {
14984 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14985 status);
14986 wmi_buf_free(buf);
14987 }
14988
14989 return status;
14990}
14991#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014992
Dustin Brownf31f88b2017-05-12 14:01:44 -070014993static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14994 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014995{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014996 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014997 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014998 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014999
Dustin Brownf31f88b2017-05-12 14:01:44 -070015000 if (!req) {
15001 WMI_LOGE("req is null");
15002 return QDF_STATUS_E_INVAL;
15003 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015004
Dustin Brownf31f88b2017-05-12 14:01:44 -070015005 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15006 if (!wmi_buf) {
15007 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015008 return QDF_STATUS_E_NOMEM;
15009 }
15010
Dustin Brownf31f88b2017-05-12 14:01:44 -070015011 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015012 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015013 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15014 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15015 cmd->vdev_id = req->vdev_id;
15016 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15017 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015018
Dustin Brownf31f88b2017-05-12 14:01:44 -070015019 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15020 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015021
Dustin Brownf31f88b2017-05-12 14:01:44 -070015022 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15023 WMI_HW_DATA_FILTER_CMDID);
15024 if (QDF_IS_STATUS_ERROR(status)) {
15025 WMI_LOGE("Failed to configure hw filter");
15026 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015027 }
15028
Dustin Brownf31f88b2017-05-12 14:01:44 -070015029 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015030}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015031
15032/**
15033 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15034 * @wmi_handle: wmi handle
15035 * @vdev_id: vdev id
15036 * @enable: Flag to enable/disable packet filter
15037 *
15038 * Return: QDF_STATUS_SUCCESS for success or error code
15039 */
15040static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15041 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15042{
15043 int32_t len;
15044 int ret = 0;
15045 wmi_buf_t buf;
15046 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15047
15048 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15049
15050 buf = wmi_buf_alloc(wmi_handle, len);
15051 if (!buf) {
15052 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15053 return QDF_STATUS_E_NOMEM;
15054 }
15055
15056 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15057 WMITLV_SET_HDR(&cmd->tlv_header,
15058 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15059 WMITLV_GET_STRUCT_TLVLEN(
15060 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15061
15062 cmd->vdev_id = vdev_id;
15063 if (enable)
15064 cmd->enable = PACKET_FILTER_SET_ENABLE;
15065 else
15066 cmd->enable = PACKET_FILTER_SET_DISABLE;
15067
15068 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15069 __func__, cmd->enable, vdev_id);
15070
15071 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15072 WMI_PACKET_FILTER_ENABLE_CMDID);
15073 if (ret) {
15074 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15075 wmi_buf_free(buf);
15076 }
15077
15078 return ret;
15079}
15080
15081/**
15082 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15083 * @wmi_handle: wmi handle
15084 * @vdev_id: vdev id
15085 * @rcv_filter_param: Packet filter parameters
15086 * @filter_id: Filter id
15087 * @enable: Flag to add/delete packet filter configuration
15088 *
15089 * Return: QDF_STATUS_SUCCESS for success or error code
15090 */
15091static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15092 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15093 uint8_t filter_id, bool enable)
15094{
15095 int len, i;
15096 int err = 0;
15097 wmi_buf_t buf;
15098 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15099
15100
15101 /* allocate the memory */
15102 len = sizeof(*cmd);
15103 buf = wmi_buf_alloc(wmi_handle, len);
15104 if (!buf) {
15105 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15106 return QDF_STATUS_E_NOMEM;
15107 }
15108
15109 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15110 WMITLV_SET_HDR(&cmd->tlv_header,
15111 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15112 WMITLV_GET_STRUCT_TLVLEN
15113 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15114
15115 cmd->vdev_id = vdev_id;
15116 cmd->filter_id = filter_id;
15117 if (enable)
15118 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15119 else
15120 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15121
15122 if (enable) {
15123 cmd->num_params = QDF_MIN(
15124 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15125 rcv_filter_param->num_params);
15126 cmd->filter_type = rcv_filter_param->filter_type;
15127 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15128
15129 for (i = 0; i < cmd->num_params; i++) {
15130 cmd->paramsData[i].proto_type =
15131 rcv_filter_param->params_data[i].protocol_layer;
15132 cmd->paramsData[i].cmp_type =
15133 rcv_filter_param->params_data[i].compare_flag;
15134 cmd->paramsData[i].data_length =
15135 rcv_filter_param->params_data[i].data_length;
15136 cmd->paramsData[i].data_offset =
15137 rcv_filter_param->params_data[i].data_offset;
15138 memcpy(&cmd->paramsData[i].compareData,
15139 rcv_filter_param->params_data[i].compare_data,
15140 sizeof(cmd->paramsData[i].compareData));
15141 memcpy(&cmd->paramsData[i].dataMask,
15142 rcv_filter_param->params_data[i].data_mask,
15143 sizeof(cmd->paramsData[i].dataMask));
15144 }
15145 }
15146
15147 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15148 cmd->filter_action, cmd->filter_id, cmd->num_params);
15149 /* send the command along with data */
15150 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15151 WMI_PACKET_FILTER_CONFIG_CMDID);
15152 if (err) {
15153 WMI_LOGE("Failed to send pkt_filter cmd");
15154 wmi_buf_free(buf);
15155 return QDF_STATUS_E_FAILURE;
15156 }
15157
15158 return QDF_STATUS_SUCCESS;
15159}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015160#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015161
Govind Singha4836fd2016-03-07 16:45:38 +053015162/**
15163 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15164 * @wmi_handle: wmi handle
15165 * @request: SSID hotlist set request
15166 *
Govind Singhb53420c2016-03-09 14:32:57 +053015167 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015168 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015169static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015170send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15171 struct ssid_hotlist_request_params *request)
15172{
15173 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15174 wmi_buf_t wmi_buf;
15175 uint32_t len;
15176 uint32_t array_size;
15177 uint8_t *buf_ptr;
15178
15179 /* length of fixed portion */
15180 len = sizeof(*cmd);
15181
15182 /* length of variable portion */
15183 array_size =
15184 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15185 len += WMI_TLV_HDR_SIZE + array_size;
15186
15187 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15188 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015189 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15190 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015191 }
15192
15193 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15194 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15195 buf_ptr;
15196 WMITLV_SET_HDR
15197 (&cmd->tlv_header,
15198 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15199 WMITLV_GET_STRUCT_TLVLEN
15200 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15201
15202 cmd->request_id = request->request_id;
15203 cmd->requestor_id = 0;
15204 cmd->vdev_id = request->session_id;
15205 cmd->table_id = 0;
15206 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15207 cmd->total_entries = request->ssid_count;
15208 cmd->num_entries_in_page = request->ssid_count;
15209 cmd->first_entry_index = 0;
15210
15211 buf_ptr += sizeof(*cmd);
15212 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15213
15214 if (request->ssid_count) {
15215 wmi_extscan_hotlist_ssid_entry *entry;
15216 int i;
15217
15218 buf_ptr += WMI_TLV_HDR_SIZE;
15219 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15220 for (i = 0; i < request->ssid_count; i++) {
15221 WMITLV_SET_HDR
15222 (entry,
15223 WMITLV_TAG_ARRAY_STRUC,
15224 WMITLV_GET_STRUCT_TLVLEN
15225 (wmi_extscan_hotlist_ssid_entry));
15226 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015227 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015228 request->ssids[i].ssid.mac_ssid,
15229 request->ssids[i].ssid.length);
15230 entry->band = request->ssids[i].band;
15231 entry->min_rssi = request->ssids[i].rssi_low;
15232 entry->max_rssi = request->ssids[i].rssi_high;
15233 entry++;
15234 }
15235 cmd->mode = WMI_EXTSCAN_MODE_START;
15236 } else {
15237 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15238 }
15239
15240 if (wmi_unified_cmd_send
15241 (wmi_handle, wmi_buf, len,
15242 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015243 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015244 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015245 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015246 }
15247
Govind Singhb53420c2016-03-09 14:32:57 +053015248 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015249}
15250
15251/**
15252 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15253 * @wmi_handle: wmi handle
15254 * @vdev_id: vdev id
15255 *
15256 * This function sends roam synch complete event to fw.
15257 *
15258 * Return: CDF STATUS
15259 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015260static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015261 uint8_t vdev_id)
15262{
15263 wmi_roam_synch_complete_fixed_param *cmd;
15264 wmi_buf_t wmi_buf;
15265 uint8_t *buf_ptr;
15266 uint16_t len;
15267 len = sizeof(wmi_roam_synch_complete_fixed_param);
15268
15269 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15270 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015271 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15272 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015273 }
15274 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15275 buf_ptr = (uint8_t *) cmd;
15276 WMITLV_SET_HDR(&cmd->tlv_header,
15277 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15278 WMITLV_GET_STRUCT_TLVLEN
15279 (wmi_roam_synch_complete_fixed_param));
15280 cmd->vdev_id = vdev_id;
15281 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15282 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015283 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015284 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015285 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015286 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015287 }
15288
Govind Singhb53420c2016-03-09 14:32:57 +053015289 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015290}
15291
15292/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015293 * send_fw_test_cmd_tlv() - send fw test command to fw.
15294 * @wmi_handle: wmi handle
15295 * @wmi_fwtest: fw test command
15296 *
15297 * This function sends fw test command to fw.
15298 *
15299 * Return: CDF STATUS
15300 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015301static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015302QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15303 struct set_fwtest_params *wmi_fwtest)
15304{
15305 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15306 wmi_buf_t wmi_buf;
15307 uint16_t len;
15308
15309 len = sizeof(*cmd);
15310
15311 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15312 if (!wmi_buf) {
15313 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15314 return QDF_STATUS_E_NOMEM;
15315 }
15316
15317 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15318 WMITLV_SET_HDR(&cmd->tlv_header,
15319 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15320 WMITLV_GET_STRUCT_TLVLEN(
15321 wmi_fwtest_set_param_cmd_fixed_param));
15322 cmd->param_id = wmi_fwtest->arg;
15323 cmd->param_value = wmi_fwtest->value;
15324
15325 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15326 WMI_FWTEST_CMDID)) {
15327 WMI_LOGP("%s: failed to send fw test command", __func__);
15328 qdf_nbuf_free(wmi_buf);
15329 return QDF_STATUS_E_FAILURE;
15330 }
15331
15332 return QDF_STATUS_SUCCESS;
15333}
15334
15335/**
Govind Singha4836fd2016-03-07 16:45:38 +053015336 * send_unit_test_cmd_tlv() - send unit test command to fw.
15337 * @wmi_handle: wmi handle
15338 * @wmi_utest: unit test command
15339 *
15340 * This function send unit test command to fw.
15341 *
15342 * Return: CDF STATUS
15343 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015344static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015345 struct wmi_unit_test_cmd *wmi_utest)
15346{
15347 wmi_unit_test_cmd_fixed_param *cmd;
15348 wmi_buf_t wmi_buf;
15349 uint8_t *buf_ptr;
15350 int i;
15351 uint16_t len, args_tlv_len;
15352 A_UINT32 *unit_test_cmd_args;
15353
15354 args_tlv_len =
15355 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
15356 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15357
15358 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15359 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015360 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15361 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015362 }
15363
15364 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15365 buf_ptr = (uint8_t *) cmd;
15366 WMITLV_SET_HDR(&cmd->tlv_header,
15367 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15368 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15369 cmd->vdev_id = wmi_utest->vdev_id;
15370 cmd->module_id = wmi_utest->module_id;
15371 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015372 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015373 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15375 (wmi_utest->num_args * sizeof(uint32_t)));
15376 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015377 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15378 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15379 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015380 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053015381 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15382 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015383 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015384 }
15385 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15386 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015387 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015388 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015389 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015390 }
15391
Govind Singhb53420c2016-03-09 14:32:57 +053015392 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015393}
15394
15395/**
15396 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15397 * @wmi_handle: wma handle
15398 * @roaminvoke: roam invoke command
15399 *
15400 * Send roam invoke command to fw for fastreassoc.
15401 *
15402 * Return: CDF STATUS
15403 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015404static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015405 struct wmi_roam_invoke_cmd *roaminvoke,
15406 uint32_t ch_hz)
15407{
15408 wmi_roam_invoke_cmd_fixed_param *cmd;
15409 wmi_buf_t wmi_buf;
15410 u_int8_t *buf_ptr;
15411 u_int16_t len, args_tlv_len;
15412 A_UINT32 *channel_list;
15413 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015414 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015415
15416 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080015417 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
15418 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15419 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015420 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15421 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15422 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015423 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15424 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015425 }
15426
15427 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15428 buf_ptr = (u_int8_t *) cmd;
15429 WMITLV_SET_HDR(&cmd->tlv_header,
15430 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15431 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15432 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015433 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015434 if (roaminvoke->is_same_bssid)
15435 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15436 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015437
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015438 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015439 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015440 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15441 cmd->num_buf = 1;
15442 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015443 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015444 cmd->num_buf = 0;
15445 }
Naveen Rawat77797922017-01-20 17:00:07 -080015446
Govind Singha4836fd2016-03-07 16:45:38 +053015447 cmd->roam_ap_sel_mode = 0;
15448 cmd->roam_delay = 0;
15449 cmd->num_chan = 1;
15450 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015451
Govind Singha4836fd2016-03-07 16:45:38 +053015452 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15453 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15454 (sizeof(u_int32_t)));
15455 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
15456 *channel_list = ch_hz;
15457 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
15458 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15459 (sizeof(wmi_mac_addr)));
15460 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15461 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015462
15463 /* move to next tlv i.e. bcn_prb_buf_list */
15464 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15465
15466 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15467 sizeof(wmi_tlv_buf_len_param));
15468
15469 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15470 buf_len_tlv->buf_len = roaminvoke->frame_len;
15471
15472 /* move to next tlv i.e. bcn_prb_frm */
15473 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15474 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15475 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15476
15477 /* copy frame after the header */
15478 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15479 roaminvoke->frame_buf,
15480 roaminvoke->frame_len);
15481
15482 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15483 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15484 buf_ptr + WMI_TLV_HDR_SIZE,
15485 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015486 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15487 cmd->flags, cmd->roam_scan_mode,
15488 cmd->roam_ap_sel_mode, cmd->roam_delay,
15489 cmd->num_chan, cmd->num_bssid);
15490 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015491
Govind Singha4836fd2016-03-07 16:45:38 +053015492 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15493 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015494 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015495 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015496 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015497 }
15498
Govind Singhb53420c2016-03-09 14:32:57 +053015499 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015500}
15501
15502/**
15503 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15504 * @wmi_handle: wmi handle
15505 * @command: command
15506 * @vdev_id: vdev id
15507 *
15508 * This function set roam offload command to fw.
15509 *
15510 * Return: CDF status
15511 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015512static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015513 uint32_t command, uint32_t vdev_id)
15514{
Govind Singh67922e82016-04-01 16:48:57 +053015515 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015516 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15517 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015518 int len;
15519 uint8_t *buf_ptr;
15520
15521 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15522 buf = wmi_buf_alloc(wmi_handle, len);
15523 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015524 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15525 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015526 }
15527
15528 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15529
15530 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15531 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15532 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15533 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15534 cmd_fp->vdev_id = vdev_id;
15535 cmd_fp->command_arg = command;
15536
15537 status = wmi_unified_cmd_send(wmi_handle, buf,
15538 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015539 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015540 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015541 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015542 goto error;
15543 }
15544
Govind Singhb53420c2016-03-09 14:32:57 +053015545 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15546 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015547
15548error:
15549 wmi_buf_free(buf);
15550
Govind Singh67922e82016-04-01 16:48:57 +053015551 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015552}
15553
15554/**
15555 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15556 * @wmi_handle: wmi handle
15557 * @ap_profile_p: ap profile
15558 * @vdev_id: vdev id
15559 *
15560 * Send WMI_ROAM_AP_PROFILE to firmware
15561 *
15562 * Return: CDF status
15563 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015564static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015565 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015566{
Govind Singha4836fd2016-03-07 16:45:38 +053015567 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015568 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015569 int len;
15570 uint8_t *buf_ptr;
15571 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015572 wmi_roam_cnd_scoring_param *score_param;
15573 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015574
15575 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015576 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015577 buf = wmi_buf_alloc(wmi_handle, len);
15578 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015579 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15580 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015581 }
15582
15583 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15584 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15585 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15586 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15587 WMITLV_GET_STRUCT_TLVLEN
15588 (wmi_roam_ap_profile_fixed_param));
15589 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015590 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015591 roam_ap_profile_fp->id = 0;
15592 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15593
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015594 profile = (wmi_ap_profile *)buf_ptr;
15595 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015596 WMITLV_TAG_STRUC_wmi_ap_profile,
15597 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015598 profile->flags = ap_profile->profile.flags;
15599 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15600 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15601 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15602 profile->ssid.ssid_len);
15603 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15604 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15605 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15606 profile->rsn_mcastmgmtcipherset =
15607 ap_profile->profile.rsn_mcastmgmtcipherset;
15608 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15609
15610 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",
15611 profile->flags, profile->rssi_threshold,
15612 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15613 profile->rsn_authmode, profile->rsn_ucastcipherset,
15614 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15615 profile->rssi_abs_thresh);
15616
15617 buf_ptr += sizeof(wmi_ap_profile);
15618
15619 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15620 WMITLV_SET_HDR(&score_param->tlv_header,
15621 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15622 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15623 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15624 score_param->rssi_weightage_pcnt =
15625 ap_profile->param.rssi_weightage;
15626 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15627 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15628 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15629 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15630 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15631 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15632 score_param->esp_qbss_weightage_pcnt =
15633 ap_profile->param.esp_qbss_weightage;
15634 score_param->beamforming_weightage_pcnt =
15635 ap_profile->param.beamforming_weightage;
15636 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15637 score_param->oce_wan_weightage_pcnt =
15638 ap_profile->param.oce_wan_weightage;
15639
15640 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",
15641 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15642 score_param->ht_weightage_pcnt,
15643 score_param->vht_weightage_pcnt,
15644 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15645 score_param->band_weightage_pcnt,
15646 score_param->nss_weightage_pcnt,
15647 score_param->esp_qbss_weightage_pcnt,
15648 score_param->beamforming_weightage_pcnt,
15649 score_param->pcl_weightage_pcnt,
15650 score_param->oce_wan_weightage_pcnt);
15651
15652 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15653 score_param->band_scoring.score_pcnt =
15654 ap_profile->param.band_index_score;
15655 score_param->nss_scoring.score_pcnt =
15656 ap_profile->param.nss_index_score;
15657
15658 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15659 score_param->bw_scoring.score_pcnt,
15660 score_param->band_scoring.score_pcnt,
15661 score_param->nss_scoring.score_pcnt);
15662
15663 score_param->rssi_scoring.best_rssi_threshold =
15664 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15665 score_param->rssi_scoring.good_rssi_threshold =
15666 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15667 score_param->rssi_scoring.bad_rssi_threshold =
15668 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15669 score_param->rssi_scoring.good_rssi_pcnt =
15670 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15671 score_param->rssi_scoring.bad_rssi_pcnt =
15672 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15673 score_param->rssi_scoring.good_bucket_size =
15674 ap_profile->param.rssi_scoring.good_bucket_size;
15675 score_param->rssi_scoring.bad_bucket_size =
15676 ap_profile->param.rssi_scoring.bad_bucket_size;
15677 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15678 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15679
15680 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15681 score_param->rssi_scoring.best_rssi_threshold,
15682 score_param->rssi_scoring.good_rssi_threshold,
15683 score_param->rssi_scoring.bad_rssi_threshold,
15684 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15685 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15686 score_param->rssi_scoring.good_rssi_pcnt,
15687 score_param->rssi_scoring.bad_rssi_pcnt,
15688 score_param->rssi_scoring.good_bucket_size,
15689 score_param->rssi_scoring.bad_bucket_size);
15690
15691 score_param->esp_qbss_scoring.num_slot =
15692 ap_profile->param.esp_qbss_scoring.num_slot;
15693 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15694 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15695 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15696 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15697 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15698 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15699 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15700 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15701
15702 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15703 score_param->esp_qbss_scoring.num_slot,
15704 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15705 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15706 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15707 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15708
15709 score_param->oce_wan_scoring.num_slot =
15710 ap_profile->param.oce_wan_scoring.num_slot;
15711 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15712 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15713 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15714 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15715 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15716 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15717 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15718 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15719
15720 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15721 score_param->oce_wan_scoring.num_slot,
15722 score_param->oce_wan_scoring.score_pcnt3_to_0,
15723 score_param->oce_wan_scoring.score_pcnt7_to_4,
15724 score_param->oce_wan_scoring.score_pcnt11_to_8,
15725 score_param->oce_wan_scoring.score_pcnt15_to_12);
15726
Govind Singha4836fd2016-03-07 16:45:38 +053015727 status = wmi_unified_cmd_send(wmi_handle, buf,
15728 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015729 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015730 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015731 status);
Govind Singh67922e82016-04-01 16:48:57 +053015732 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015733 }
15734
Govind Singhb53420c2016-03-09 14:32:57 +053015735 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015736
Govind Singh67922e82016-04-01 16:48:57 +053015737 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015738}
15739
15740/**
15741 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15742 * @wmi_handle: wmi handle
15743 * @scan_period: scan period
15744 * @scan_age: scan age
15745 * @vdev_id: vdev id
15746 *
15747 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15748 *
15749 * Return: CDF status
15750 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015751static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015752 uint32_t scan_period,
15753 uint32_t scan_age,
15754 uint32_t vdev_id)
15755{
Govind Singh67922e82016-04-01 16:48:57 +053015756 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015757 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015758 int len;
15759 uint8_t *buf_ptr;
15760 wmi_roam_scan_period_fixed_param *scan_period_fp;
15761
15762 /* Send scan period values */
15763 len = sizeof(wmi_roam_scan_period_fixed_param);
15764 buf = wmi_buf_alloc(wmi_handle, len);
15765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015766 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15767 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015768 }
15769
15770 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15771 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15772 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15773 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15774 WMITLV_GET_STRUCT_TLVLEN
15775 (wmi_roam_scan_period_fixed_param));
15776 /* fill in scan period values */
15777 scan_period_fp->vdev_id = vdev_id;
15778 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15779 scan_period_fp->roam_scan_age = scan_age;
15780
15781 status = wmi_unified_cmd_send(wmi_handle, buf,
15782 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015783 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015784 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015785 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015786 goto error;
15787 }
15788
Govind Singhb53420c2016-03-09 14:32:57 +053015789 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015790 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015791 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015792error:
15793 wmi_buf_free(buf);
15794
Govind Singh67922e82016-04-01 16:48:57 +053015795 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015796}
15797
15798/**
15799 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15800 * @wmi_handle: wmi handle
15801 * @chan_count: channel count
15802 * @chan_list: channel list
15803 * @list_type: list type
15804 * @vdev_id: vdev id
15805 *
15806 * Set roam offload channel list.
15807 *
15808 * Return: CDF status
15809 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015810static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015811 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015812 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015813 uint8_t list_type, uint32_t vdev_id)
15814{
Govind Singha4836fd2016-03-07 16:45:38 +053015815 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015816 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015817 int len, list_tlv_len;
15818 int i;
15819 uint8_t *buf_ptr;
15820 wmi_roam_chan_list_fixed_param *chan_list_fp;
15821 A_UINT32 *roam_chan_list_array;
15822
15823 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015824 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015825 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015826 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015827 }
15828 /* Channel list is a table of 2 TLV's */
15829 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
15830 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15831 buf = wmi_buf_alloc(wmi_handle, len);
15832 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015833 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15834 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015835 }
15836
15837 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15838 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15839 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15840 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15841 WMITLV_GET_STRUCT_TLVLEN
15842 (wmi_roam_chan_list_fixed_param));
15843 chan_list_fp->vdev_id = vdev_id;
15844 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015845 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015846 /* external app is controlling channel list */
15847 chan_list_fp->chan_list_type =
15848 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15849 } else {
15850 /* umac supplied occupied channel list in LFR */
15851 chan_list_fp->chan_list_type =
15852 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15853 }
15854
15855 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15856 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15857 (chan_list_fp->num_chan * sizeof(uint32_t)));
15858 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015859 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015860 for (i = 0; ((i < chan_list_fp->num_chan) &&
15861 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15862 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015863 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015864 }
15865
15866 status = wmi_unified_cmd_send(wmi_handle, buf,
15867 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015868 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015869 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015870 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015871 goto error;
15872 }
15873
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015874 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015875 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015876error:
15877 wmi_buf_free(buf);
15878
Govind Singh67922e82016-04-01 16:48:57 +053015879 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015880}
15881
15882/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015883 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15884 * @wmi_handle: wmi handle
15885 * @req_buf: per roam config buffer
15886 *
15887 * Return: QDF status
15888 */
15889static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15890 struct wmi_per_roam_config_req *req_buf)
15891{
15892 wmi_buf_t buf = NULL;
15893 QDF_STATUS status;
15894 int len;
15895 uint8_t *buf_ptr;
15896 wmi_roam_per_config_fixed_param *wmi_per_config;
15897
15898 len = sizeof(wmi_roam_per_config_fixed_param);
15899 buf = wmi_buf_alloc(wmi_handle, len);
15900 if (!buf) {
15901 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15902 return QDF_STATUS_E_NOMEM;
15903 }
15904
15905 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15906 wmi_per_config =
15907 (wmi_roam_per_config_fixed_param *) buf_ptr;
15908 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15909 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15910 WMITLV_GET_STRUCT_TLVLEN
15911 (wmi_roam_per_config_fixed_param));
15912
15913 /* fill in per roam config values */
15914 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015915
15916 wmi_per_config->enable = req_buf->per_config.enable;
15917 wmi_per_config->high_rate_thresh =
15918 (req_buf->per_config.tx_high_rate_thresh << 16) |
15919 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15920 wmi_per_config->low_rate_thresh =
15921 (req_buf->per_config.tx_low_rate_thresh << 16) |
15922 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15923 wmi_per_config->pkt_err_rate_thresh_pct =
15924 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15925 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15926 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015927 wmi_per_config->pkt_err_rate_mon_time =
15928 (req_buf->per_config.tx_per_mon_time << 16) |
15929 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015930 wmi_per_config->min_candidate_rssi =
15931 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015932
15933 /* Send per roam config parameters */
15934 status = wmi_unified_cmd_send(wmi_handle, buf,
15935 len, WMI_ROAM_PER_CONFIG_CMDID);
15936 if (QDF_IS_STATUS_ERROR(status)) {
15937 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15938 status);
15939 wmi_buf_free(buf);
15940 return status;
15941 }
15942
15943 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15944 req_buf->per_config.enable, req_buf->vdev_id);
15945 return QDF_STATUS_SUCCESS;
15946}
15947
15948/**
Govind Singha4836fd2016-03-07 16:45:38 +053015949 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15950 * @wmi_handle: wmi handle
15951 * @rssi_change_thresh: RSSI Change threshold
15952 * @bcn_rssi_weight: beacon RSSI weight
15953 * @vdev_id: vdev id
15954 *
15955 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15956 *
15957 * Return: CDF status
15958 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015959static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015960 uint32_t vdev_id,
15961 int32_t rssi_change_thresh,
15962 uint32_t bcn_rssi_weight,
15963 uint32_t hirssi_delay_btw_scans)
15964{
Govind Singha4836fd2016-03-07 16:45:38 +053015965 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015966 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015967 int len;
15968 uint8_t *buf_ptr;
15969 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15970
15971 /* Send rssi change parameters */
15972 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15973 buf = wmi_buf_alloc(wmi_handle, len);
15974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015975 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15976 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015977 }
15978
15979 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15980 rssi_change_fp =
15981 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15982 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15983 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15984 WMITLV_GET_STRUCT_TLVLEN
15985 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15986 /* fill in rssi change threshold (hysteresis) values */
15987 rssi_change_fp->vdev_id = vdev_id;
15988 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15989 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15990 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15991
15992 status = wmi_unified_cmd_send(wmi_handle, buf,
15993 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015994 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015995 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015996 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015997 goto error;
15998 }
15999
Govind Singhb53420c2016-03-09 14:32:57 +053016000 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016001 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016002 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16003 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016004error:
16005 wmi_buf_free(buf);
16006
Govind Singh67922e82016-04-01 16:48:57 +053016007 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016008}
16009
16010/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16011 * @wmi_handle: wmi handle.
16012 * @cmd: size of command structure.
16013 * @per_entry_size: per entry size.
16014 *
16015 * This utility function calculates how many hotlist entries can
16016 * fit in one page.
16017 *
16018 * Return: number of entries
16019 */
16020static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16021 size_t cmd_size,
16022 size_t per_entry_size)
16023{
16024 uint32_t avail_space = 0;
16025 int num_entries = 0;
16026 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16027
16028 /* Calculate number of hotlist entries that can
16029 * be passed in wma message request.
16030 */
16031 avail_space = max_msg_len - cmd_size;
16032 num_entries = avail_space / per_entry_size;
16033 return num_entries;
16034}
16035
16036/**
16037 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16038 * @wmi_handle: wmi handle
16039 * @photlist: hotlist command params
16040 * @buf_len: buffer length
16041 *
16042 * This function fills individual elements for hotlist request and
16043 * TLV for bssid entries
16044 *
16045 * Return: CDF Status.
16046 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016047static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016048 struct ext_scan_setbssi_hotlist_params *
16049 photlist, int *buf_len)
16050{
16051 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16052 wmi_extscan_hotlist_entry *dest_hotlist;
16053 struct ap_threshold_params *src_ap = photlist->ap;
16054 wmi_buf_t buf;
16055 uint8_t *buf_ptr;
16056
16057 int j, index = 0;
16058 int cmd_len = 0;
16059 int num_entries;
16060 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016061 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016062 int len = sizeof(*cmd);
16063
16064 len += WMI_TLV_HDR_SIZE;
16065 cmd_len = len;
16066
16067 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16068 cmd_len,
16069 sizeof(*dest_hotlist));
16070 /* setbssid hotlist expects the bssid list
16071 * to be non zero value
16072 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016073 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016074 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016075 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016076 }
16077
16078 /* Split the hot list entry pages and send multiple command
16079 * requests if the buffer reaches the maximum request size
16080 */
16081 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016082 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016083 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16084 buf = wmi_buf_alloc(wmi_handle, len);
16085 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016086 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16087 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016088 }
16089 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16090 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16091 buf_ptr;
16092 WMITLV_SET_HDR(&cmd->tlv_header,
16093 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16094 WMITLV_GET_STRUCT_TLVLEN
16095 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16096
16097 /* Multiple requests are sent until the num_entries_in_page
16098 * matches the total_entries
16099 */
16100 cmd->request_id = photlist->requestId;
16101 cmd->vdev_id = photlist->sessionId;
16102 cmd->total_entries = numap;
16103 cmd->mode = 1;
16104 cmd->num_entries_in_page = min_entries;
16105 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16106 cmd->first_entry_index = index;
16107
Govind Singhb53420c2016-03-09 14:32:57 +053016108 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016109 __func__, cmd->vdev_id, cmd->total_entries,
16110 cmd->num_entries_in_page,
16111 cmd->lost_ap_scan_count);
16112
16113 buf_ptr += sizeof(*cmd);
16114 WMITLV_SET_HDR(buf_ptr,
16115 WMITLV_TAG_ARRAY_STRUC,
16116 min_entries * sizeof(wmi_extscan_hotlist_entry));
16117 dest_hotlist = (wmi_extscan_hotlist_entry *)
16118 (buf_ptr + WMI_TLV_HDR_SIZE);
16119
16120 /* Populate bssid, channel info and rssi
16121 * for the bssid's that are sent as hotlists.
16122 */
16123 for (j = 0; j < min_entries; j++) {
16124 WMITLV_SET_HDR(dest_hotlist,
16125 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16126 WMITLV_GET_STRUCT_TLVLEN
16127 (wmi_extscan_hotlist_entry));
16128
16129 dest_hotlist->min_rssi = src_ap->low;
16130 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16131 &dest_hotlist->bssid);
16132
Govind Singhb53420c2016-03-09 14:32:57 +053016133 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016134 __func__, dest_hotlist->channel,
16135 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016136 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016137 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16138 __func__, dest_hotlist->bssid.mac_addr31to0,
16139 dest_hotlist->bssid.mac_addr47to32);
16140 dest_hotlist++;
16141 src_ap++;
16142 }
16143 buf_ptr += WMI_TLV_HDR_SIZE +
16144 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16145
16146 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16147 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016148 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016149 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016150 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016151 }
16152 index = index + min_entries;
16153 num_entries = numap - min_entries;
16154 len = cmd_len;
16155 }
Govind Singhb53420c2016-03-09 14:32:57 +053016156 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016157}
16158
Govind Singhbca3b1b2016-05-02 17:59:24 +053016159/**
Dustin Brown4423f632017-01-13 15:24:07 -080016160 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16161 * @wmi_handle: the WMI handle
16162 * @vdev_id: the Id of the vdev to apply the configuration to
16163 * @ucast_mode: the active BPF mode to configure for unicast packets
16164 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16165 * packets
16166 *
16167 * Return: QDF status
16168 */
16169static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16170 uint8_t vdev_id,
16171 enum wmi_host_active_bpf_mode ucast_mode,
16172 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16173{
16174 const WMITLV_TAG_ID tag_id =
16175 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16176 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16177 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16178 QDF_STATUS status;
16179 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16180 wmi_buf_t buf;
16181
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016182 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016183 vdev_id, ucast_mode, mcast_bcast_mode);
16184
16185 /* allocate command buffer */
16186 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16187 if (!buf) {
16188 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16189 return QDF_STATUS_E_NOMEM;
16190 }
16191
16192 /* set TLV header */
16193 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16194 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16195
16196 /* populate data */
16197 cmd->vdev_id = vdev_id;
16198 cmd->uc_mode = ucast_mode;
16199 cmd->mcbc_mode = mcast_bcast_mode;
16200
16201 /* send to FW */
16202 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16203 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16204 if (QDF_IS_STATUS_ERROR(status)) {
16205 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16206 status);
16207 wmi_buf_free(buf);
16208 return status;
16209 }
16210
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016211 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016212
16213 return QDF_STATUS_SUCCESS;
16214}
16215
16216/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016217 * send_power_dbg_cmd_tlv() - send power debug commands
16218 * @wmi_handle: wmi handle
16219 * @param: wmi power debug parameter
16220 *
16221 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16222 *
16223 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16224 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016225static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16226 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016227{
16228 wmi_buf_t buf = NULL;
16229 QDF_STATUS status;
16230 int len, args_tlv_len;
16231 uint8_t *buf_ptr;
16232 uint8_t i;
16233 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16234 uint32_t *cmd_args;
16235
16236 /* Prepare and send power debug cmd parameters */
16237 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16238 len = sizeof(*cmd) + args_tlv_len;
16239 buf = wmi_buf_alloc(wmi_handle, len);
16240 if (!buf) {
16241 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16242 return QDF_STATUS_E_NOMEM;
16243 }
16244
16245 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16246 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16247 WMITLV_SET_HDR(&cmd->tlv_header,
16248 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16249 WMITLV_GET_STRUCT_TLVLEN
16250 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16251
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016252 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16253 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016254 cmd->module_id = param->module_id;
16255 cmd->num_args = param->num_args;
16256 buf_ptr += sizeof(*cmd);
16257 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16258 (param->num_args * sizeof(uint32_t)));
16259 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16260 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
16261 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
16262 cmd_args[i] = param->args[i];
16263 WMI_LOGI("%d,", param->args[i]);
16264 }
16265
16266 status = wmi_unified_cmd_send(wmi_handle, buf,
16267 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16268 if (QDF_IS_STATUS_ERROR(status)) {
16269 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16270 status);
16271 goto error;
16272 }
16273
16274 return QDF_STATUS_SUCCESS;
16275error:
16276 wmi_buf_free(buf);
16277
16278 return status;
16279}
16280
Govind Singhe7f2f342016-05-23 12:12:52 +053016281/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016282 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16283 * @wmi_handle: wmi handle
16284 * @param: wmi multiple vdev restart req param
16285 *
16286 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16287 *
16288 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16289 */
16290static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16291 wmi_unified_t wmi_handle,
16292 struct multiple_vdev_restart_params *param)
16293{
16294 wmi_buf_t buf;
16295 QDF_STATUS qdf_status;
16296 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16297 int i;
16298 uint8_t *buf_ptr;
16299 uint32_t *vdev_ids;
16300 wmi_channel *chan_info;
16301 struct channel_param *tchan_info;
16302 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16303
16304 len += sizeof(wmi_channel);
16305 if (param->num_vdevs)
16306 len += sizeof(uint32_t) * param->num_vdevs;
16307
16308 buf = wmi_buf_alloc(wmi_handle, len);
16309 if (!buf) {
16310 WMI_LOGE("Failed to allocate memory\n");
16311 qdf_status = QDF_STATUS_E_NOMEM;
16312 goto end;
16313 }
16314
16315 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16316 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16317 buf_ptr;
16318
16319 WMITLV_SET_HDR(&cmd->tlv_header,
16320 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16321 WMITLV_GET_STRUCT_TLVLEN
16322 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016323 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16324 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016325 cmd->requestor_id = param->requestor_id;
16326 cmd->disable_hw_ack = param->disable_hw_ack;
16327 cmd->cac_duration_ms = param->cac_duration_ms;
16328 cmd->num_vdevs = param->num_vdevs;
16329
16330 buf_ptr += sizeof(*cmd);
16331
16332 WMITLV_SET_HDR(buf_ptr,
16333 WMITLV_TAG_ARRAY_UINT32,
16334 sizeof(A_UINT32) * param->num_vdevs);
16335 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16336 for (i = 0; i < param->num_vdevs; i++) {
16337 vdev_ids[i] = param->vdev_ids[i];
16338 }
16339
16340 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
16341
16342 WMITLV_SET_HDR(buf_ptr,
16343 WMITLV_TAG_STRUC_wmi_channel,
16344 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016345 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016346 tchan_info = &(param->ch_param);
16347 chan_info->mhz = tchan_info->mhz;
16348 chan_info->band_center_freq1 = tchan_info->cfreq1;
16349 chan_info->band_center_freq2 = tchan_info->cfreq2;
16350 if (tchan_info->is_chan_passive)
16351 WMI_SET_CHANNEL_FLAG(chan_info,
16352 WMI_CHAN_FLAG_PASSIVE);
16353 if (tchan_info->allow_vht)
16354 WMI_SET_CHANNEL_FLAG(chan_info,
16355 WMI_CHAN_FLAG_ALLOW_VHT);
16356 else if (tchan_info->allow_ht)
16357 WMI_SET_CHANNEL_FLAG(chan_info,
16358 WMI_CHAN_FLAG_ALLOW_HT);
16359 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16360 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16361 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16362 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16363 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16364 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
16365
16366 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16367 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16368
16369 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16370 WMI_LOGE("%s: Failed to send\n", __func__);
16371 wmi_buf_free(buf);
16372 }
16373
16374end:
16375 return qdf_status;
16376}
16377
16378/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016379 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16380 * @wmi_handle: wmi handle
16381 * @pdev_id: pdev id
16382 *
16383 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16384 *
16385 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16386 */
16387static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16388 uint32_t pdev_id)
16389{
16390 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16391 wmi_buf_t buf;
16392 uint16_t len;
16393 QDF_STATUS ret;
16394
16395 len = sizeof(*cmd);
16396 buf = wmi_buf_alloc(wmi_handle, len);
16397
16398 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16399
16400 if (!buf) {
16401 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16402 return QDF_STATUS_E_NOMEM;
16403 }
16404
16405 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16406 wmi_buf_data(buf);
16407
16408 WMITLV_SET_HDR(&cmd->tlv_header,
16409 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16410 WMITLV_GET_STRUCT_TLVLEN(
16411 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16412
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016413 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16415 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16416 if (QDF_IS_STATUS_ERROR(ret)) {
16417 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16418 __func__, ret, pdev_id);
16419 wmi_buf_free(buf);
16420 return QDF_STATUS_E_FAILURE;
16421 }
16422
16423 return QDF_STATUS_SUCCESS;
16424}
16425
16426/**
16427 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16428 * @wmi_handle: wmi handle
16429 * @pdev_id: pdev id
16430 *
16431 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16432 *
16433 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16434 */
16435static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16436 uint32_t pdev_id)
16437{
16438 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16439 wmi_buf_t buf;
16440 uint16_t len;
16441 QDF_STATUS ret;
16442
16443 len = sizeof(*cmd);
16444 buf = wmi_buf_alloc(wmi_handle, len);
16445
16446 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16447
16448 if (!buf) {
16449 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16450 return QDF_STATUS_E_NOMEM;
16451 }
16452
16453 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16454 wmi_buf_data(buf);
16455
16456 WMITLV_SET_HDR(&cmd->tlv_header,
16457 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16458 WMITLV_GET_STRUCT_TLVLEN(
16459 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16460
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016461 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016462 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16463 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16464 if (QDF_IS_STATUS_ERROR(ret)) {
16465 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16466 __func__, ret, pdev_id);
16467 wmi_buf_free(buf);
16468 return QDF_STATUS_E_FAILURE;
16469 }
16470
16471 return QDF_STATUS_SUCCESS;
16472}
16473
16474/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016475 * init_cmd_send_tlv() - send initialization cmd to fw
16476 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016477 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016478 *
16479 * Return: QDF_STATUS_SUCCESS for success or error code
16480 */
16481static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016482 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016483{
16484 wmi_buf_t buf;
16485 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016486 uint8_t *buf_ptr;
16487 wmi_resource_config *resource_cfg;
16488 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016489 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016490 uint16_t idx;
16491 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016492 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016493
Kiran Venkatappa26117052016-12-23 19:58:54 +053016494 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16495 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016496 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016497
16498 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16499 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16500 WMI_TLV_HDR_SIZE +
16501 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16502
16503 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016504 if (!buf) {
16505 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16506 return QDF_STATUS_E_FAILURE;
16507 }
16508
16509 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16510 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16511 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16512
16513 host_mem_chunks = (wlan_host_memory_chunk *)
16514 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16515 + WMI_TLV_HDR_SIZE);
16516
16517 WMITLV_SET_HDR(&cmd->tlv_header,
16518 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16519 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16520
Kiran Venkatappa26117052016-12-23 19:58:54 +053016521 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016522 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16523 WMITLV_TAG_STRUC_wmi_resource_config,
16524 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16525
Kiran Venkatappa26117052016-12-23 19:58:54 +053016526 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016527 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16528 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16529 WMITLV_GET_STRUCT_TLVLEN
16530 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016531 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16532 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16533 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016534 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16535 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016536 idx, host_mem_chunks[idx].size,
16537 host_mem_chunks[idx].ptr);
16538 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016539 cmd->num_host_mem_chunks = param->num_mem_chunks;
16540 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16541
Govind Singhe7f2f342016-05-23 12:12:52 +053016542 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16543 WMITLV_TAG_ARRAY_STRUC,
16544 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016545 param->num_mem_chunks));
16546
16547 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016548 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016549
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016550 /* Fill fw_abi_vers */
16551 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016552
Abhishek Singh716c46c2016-05-04 16:24:07 +053016553 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16554 if (QDF_IS_STATUS_ERROR(ret)) {
16555 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16556 ret);
16557 wmi_buf_free(buf);
16558 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016559
Abhishek Singh716c46c2016-05-04 16:24:07 +053016560 return ret;
16561
Govind Singhe7f2f342016-05-23 12:12:52 +053016562}
16563
16564/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016565 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16566 * @wmi_handle: wmi handle
16567 * @bcn_ctrl_param: pointer to bcn_offload_control param
16568 *
16569 * Return: QDF_STATUS_SUCCESS for success or error code
16570 */
16571static
16572QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16573 struct bcn_offload_control *bcn_ctrl_param)
16574{
16575 wmi_buf_t buf;
16576 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16577 QDF_STATUS ret;
16578 uint32_t len;
16579
16580 len = sizeof(*cmd);
16581
16582 buf = wmi_buf_alloc(wmi_handle, len);
16583 if (!buf) {
16584 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16585 return QDF_STATUS_E_FAILURE;
16586 }
16587
16588 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16589 WMITLV_SET_HDR(&cmd->tlv_header,
16590 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16591 WMITLV_GET_STRUCT_TLVLEN
16592 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16593 cmd->vdev_id = bcn_ctrl_param->vdev_id;
16594 if (bcn_ctrl_param->bcn_tx_enable)
16595 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16596 else
16597 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
16598
16599
16600 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16601 WMI_BCN_OFFLOAD_CTRL_CMDID);
16602
16603 if (QDF_IS_STATUS_ERROR(ret)) {
16604 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16605 ret);
16606 wmi_buf_free(buf);
16607 }
16608
16609 return ret;
16610}
16611
16612/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016613 * save_service_bitmap_tlv() - save service bitmap
16614 * @wmi_handle: wmi handle
16615 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080016616 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053016617 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016618 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053016619 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016620static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016621QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080016622 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053016623{
16624 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016625 struct wmi_soc *soc = wmi_handle->soc;
16626
Govind Singhe7f2f342016-05-23 12:12:52 +053016627 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
16628
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016629 /* If it is already allocated, use that buffer. This can happen
16630 * during target stop/start scenarios where host allocation is skipped.
16631 */
16632 if (!soc->wmi_service_bitmap) {
16633 soc->wmi_service_bitmap =
16634 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
16635 if (!soc->wmi_service_bitmap) {
16636 WMI_LOGE("Failed memory allocation for service bitmap");
16637 return QDF_STATUS_E_NOMEM;
16638 }
16639 }
16640
16641 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053016642 param_buf->wmi_service_bitmap,
16643 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080016644
16645 if (bitmap_buf)
16646 qdf_mem_copy(bitmap_buf,
16647 param_buf->wmi_service_bitmap,
16648 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016649
16650 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053016651}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016652
16653/**
16654 * save_ext_service_bitmap_tlv() - save extendend service bitmap
16655 * @wmi_handle: wmi handle
16656 * @param evt_buf: pointer to event buffer
16657 * @param bitmap_buf: bitmap buffer, for converged legacy support
16658 *
16659 * Return: QDF_STATUS
16660 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016661static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016662QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080016663 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053016664{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016665 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
16666 wmi_service_available_event_fixed_param *ev;
16667 struct wmi_soc *soc = wmi_handle->soc;
16668
16669 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
16670
16671 ev = param_buf->fixed_param;
16672
16673 /* If it is already allocated, use that buffer. This can happen
16674 * during target stop/start scenarios where host allocation is skipped.
16675 */
16676 if (!soc->wmi_ext_service_bitmap) {
16677 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
16678 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
16679 if (!soc->wmi_ext_service_bitmap) {
16680 WMI_LOGE("Failed memory allocation for service bitmap");
16681 return QDF_STATUS_E_NOMEM;
16682 }
16683 }
16684
16685 qdf_mem_copy(soc->wmi_ext_service_bitmap,
16686 ev->wmi_service_segment_bitmap,
16687 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053016688
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053016689 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
16690 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
16691 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
16692
Rajeev Kumar77901472017-02-12 02:12:17 -080016693 if (bitmap_buf)
16694 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016695 soc->wmi_ext_service_bitmap,
16696 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053016697
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016698 return QDF_STATUS_SUCCESS;
16699}
Govind Singhe7f2f342016-05-23 12:12:52 +053016700/**
16701 * is_service_enabled_tlv() - Check if service enabled
16702 * @param wmi_handle: wmi handle
16703 * @param service_id: service identifier
16704 *
16705 * Return: 1 enabled, 0 disabled
16706 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053016707#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053016708static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
16709 uint32_t service_id)
16710{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053016711 struct wmi_soc *soc = wmi_handle->soc;
16712
16713 if (!soc->wmi_service_bitmap) {
16714 WMI_LOGE("WMI service bit map is not saved yet\n");
16715 return false;
16716 }
16717
16718 /* if WMI_EXTENDED_SERVICE_AVAILABLE was received with extended bitmap,
16719 * use WMI_SERVICE_EXT_ENABLE to check the services.
16720 */
16721 if (soc->wmi_ext_service_bitmap)
16722 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
16723 soc->wmi_ext_service_bitmap,
16724 service_id);
16725
16726 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
16727 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016728}
16729#else
16730static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
16731 uint32_t service_id)
16732{
16733 return false;
16734}
16735#endif
16736
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053016737static inline void copy_ht_cap_info(uint32_t ev_target_cap,
16738 struct wlan_psoc_target_capability_info *cap)
16739{
16740 /* except LDPC all flags are common betwen legacy and here
16741 * also IBFEER is not defined for TLV
16742 */
16743 cap->ht_cap_info |= ev_target_cap & (
16744 WMI_HT_CAP_ENABLED
16745 | WMI_HT_CAP_HT20_SGI
16746 | WMI_HT_CAP_DYNAMIC_SMPS
16747 | WMI_HT_CAP_TX_STBC
16748 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
16749 | WMI_HT_CAP_RX_STBC
16750 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
16751 | WMI_HT_CAP_LDPC
16752 | WMI_HT_CAP_L_SIG_TXOP_PROT
16753 | WMI_HT_CAP_MPDU_DENSITY
16754 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
16755 | WMI_HT_CAP_HT40_SGI);
16756 if (ev_target_cap & WMI_HT_CAP_LDPC)
16757 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
16758 WMI_HOST_HT_CAP_TX_LDPC;
16759}
Govind Singhe7f2f342016-05-23 12:12:52 +053016760/**
16761 * extract_service_ready_tlv() - extract service ready event
16762 * @wmi_handle: wmi handle
16763 * @param evt_buf: pointer to received event buffer
16764 * @param cap: pointer to hold target capability information extracted from even
16765 *
16766 * Return: QDF_STATUS_SUCCESS for success or error code
16767 */
16768static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016769 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053016770{
16771 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
16772 wmi_service_ready_event_fixed_param *ev;
16773
16774
16775 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
16776
16777 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
16778 if (!ev) {
16779 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16780 return QDF_STATUS_E_FAILURE;
16781 }
16782
16783 cap->phy_capability = ev->phy_capability;
16784 cap->max_frag_entry = ev->max_frag_entry;
16785 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053016786 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053016787 cap->vht_cap_info = ev->vht_cap_info;
16788 cap->vht_supp_mcs = ev->vht_supp_mcs;
16789 cap->hw_min_tx_power = ev->hw_min_tx_power;
16790 cap->hw_max_tx_power = ev->hw_max_tx_power;
16791 cap->sys_cap_info = ev->sys_cap_info;
16792 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
16793 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
16794 cap->max_num_scan_channels = ev->max_num_scan_channels;
16795 cap->max_supported_macs = ev->max_supported_macs;
16796 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
16797 cap->txrx_chainmask = ev->txrx_chainmask;
16798 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
16799 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053016800 cap->fw_version = ev->fw_build_vers;
16801 /* fw_version_1 is not available in TLV. */
16802 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016803
16804 return QDF_STATUS_SUCCESS;
16805}
16806
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053016807/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
16808 * to host internal WMI_HOST_REGDMN_MODE values.
16809 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
16810 * host currently. Add this in the future if required.
16811 * 11AX (Phase II) : 11ax related values are not currently
16812 * advertised separately by FW. As part of phase II regulatory bring-up,
16813 * finalize the advertisement mechanism.
16814 * @target_wireless_mode: target wireless mode received in message
16815 *
16816 * Return: returns the host internal wireless mode.
16817 */
16818static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
16819{
16820
16821 uint32_t wireless_modes = 0;
16822
16823 if (target_wireless_mode & REGDMN_MODE_11A)
16824 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
16825
16826 if (target_wireless_mode & REGDMN_MODE_TURBO)
16827 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
16828
16829 if (target_wireless_mode & REGDMN_MODE_11B)
16830 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
16831
16832 if (target_wireless_mode & REGDMN_MODE_PUREG)
16833 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
16834
16835 if (target_wireless_mode & REGDMN_MODE_11G)
16836 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
16837
16838 if (target_wireless_mode & REGDMN_MODE_108G)
16839 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
16840
16841 if (target_wireless_mode & REGDMN_MODE_108A)
16842 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
16843
16844 if (target_wireless_mode & REGDMN_MODE_XR)
16845 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
16846
16847 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
16848 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
16849
16850 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
16851 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
16852
16853 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
16854 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
16855
16856 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
16857 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
16858
16859 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
16860 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
16861
16862 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
16863 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
16864
16865 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
16866 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
16867
16868 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
16869 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
16870
16871 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
16872 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
16873
16874 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
16875 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
16876
16877 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
16878 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
16879
16880 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
16881 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
16882
16883 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
16884 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
16885
16886 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
16887 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
16888
16889 return wireless_modes;
16890}
16891
Govind Singhe7f2f342016-05-23 12:12:52 +053016892/**
16893 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
16894 * @wmi_handle: wmi handle
16895 * @param evt_buf: Pointer to event buffer
16896 * @param cap: pointer to hold HAL reg capabilities
16897 *
16898 * Return: QDF_STATUS_SUCCESS for success or error code
16899 */
16900static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016901 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053016902{
16903 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
16904
16905 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
16906
16907 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
16908 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080016909 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053016910
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053016911 cap->wireless_modes = convert_wireless_modes_tlv(
16912 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053016913
Govind Singhe7f2f342016-05-23 12:12:52 +053016914 return QDF_STATUS_SUCCESS;
16915}
16916
16917/**
16918 * extract_host_mem_req_tlv() - Extract host memory request event
16919 * @wmi_handle: wmi handle
16920 * @param evt_buf: pointer to event buffer
16921 * @param num_entries: pointer to hold number of entries requested
16922 *
16923 * Return: Number of entries requested
16924 */
16925static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
16926 void *evt_buf, uint8_t *num_entries)
16927{
16928 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
16929 wmi_service_ready_event_fixed_param *ev;
16930
16931 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
16932
16933 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
16934 if (!ev) {
16935 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16936 return NULL;
16937 }
16938
16939 *num_entries = ev->num_mem_reqs;
16940
16941 return (host_mem_req *)param_buf->mem_reqs;
16942}
16943
16944/**
16945 * save_fw_version_in_service_ready_tlv() - Save fw version in service
16946 * ready function
16947 * @wmi_handle: wmi handle
16948 * @param evt_buf: pointer to event buffer
16949 *
16950 * Return: QDF_STATUS_SUCCESS for success or error code
16951 */
16952static QDF_STATUS
16953save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
16954{
16955 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
16956 wmi_service_ready_event_fixed_param *ev;
16957
16958
16959 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
16960
16961 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
16962 if (!ev) {
16963 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16964 return QDF_STATUS_E_FAILURE;
16965 }
16966
16967 /*Save fw version from service ready message */
16968 /*This will be used while sending INIT message */
16969 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
16970 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016971
Govind Singhe7f2f342016-05-23 12:12:52 +053016972 return QDF_STATUS_SUCCESS;
16973}
16974
16975/**
16976 * ready_extract_init_status_tlv() - Extract init status from ready event
16977 * @wmi_handle: wmi handle
16978 * @param evt_buf: Pointer to event buffer
16979 *
16980 * Return: ready status
16981 */
16982static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
16983 void *evt_buf)
16984{
16985 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
16986 wmi_ready_event_fixed_param *ev = NULL;
16987
Govind Singhe7f2f342016-05-23 12:12:52 +053016988 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
16989 ev = param_buf->fixed_param;
16990
16991 qdf_print("%s:%d\n", __func__, ev->status);
16992
16993 return ev->status;
16994}
16995
16996/**
16997 * ready_extract_mac_addr_tlv() - extract mac address from ready event
16998 * @wmi_handle: wmi handle
16999 * @param evt_buf: pointer to event buffer
17000 * @param macaddr: Pointer to hold MAC address
17001 *
17002 * Return: QDF_STATUS_SUCCESS for success or error code
17003 */
17004static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17005 void *evt_buf, uint8_t *macaddr)
17006{
17007 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17008 wmi_ready_event_fixed_param *ev = NULL;
17009
17010
17011 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17012 ev = param_buf->fixed_param;
17013
17014 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17015
17016 return QDF_STATUS_SUCCESS;
17017}
17018
17019/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017020 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17021 * @wmi_handle: wmi handle
17022 * @param evt_buf: pointer to event buffer
17023 * @param macaddr: Pointer to hold number of MAC addresses
17024 *
17025 * Return: Pointer to addr list
17026 */
17027static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17028 void *evt_buf, uint8_t *num_mac)
17029{
17030 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17031 wmi_ready_event_fixed_param *ev = NULL;
17032
17033 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17034 ev = param_buf->fixed_param;
17035
17036 *num_mac = ev->num_extra_mac_addr;
17037
17038 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17039}
17040
17041/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017042 * extract_ready_params_tlv() - Extract data from ready event apart from
17043 * status, macaddr and version.
17044 * @wmi_handle: Pointer to WMI handle.
17045 * @evt_buf: Pointer to Ready event buffer.
17046 * @ev_param: Pointer to host defined struct to copy the data from event.
17047 *
17048 * Return: QDF_STATUS_SUCCESS on success.
17049 */
17050static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17051 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17052{
17053 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17054 wmi_ready_event_fixed_param *ev = NULL;
17055
17056 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17057 ev = param_buf->fixed_param;
17058
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017059 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017060 ev_param->num_dscp_table = ev->num_dscp_table;
17061 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17062 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017063 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017064 /* Agile_cap in ready event is not supported in TLV target */
17065 ev_param->agile_capability = false;
17066
17067 return QDF_STATUS_SUCCESS;
17068}
17069
17070/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017071 * extract_dbglog_data_len_tlv() - extract debuglog data length
17072 * @wmi_handle: wmi handle
17073 * @param evt_buf: pointer to event buffer
17074 *
17075 * Return: length
17076 */
17077static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017078 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017079{
17080 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17081
17082 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17083
17084 *len = param_buf->num_bufp;
17085
17086 return param_buf->bufp;
17087}
17088
17089/**
17090 * extract_vdev_start_resp_tlv() - extract vdev start response
17091 * @wmi_handle: wmi handle
17092 * @param evt_buf: pointer to event buffer
17093 * @param vdev_rsp: Pointer to hold vdev response
17094 *
17095 * Return: QDF_STATUS_SUCCESS for success or error code
17096 */
17097static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17098 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17099{
17100 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17101 wmi_vdev_start_response_event_fixed_param *ev;
17102
17103 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17104 if (!param_buf) {
17105 qdf_print("Invalid start response event buffer\n");
17106 return QDF_STATUS_E_INVAL;
17107 }
17108
17109 ev = param_buf->fixed_param;
17110 if (!ev) {
17111 qdf_print("Invalid start response event buffer\n");
17112 return QDF_STATUS_E_INVAL;
17113 }
17114
17115 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17116
17117 vdev_rsp->vdev_id = ev->vdev_id;
17118 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017119 switch (ev->resp_type) {
17120 case WMI_VDEV_START_RESP_EVENT:
17121 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17122 break;
17123 case WMI_VDEV_RESTART_RESP_EVENT:
17124 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17125 break;
17126 default:
17127 qdf_print("Invalid start response event buffer\n");
17128 break;
17129 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017130 vdev_rsp->status = ev->status;
17131 vdev_rsp->chain_mask = ev->chain_mask;
17132 vdev_rsp->smps_mode = ev->smps_mode;
17133 vdev_rsp->mac_id = ev->mac_id;
17134 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17135 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17136
17137 return QDF_STATUS_SUCCESS;
17138}
17139
17140/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017141 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17142 * @wmi_handle: wmi handle
17143 * @param evt_buf: pointer to event buffer
17144 * @param delete_rsp: Pointer to hold vdev delete response
17145 *
17146 * Return: QDF_STATUS_SUCCESS for success or error code
17147 */
17148static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17149 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17150{
17151 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17152 wmi_vdev_delete_resp_event_fixed_param *ev;
17153
17154 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17155 if (!param_buf) {
17156 WMI_LOGE("Invalid vdev delete response event buffer\n");
17157 return QDF_STATUS_E_INVAL;
17158 }
17159
17160 ev = param_buf->fixed_param;
17161 if (!ev) {
17162 WMI_LOGE("Invalid vdev delete response event\n");
17163 return QDF_STATUS_E_INVAL;
17164 }
17165
17166 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17167 delete_rsp->vdev_id = ev->vdev_id;
17168
17169 return QDF_STATUS_SUCCESS;
17170}
17171
17172
17173/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017174 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017175 * @wmi_handle: wmi handle
17176 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017177 * @param num_vdevs: Pointer to hold num vdev
17178 *
17179 * Return: QDF_STATUS_SUCCESS for success or error code
17180 */
17181static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17182 void *evt_buf, uint32_t *num_vdevs)
17183{
17184 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17185 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17186 uint32_t vdev_map;
17187
17188 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17189 if (!param_buf) {
17190 qdf_print("Invalid tbtt update ext event buffer\n");
17191 return QDF_STATUS_E_INVAL;
17192 }
17193 tbtt_offset_event = param_buf->fixed_param;
17194 vdev_map = tbtt_offset_event->vdev_map;
17195 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17196
17197 return QDF_STATUS_SUCCESS;
17198}
17199
17200/**
17201 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17202 * @wmi_handle: wmi handle
17203 * @param evt_buf: pointer to event buffer
17204 * @param num_vdevs: Pointer to hold num vdev
17205 *
17206 * Return: QDF_STATUS_SUCCESS for success or error code
17207 */
17208static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17209 void *evt_buf, uint32_t *num_vdevs)
17210{
17211 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17212 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17213
17214 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17215 if (!param_buf) {
17216 qdf_print("Invalid tbtt update ext event buffer\n");
17217 return QDF_STATUS_E_INVAL;
17218 }
17219 tbtt_offset_ext_event = param_buf->fixed_param;
17220
17221 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17222
17223 return QDF_STATUS_SUCCESS;
17224}
17225
17226/**
17227 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17228 * @wmi_handle: wmi handle
17229 * @param evt_buf: pointer to event buffer
17230 * @param idx: Index refering to a vdev
17231 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017232 *
17233 * Return: QDF_STATUS_SUCCESS for success or error code
17234 */
17235static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017236 void *evt_buf, uint8_t idx,
17237 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017238{
17239 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17240 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017241 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017242
17243 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17244 if (!param_buf) {
17245 qdf_print("Invalid tbtt update event buffer\n");
17246 return QDF_STATUS_E_INVAL;
17247 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017248
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017249 tbtt_offset_event = param_buf->fixed_param;
17250 vdev_map = tbtt_offset_event->vdev_map;
17251 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17252 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17253 return QDF_STATUS_E_INVAL;
17254 tbtt_param->tbttoffset =
17255 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17256
17257 return QDF_STATUS_SUCCESS;
17258}
17259
17260/**
17261 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17262 * @wmi_handle: wmi handle
17263 * @param evt_buf: pointer to event buffer
17264 * @param idx: Index refering to a vdev
17265 * @param tbtt_param: Pointer to tbttoffset event param
17266 *
17267 * Return: QDF_STATUS_SUCCESS for success or error code
17268 */
17269static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17270 void *evt_buf, uint8_t idx,
17271 struct tbttoffset_params *tbtt_param)
17272{
17273 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17274 wmi_tbtt_offset_info *tbtt_offset_info;
17275
17276 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17277 if (!param_buf) {
17278 qdf_print("Invalid tbtt update event buffer\n");
17279 return QDF_STATUS_E_INVAL;
17280 }
17281 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17282
17283 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17284 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017285
17286 return QDF_STATUS_SUCCESS;
17287}
17288
17289/**
17290 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17291 * @wmi_handle: wmi handle
17292 * @param evt_buf: pointer to event buffer
17293 * @param hdr: Pointer to hold header
17294 * @param bufp: Pointer to hold pointer to rx param buffer
17295 *
17296 * Return: QDF_STATUS_SUCCESS for success or error code
17297 */
17298static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017299 void *evt_buf, struct mgmt_rx_event_params *hdr,
17300 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017301{
17302 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17303 wmi_mgmt_rx_hdr *ev_hdr = NULL;
17304
17305 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17306 if (!param_tlvs) {
17307 WMI_LOGE("Get NULL point message from FW");
17308 return QDF_STATUS_E_INVAL;
17309 }
17310
17311 ev_hdr = param_tlvs->hdr;
17312 if (!hdr) {
17313 WMI_LOGE("Rx event is NULL");
17314 return QDF_STATUS_E_INVAL;
17315 }
17316
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017317 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17318 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017319
17320 hdr->channel = ev_hdr->channel;
17321 hdr->snr = ev_hdr->snr;
17322 hdr->rate = ev_hdr->rate;
17323 hdr->phy_mode = ev_hdr->phy_mode;
17324 hdr->buf_len = ev_hdr->buf_len;
17325 hdr->status = ev_hdr->status;
17326 hdr->flags = ev_hdr->flags;
17327 hdr->rssi = ev_hdr->rssi;
17328 hdr->tsf_delta = ev_hdr->tsf_delta;
17329 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
17330
17331 *bufp = param_tlvs->bufp;
17332
17333 return QDF_STATUS_SUCCESS;
17334}
17335
17336/**
17337 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17338 * @wmi_handle: wmi handle
17339 * @param evt_buf: pointer to event buffer
17340 * @param vdev_id: Pointer to hold vdev identifier
17341 *
17342 * Return: QDF_STATUS_SUCCESS for success or error code
17343 */
17344static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17345 void *evt_buf, uint32_t *vdev_id)
17346{
17347 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17348 wmi_vdev_stopped_event_fixed_param *resp_event;
17349
17350 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17351 if (!param_buf) {
17352 WMI_LOGE("Invalid event buffer");
17353 return QDF_STATUS_E_INVAL;
17354 }
17355 resp_event = param_buf->fixed_param;
17356 *vdev_id = resp_event->vdev_id;
17357
17358 return QDF_STATUS_SUCCESS;
17359}
17360
17361/**
17362 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17363 * @wmi_handle: wmi handle
17364 * @param evt_buf: pointer to event buffer
17365 * @param param: Pointer to hold roam param
17366 *
17367 * Return: QDF_STATUS_SUCCESS for success or error code
17368 */
17369static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17370 void *evt_buf, wmi_host_roam_event *param)
17371{
17372 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17373 wmi_roam_event_fixed_param *evt;
17374
17375 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17376 if (!param_buf) {
17377 WMI_LOGE("Invalid roam event buffer");
17378 return QDF_STATUS_E_INVAL;
17379 }
17380
17381 evt = param_buf->fixed_param;
17382 qdf_mem_zero(param, sizeof(*param));
17383
17384 param->vdev_id = evt->vdev_id;
17385 param->reason = evt->reason;
17386 param->rssi = evt->rssi;
17387
17388 return QDF_STATUS_SUCCESS;
17389}
17390
17391/**
17392 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
17393 * @wmi_handle: wmi handle
17394 * @param evt_buf: pointer to event buffer
17395 * @param param: Pointer to hold vdev scan param
17396 *
17397 * Return: QDF_STATUS_SUCCESS for success or error code
17398 */
17399static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017400 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017401{
17402 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
17403 wmi_scan_event_fixed_param *evt = NULL;
17404
17405 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
17406 evt = param_buf->fixed_param;
17407
17408 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017409
Govind Singhe7f2f342016-05-23 12:12:52 +053017410 switch (evt->event) {
17411 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017412 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017413 break;
17414 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017415 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017416 break;
17417 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017418 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017419 break;
17420 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017421 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017422 break;
17423 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017424 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017425 break;
17426 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017427 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017428 break;
17429 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017430 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017431 break;
17432 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017433 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017434 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053017435 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017436 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053017437 break;
17438 case WMI_SCAN_EVENT_MAX:
17439 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017440 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053017441 break;
17442 };
17443
17444 switch (evt->reason) {
17445 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017446 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017447 break;
17448 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017449 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017450 break;
17451 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017452 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017453 break;
17454 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017455 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017456 break;
17457 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017458 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053017459 break;
17460 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017461 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017462 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017463 case WMI_SCAN_REASON_SUSPENDED:
17464 param->reason = SCAN_REASON_SUSPENDED;
17465 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053017466 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017467 param->reason = SCAN_REASON_MAX;
17468 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053017469 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017470 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053017471 break;
17472 };
17473
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017474 param->chan_freq = evt->channel_freq;
17475 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053017476 param->scan_id = evt->scan_id;
17477 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053017478 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053017479
17480 return QDF_STATUS_SUCCESS;
17481}
17482
Frank Liu3d5e9992017-03-15 17:51:43 +080017483#ifdef CONVERGED_TDLS_ENABLE
17484/**
17485 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
17486 * @wmi_handle: wmi handle
17487 * @param evt_buf: pointer to event buffer
17488 * @param param: Pointer to hold vdev tdls param
17489 *
17490 * Return: QDF_STATUS_SUCCESS for success or error code
17491 */
17492static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
17493 void *evt_buf, struct tdls_event_info *param)
17494{
17495 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
17496 wmi_tdls_peer_event_fixed_param *evt;
17497
17498 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
17499 if (!param_buf) {
17500 WMI_LOGE("%s: NULL param_buf", __func__);
17501 return QDF_STATUS_E_NULL_VALUE;
17502 }
17503
17504 evt = param_buf->fixed_param;
17505
17506 qdf_mem_zero(param, sizeof(*param));
17507
17508 param->vdev_id = evt->vdev_id;
17509 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
17510 param->peermac.bytes);
17511 switch (evt->peer_status) {
17512 case WMI_TDLS_SHOULD_DISCOVER:
17513 param->message_type = TDLS_SHOULD_DISCOVER;
17514 break;
17515 case WMI_TDLS_SHOULD_TEARDOWN:
17516 param->message_type = TDLS_SHOULD_TEARDOWN;
17517 break;
17518 case WMI_TDLS_PEER_DISCONNECTED:
17519 param->message_type = TDLS_PEER_DISCONNECTED;
17520 break;
17521 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
17522 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
17523 break;
17524 default:
17525 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
17526 __func__, evt->peer_status);
17527 return QDF_STATUS_E_INVAL;
17528 };
17529
17530 switch (evt->peer_reason) {
17531 case WMI_TDLS_TEARDOWN_REASON_TX:
17532 param->peer_reason = TDLS_TEARDOWN_TX;
17533 break;
17534 case WMI_TDLS_TEARDOWN_REASON_RSSI:
17535 param->peer_reason = TDLS_TEARDOWN_RSSI;
17536 break;
17537 case WMI_TDLS_TEARDOWN_REASON_SCAN:
17538 param->peer_reason = TDLS_TEARDOWN_SCAN;
17539 break;
17540 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
17541 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
17542 break;
17543 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
17544 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
17545 break;
17546 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
17547 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
17548 break;
17549 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
17550 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
17551 break;
17552 case WMI_TDLS_ENTER_BUF_STA:
17553 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
17554 break;
17555 case WMI_TDLS_EXIT_BUF_STA:
17556 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
17557 break;
17558 case WMI_TDLS_ENTER_BT_BUSY_MODE:
17559 param->peer_reason = TDLS_ENTER_BT_BUSY;
17560 break;
17561 case WMI_TDLS_EXIT_BT_BUSY_MODE:
17562 param->peer_reason = TDLS_EXIT_BT_BUSY;
17563 break;
17564 case WMI_TDLS_SCAN_STARTED_EVENT:
17565 param->peer_reason = TDLS_SCAN_STARTED;
17566 break;
17567 case WMI_TDLS_SCAN_COMPLETED_EVENT:
17568 param->peer_reason = TDLS_SCAN_COMPLETED;
17569 break;
17570
17571 default:
17572 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
17573 __func__, evt->peer_reason, evt->peer_status);
17574 return QDF_STATUS_E_INVAL;
17575 };
17576
17577 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
17578 __func__, param->peermac.bytes, param->message_type,
17579 param->peer_reason, param->vdev_id);
17580
17581 return QDF_STATUS_SUCCESS;
17582}
17583#endif
17584
Govind Singhe7f2f342016-05-23 12:12:52 +053017585/**
17586 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
17587 * @wmi_handle: wmi handle
17588 * @param evt_buf: pointer to event buffer
17589 * @param param: Pointer to hold MGMT TX completion params
17590 *
17591 * Return: QDF_STATUS_SUCCESS for success or error code
17592 */
17593static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
17594 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
17595{
17596 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
17597 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
17598
17599 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
17600 evt_buf;
17601 if (!param_buf) {
17602 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
17603 return QDF_STATUS_E_INVAL;
17604 }
17605 cmpl_params = param_buf->fixed_param;
17606
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017607 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17608 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017609 param->desc_id = cmpl_params->desc_id;
17610 param->status = cmpl_params->status;
17611
17612 return QDF_STATUS_SUCCESS;
17613}
17614
17615/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017616 * extract_offchan_data_tx_compl_param_tlv() -
17617 * extract Offchan data tx completion event params
17618 * @wmi_handle: wmi handle
17619 * @param evt_buf: pointer to event buffer
17620 * @param param: Pointer to hold offchan data TX completion params
17621 *
17622 * Return: QDF_STATUS_SUCCESS for success or error code
17623 */
17624static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
17625 wmi_unified_t wmi_handle, void *evt_buf,
17626 struct wmi_host_offchan_data_tx_compl_event *param)
17627{
17628 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
17629 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
17630
17631 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
17632 evt_buf;
17633 if (!param_buf) {
17634 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
17635 return QDF_STATUS_E_INVAL;
17636 }
17637 cmpl_params = param_buf->fixed_param;
17638
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017639 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17640 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017641 param->desc_id = cmpl_params->desc_id;
17642 param->status = cmpl_params->status;
17643
17644 return QDF_STATUS_SUCCESS;
17645}
17646
17647/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053017648 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
17649 * status tlv
17650 * @wmi_handle: wmi handle
17651 * @param evt_buf: pointer to event buffer
17652 * @param param: Pointer to hold csa switch count status event param
17653 *
17654 * Return: QDF_STATUS_SUCCESS for success or error code
17655 */
17656static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
17657 wmi_unified_t wmi_handle,
17658 void *evt_buf,
17659 struct pdev_csa_switch_count_status *param)
17660{
17661 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
17662 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
17663
17664 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
17665 evt_buf;
17666 if (!param_buf) {
17667 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
17668 return QDF_STATUS_E_INVAL;
17669 }
17670
17671 csa_status = param_buf->fixed_param;
17672
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017673 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17674 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053017675 param->current_switch_count = csa_status->current_switch_count;
17676 param->num_vdevs = csa_status->num_vdevs;
17677 param->vdev_ids = param_buf->vdev_ids;
17678
17679 return QDF_STATUS_SUCCESS;
17680}
17681
17682/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017683 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053017684 * @wmi_handle: wmi handle
17685 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017686 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053017687 *
17688 * Return: QDF_STATUS_SUCCESS for success or error code
17689 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017690static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
17691 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053017692{
17693 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
17694 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017695 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017696
17697 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
17698 if (!param_buf) {
17699 WMI_LOGE("Invalid swba event buffer");
17700 return QDF_STATUS_E_INVAL;
17701 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017702
Govind Singhe7f2f342016-05-23 12:12:52 +053017703 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017704 *num_vdevs = swba_event->num_vdevs;
17705 if (!(*num_vdevs)) {
17706 vdev_map = swba_event->vdev_map;
17707 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17708 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017709
17710 return QDF_STATUS_SUCCESS;
17711}
17712
17713/**
17714 * extract_swba_tim_info_tlv() - extract swba tim info from event
17715 * @wmi_handle: wmi handle
17716 * @param evt_buf: pointer to event buffer
17717 * @param idx: Index to bcn info
17718 * @param tim_info: Pointer to hold tim info
17719 *
17720 * Return: QDF_STATUS_SUCCESS for success or error code
17721 */
17722static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
17723 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
17724{
17725 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
17726 wmi_tim_info *tim_info_ev;
17727
17728 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
17729 if (!param_buf) {
17730 WMI_LOGE("Invalid swba event buffer");
17731 return QDF_STATUS_E_INVAL;
17732 }
17733
17734 tim_info_ev = &param_buf->tim_info[idx];
17735
17736 tim_info->tim_len = tim_info_ev->tim_len;
17737 tim_info->tim_mcast = tim_info_ev->tim_mcast;
17738 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
17739 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
17740 tim_info->tim_changed = tim_info_ev->tim_changed;
17741 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017742 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053017743
17744 return QDF_STATUS_SUCCESS;
17745}
17746
17747/**
17748 * extract_swba_noa_info_tlv() - extract swba NoA information from event
17749 * @wmi_handle: wmi handle
17750 * @param evt_buf: pointer to event buffer
17751 * @param idx: Index to bcn info
17752 * @param p2p_desc: Pointer to hold p2p NoA info
17753 *
17754 * Return: QDF_STATUS_SUCCESS for success or error code
17755 */
17756static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
17757 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
17758{
17759 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
17760 wmi_p2p_noa_info *p2p_noa_info;
17761 uint8_t i = 0;
17762
17763 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
17764 if (!param_buf) {
17765 WMI_LOGE("Invalid swba event buffer");
17766 return QDF_STATUS_E_INVAL;
17767 }
17768
17769 p2p_noa_info = &param_buf->p2p_noa_info[idx];
17770
17771 p2p_desc->modified = false;
17772 p2p_desc->num_descriptors = 0;
17773 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
17774 p2p_desc->modified = true;
17775 p2p_desc->index =
17776 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
17777 p2p_desc->oppPS =
17778 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
17779 p2p_desc->ctwindow =
17780 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
17781 p2p_desc->num_descriptors =
17782 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
17783 (p2p_noa_info);
17784 for (i = 0; i < p2p_desc->num_descriptors; i++) {
17785 p2p_desc->noa_descriptors[i].type_count =
17786 (uint8_t) p2p_noa_info->noa_descriptors[i].
17787 type_count;
17788 p2p_desc->noa_descriptors[i].duration =
17789 p2p_noa_info->noa_descriptors[i].duration;
17790 p2p_desc->noa_descriptors[i].interval =
17791 p2p_noa_info->noa_descriptors[i].interval;
17792 p2p_desc->noa_descriptors[i].start_time =
17793 p2p_noa_info->noa_descriptors[i].start_time;
17794 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017795 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053017796 }
17797
17798 return QDF_STATUS_SUCCESS;
17799}
17800
Wu Gaocd3a8512017-03-13 20:17:34 +080017801#ifdef CONVERGED_P2P_ENABLE
17802/**
17803 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
17804 * @wmi_handle: wmi handle
17805 * @param evt_buf: pointer to event buffer
17806 * @param param: Pointer to hold p2p noa info
17807 *
17808 * Return: QDF_STATUS_SUCCESS for success or error code
17809 */
17810static QDF_STATUS extract_p2p_noa_ev_param_tlv(
17811 wmi_unified_t wmi_handle, void *evt_buf,
17812 struct p2p_noa_info *param)
17813{
17814 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
17815 wmi_p2p_noa_event_fixed_param *fixed_param;
17816 uint8_t i;
17817 wmi_p2p_noa_info *wmi_noa_info;
17818 uint8_t *buf_ptr;
17819 uint32_t descriptors;
17820
17821 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
17822 if (!param_tlvs) {
17823 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
17824 return QDF_STATUS_E_INVAL;
17825 }
17826
17827 if (!param) {
17828 WMI_LOGE("noa information param is null");
17829 return QDF_STATUS_E_INVAL;
17830 }
17831
17832 fixed_param = param_tlvs->fixed_param;
17833 buf_ptr = (uint8_t *) fixed_param;
17834 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
17835 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
17836
17837 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
17838 WMI_LOGE("%s: noa attr is not modified", __func__);
17839 return QDF_STATUS_E_INVAL;
17840 }
17841
17842 param->vdev_id = fixed_param->vdev_id;
17843 param->index =
17844 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
17845 param->opps_ps =
17846 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
17847 param->ct_window =
17848 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
17849 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
17850 param->num_desc = (uint8_t) descriptors;
17851
17852 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
17853 param->index, param->opps_ps, param->ct_window,
17854 param->num_desc);
17855 for (i = 0; i < param->num_desc; i++) {
17856 param->noa_desc[i].type_count =
17857 (uint8_t) wmi_noa_info->noa_descriptors[i].
17858 type_count;
17859 param->noa_desc[i].duration =
17860 wmi_noa_info->noa_descriptors[i].duration;
17861 param->noa_desc[i].interval =
17862 wmi_noa_info->noa_descriptors[i].interval;
17863 param->noa_desc[i].start_time =
17864 wmi_noa_info->noa_descriptors[i].start_time;
17865 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
17866 __func__, i, param->noa_desc[i].type_count,
17867 param->noa_desc[i].duration,
17868 param->noa_desc[i].interval,
17869 param->noa_desc[i].start_time);
17870 }
17871
17872 return QDF_STATUS_SUCCESS;
17873}
17874
17875/**
17876 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
17877 * information from event
17878 * @wmi_handle: wmi handle
17879 * @param evt_buf: pointer to event buffer
17880 * @param param: Pointer to hold p2p lo stop event information
17881 *
17882 * Return: QDF_STATUS_SUCCESS for success or error code
17883 */
17884static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
17885 wmi_unified_t wmi_handle, void *evt_buf,
17886 struct p2p_lo_event *param)
17887{
17888 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
17889 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
17890
17891 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
17892 evt_buf;
17893 if (!param_tlvs) {
17894 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
17895 return QDF_STATUS_E_INVAL;
17896 }
17897
17898 if (!param) {
17899 WMI_LOGE("lo stop event param is null");
17900 return QDF_STATUS_E_INVAL;
17901 }
17902
17903 lo_param = param_tlvs->fixed_param;
17904 param->vdev_id = lo_param->vdev_id;
17905 param->reason_code = lo_param->reason;
17906 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
17907 param->vdev_id, param->reason_code);
17908
17909 return QDF_STATUS_SUCCESS;
17910}
17911#endif /* End of CONVERGED_P2P_ENABLE */
17912
Govind Singhe7f2f342016-05-23 12:12:52 +053017913/**
17914 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
17915 * @wmi_handle: wmi handle
17916 * @param evt_buf: pointer to event buffer
17917 * @param ev: Pointer to hold peer param
17918 *
17919 * Return: QDF_STATUS_SUCCESS for success or error code
17920 */
17921static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
17922 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
17923{
17924 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
17925 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
17926
17927 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
17928 kickout_event = param_buf->fixed_param;
17929
17930 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
17931 ev->peer_macaddr);
17932
17933 ev->reason = kickout_event->reason;
17934 ev->rssi = kickout_event->rssi;
17935
17936 return QDF_STATUS_SUCCESS;
17937}
17938
17939/**
17940 * extract_all_stats_counts_tlv() - extract all stats count from event
17941 * @wmi_handle: wmi handle
17942 * @param evt_buf: pointer to event buffer
17943 * @param stats_param: Pointer to hold stats count
17944 *
17945 * Return: QDF_STATUS_SUCCESS for success or error code
17946 */
17947static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
17948 void *evt_buf, wmi_host_stats_event *stats_param)
17949{
17950 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17951 wmi_stats_event_fixed_param *ev;
17952
17953 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17954
17955 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17956 if (!ev) {
17957 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
17958 return QDF_STATUS_E_FAILURE;
17959 }
17960
17961 switch (ev->stats_id) {
17962 case WMI_REQUEST_PEER_STAT:
17963 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
17964 break;
17965
17966 case WMI_REQUEST_AP_STAT:
17967 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
17968 break;
17969
17970 case WMI_REQUEST_PDEV_STAT:
17971 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
17972 break;
17973
17974 case WMI_REQUEST_VDEV_STAT:
17975 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
17976 break;
17977
17978 case WMI_REQUEST_BCNFLT_STAT:
17979 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
17980 break;
17981
17982 case WMI_REQUEST_VDEV_RATE_STAT:
17983 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
17984 break;
17985
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053017986 case WMI_REQUEST_BCN_STAT:
17987 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
17988 break;
17989
Govind Singhe7f2f342016-05-23 12:12:52 +053017990 default:
17991 stats_param->stats_id = 0;
17992 break;
17993
17994 }
17995
17996 stats_param->num_pdev_stats = ev->num_pdev_stats;
17997 stats_param->num_pdev_ext_stats = 0;
17998 stats_param->num_vdev_stats = ev->num_vdev_stats;
17999 stats_param->num_peer_stats = ev->num_peer_stats;
18000 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18001 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018002 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018003 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18004 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018005
18006 return QDF_STATUS_SUCCESS;
18007}
18008
18009/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018010 * extract_pdev_tx_stats() - extract pdev tx stats from event
18011 */
18012static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18013{
18014 /* Tx Stats */
18015 tx->comp_queued = tx_stats->comp_queued;
18016 tx->comp_delivered = tx_stats->comp_delivered;
18017 tx->msdu_enqued = tx_stats->msdu_enqued;
18018 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18019 tx->wmm_drop = tx_stats->wmm_drop;
18020 tx->local_enqued = tx_stats->local_enqued;
18021 tx->local_freed = tx_stats->local_freed;
18022 tx->hw_queued = tx_stats->hw_queued;
18023 tx->hw_reaped = tx_stats->hw_reaped;
18024 tx->underrun = tx_stats->underrun;
18025 tx->tx_abort = tx_stats->tx_abort;
18026 tx->mpdus_requed = tx_stats->mpdus_requed;
18027 tx->data_rc = tx_stats->data_rc;
18028 tx->self_triggers = tx_stats->self_triggers;
18029 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18030 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18031 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18032 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18033 tx->pdev_resets = tx_stats->pdev_resets;
18034 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18035 tx->phy_underrun = tx_stats->phy_underrun;
18036 tx->txop_ovf = tx_stats->txop_ovf;
18037
18038 return;
18039}
18040
18041
18042/**
18043 * extract_pdev_rx_stats() - extract pdev rx stats from event
18044 */
18045static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18046{
18047 /* Rx Stats */
18048 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18049 rx->status_rcvd = rx_stats->status_rcvd;
18050 rx->r0_frags = rx_stats->r0_frags;
18051 rx->r1_frags = rx_stats->r1_frags;
18052 rx->r2_frags = rx_stats->r2_frags;
18053 /* Only TLV */
18054 rx->r3_frags = 0;
18055 rx->htt_msdus = rx_stats->htt_msdus;
18056 rx->htt_mpdus = rx_stats->htt_mpdus;
18057 rx->loc_msdus = rx_stats->loc_msdus;
18058 rx->loc_mpdus = rx_stats->loc_mpdus;
18059 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18060 rx->phy_errs = rx_stats->phy_errs;
18061 rx->phy_err_drop = rx_stats->phy_err_drop;
18062 rx->mpdu_errs = rx_stats->mpdu_errs;
18063
18064 return;
18065}
18066
18067/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018068 * extract_pdev_stats_tlv() - extract pdev stats from event
18069 * @wmi_handle: wmi handle
18070 * @param evt_buf: pointer to event buffer
18071 * @param index: Index into pdev stats
18072 * @param pdev_stats: Pointer to hold pdev stats
18073 *
18074 * Return: QDF_STATUS_SUCCESS for success or error code
18075 */
18076static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18077 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18078{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018079 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18080 wmi_stats_event_fixed_param *ev_param;
18081 uint8_t *data;
18082
18083 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18084 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18085
18086 data = param_buf->data;
18087
18088 if (index < ev_param->num_pdev_stats) {
18089 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18090 (index * sizeof(wmi_pdev_stats)));
18091
18092 pdev_stats->chan_nf = ev->chan_nf;
18093 pdev_stats->tx_frame_count = ev->tx_frame_count;
18094 pdev_stats->rx_frame_count = ev->rx_frame_count;
18095 pdev_stats->rx_clear_count = ev->rx_clear_count;
18096 pdev_stats->cycle_count = ev->cycle_count;
18097 pdev_stats->phy_err_count = ev->phy_err_count;
18098 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18099
18100 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18101 &(ev->pdev_stats.tx));
18102 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18103 &(ev->pdev_stats.rx));
18104 }
18105
Govind Singhe7f2f342016-05-23 12:12:52 +053018106 return QDF_STATUS_SUCCESS;
18107}
18108
18109/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018110 * extract_unit_test_tlv() - extract unit test data
18111 * @wmi_handle: wmi handle
18112 * @param evt_buf: pointer to event buffer
18113 * @param unit_test: pointer to hold unit test data
18114 * @param maxspace: Amount of space in evt_buf
18115 *
18116 * Return: QDF_STATUS_SUCCESS for success or error code
18117 */
18118static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18119 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18120{
18121 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18122 wmi_unit_test_event_fixed_param *ev_param;
18123 uint32_t num_bufp;
18124 uint32_t copy_size;
18125 uint8_t *bufp;
18126
18127 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18128 ev_param = param_buf->fixed_param;
18129 bufp = param_buf->bufp;
18130 num_bufp = param_buf->num_bufp;
18131 unit_test->vdev_id = ev_param->vdev_id;
18132 unit_test->module_id = ev_param->module_id;
18133 unit_test->diag_token = ev_param->diag_token;
18134 unit_test->flag = ev_param->flag;
18135 unit_test->payload_len = ev_param->payload_len;
18136 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18137 ev_param->vdev_id,
18138 ev_param->module_id,
18139 ev_param->diag_token,
18140 ev_param->flag);
18141 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18142 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18143 bufp, num_bufp);
18144 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18145 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18146 unit_test->buffer_len = copy_size;
18147
18148 return QDF_STATUS_SUCCESS;
18149}
18150
18151/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018152 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18153 * @wmi_handle: wmi handle
18154 * @param evt_buf: pointer to event buffer
18155 * @param index: Index into extended pdev stats
18156 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18157 *
18158 * Return: QDF_STATUS_SUCCESS for success or error code
18159 */
18160static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18161 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18162{
18163 return QDF_STATUS_SUCCESS;
18164}
18165
18166/**
18167 * extract_vdev_stats_tlv() - extract vdev stats from event
18168 * @wmi_handle: wmi handle
18169 * @param evt_buf: pointer to event buffer
18170 * @param index: Index into vdev stats
18171 * @param vdev_stats: Pointer to hold vdev stats
18172 *
18173 * Return: QDF_STATUS_SUCCESS for success or error code
18174 */
18175static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18176 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18177{
18178 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18179 wmi_stats_event_fixed_param *ev_param;
18180 uint8_t *data;
18181
18182 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18183 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18184 data = (uint8_t *) param_buf->data;
18185
18186 if (index < ev_param->num_vdev_stats) {
18187 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18188 ((ev_param->num_pdev_stats) *
18189 sizeof(wmi_pdev_stats)) +
18190 (index * sizeof(wmi_vdev_stats)));
18191
18192 vdev_stats->vdev_id = ev->vdev_id;
18193 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18194 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18195
18196 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18197 sizeof(ev->tx_frm_cnt));
18198 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18199 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18200 ev->multiple_retry_cnt,
18201 sizeof(ev->multiple_retry_cnt));
18202 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18203 sizeof(ev->fail_cnt));
18204 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18205 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18206 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18207 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18208 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18209 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18210 sizeof(ev->tx_rate_history));
18211 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18212 sizeof(ev->bcn_rssi_history));
18213
18214 }
18215
18216 return QDF_STATUS_SUCCESS;
18217}
18218
18219/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018220 * extract_bcn_stats_tlv() - extract bcn stats from event
18221 * @wmi_handle: wmi handle
18222 * @param evt_buf: pointer to event buffer
18223 * @param index: Index into vdev stats
18224 * @param bcn_stats: Pointer to hold bcn stats
18225 *
18226 * Return: QDF_STATUS_SUCCESS for success or error code
18227 */
18228static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18229 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18230{
18231 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18232 wmi_stats_event_fixed_param *ev_param;
18233 uint8_t *data;
18234
18235 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18236 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18237 data = (uint8_t *) param_buf->data;
18238
18239 if (index < ev_param->num_bcn_stats) {
18240 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18241 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18242 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18243 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18244 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18245 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18246 (index * sizeof(wmi_bcn_stats)));
18247
18248 bcn_stats->vdev_id = ev->vdev_id;
18249 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18250 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18251 }
18252
18253 return QDF_STATUS_SUCCESS;
18254}
18255
18256/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018257 * extract_peer_stats_tlv() - extract peer stats from event
18258 * @wmi_handle: wmi handle
18259 * @param evt_buf: pointer to event buffer
18260 * @param index: Index into peer stats
18261 * @param peer_stats: Pointer to hold peer stats
18262 *
18263 * Return: QDF_STATUS_SUCCESS for success or error code
18264 */
18265static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
18266 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
18267{
18268 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18269 wmi_stats_event_fixed_param *ev_param;
18270 uint8_t *data;
18271
18272 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18273 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18274 data = (uint8_t *) param_buf->data;
18275
18276 if (index < ev_param->num_peer_stats) {
18277 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
18278 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18279 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18280 (index * sizeof(wmi_peer_stats)));
18281
18282 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
18283
18284 OS_MEMCPY(&(peer_stats->peer_macaddr),
18285 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
18286
18287 peer_stats->peer_rssi = ev->peer_rssi;
18288 peer_stats->peer_tx_rate = ev->peer_tx_rate;
18289 peer_stats->peer_rx_rate = ev->peer_rx_rate;
18290 }
18291
18292 return QDF_STATUS_SUCCESS;
18293}
18294
18295/**
18296 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
18297 * @wmi_handle: wmi handle
18298 * @param evt_buf: pointer to event buffer
18299 * @param index: Index into bcn fault stats
18300 * @param bcnflt_stats: Pointer to hold bcn fault stats
18301 *
18302 * Return: QDF_STATUS_SUCCESS for success or error code
18303 */
18304static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
18305 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
18306{
18307 return QDF_STATUS_SUCCESS;
18308}
18309
18310/**
18311 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
18312 * @wmi_handle: wmi handle
18313 * @param evt_buf: pointer to event buffer
18314 * @param index: Index into extended peer stats
18315 * @param peer_extd_stats: Pointer to hold extended peer stats
18316 *
18317 * Return: QDF_STATUS_SUCCESS for success or error code
18318 */
18319static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
18320 void *evt_buf, uint32_t index,
18321 wmi_host_peer_extd_stats *peer_extd_stats)
18322{
18323 return QDF_STATUS_SUCCESS;
18324}
18325
18326/**
18327 * extract_chan_stats_tlv() - extract chan stats from event
18328 * @wmi_handle: wmi handle
18329 * @param evt_buf: pointer to event buffer
18330 * @param index: Index into chan stats
18331 * @param vdev_extd_stats: Pointer to hold chan stats
18332 *
18333 * Return: QDF_STATUS_SUCCESS for success or error code
18334 */
18335static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
18336 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
18337{
18338 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18339 wmi_stats_event_fixed_param *ev_param;
18340 uint8_t *data;
18341
18342 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18343 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18344 data = (uint8_t *) param_buf->data;
18345
18346 if (index < ev_param->num_chan_stats) {
18347 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
18348 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18349 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18350 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18351 (index * sizeof(wmi_chan_stats)));
18352
18353
18354 /* Non-TLV doesnt have num_chan_stats */
18355 chan_stats->chan_mhz = ev->chan_mhz;
18356 chan_stats->sampling_period_us = ev->sampling_period_us;
18357 chan_stats->rx_clear_count = ev->rx_clear_count;
18358 chan_stats->tx_duration_us = ev->tx_duration_us;
18359 chan_stats->rx_duration_us = ev->rx_duration_us;
18360 }
18361
18362 return QDF_STATUS_SUCCESS;
18363}
18364
18365/**
18366 * extract_profile_ctx_tlv() - extract profile context from event
18367 * @wmi_handle: wmi handle
18368 * @param evt_buf: pointer to event buffer
18369 * @idx: profile stats index to extract
18370 * @param profile_ctx: Pointer to hold profile context
18371 *
18372 * Return: QDF_STATUS_SUCCESS for success or error code
18373 */
18374static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
18375 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
18376{
18377 return QDF_STATUS_SUCCESS;
18378}
18379
18380/**
18381 * extract_profile_data_tlv() - extract profile data from event
18382 * @wmi_handle: wmi handle
18383 * @param evt_buf: pointer to event buffer
18384 * @param profile_data: Pointer to hold profile data
18385 *
18386 * Return: QDF_STATUS_SUCCESS for success or error code
18387 */
18388static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
18389 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
18390{
18391
18392 return QDF_STATUS_SUCCESS;
18393}
18394
18395/**
18396 * extract_chan_info_event_tlv() - extract chan information from event
18397 * @wmi_handle: wmi handle
18398 * @param evt_buf: pointer to event buffer
18399 * @param chan_info: Pointer to hold chan information
18400 *
18401 * Return: QDF_STATUS_SUCCESS for success or error code
18402 */
18403static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
18404 void *evt_buf, wmi_host_chan_info_event *chan_info)
18405{
18406 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
18407 wmi_chan_info_event_fixed_param *ev;
18408
18409 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
18410
18411 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
18412 if (!ev) {
18413 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
18414 return QDF_STATUS_E_FAILURE;
18415 }
18416
18417 chan_info->err_code = ev->err_code;
18418 chan_info->freq = ev->freq;
18419 chan_info->cmd_flags = ev->cmd_flags;
18420 chan_info->noise_floor = ev->noise_floor;
18421 chan_info->rx_clear_count = ev->rx_clear_count;
18422 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053018423 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
18424 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053018425 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
18426 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
18427 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053018428 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
18429 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
18430 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
18431 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
18432 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
18433 chan_info->rx_frame_count = ev->rx_frame_count;
18434 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
18435 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018436
18437 return QDF_STATUS_SUCCESS;
18438}
18439
18440/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018441 * extract_pdev_utf_event_tlv() - extract UTF data info from event
18442 * @wmi_handle: WMI handle
18443 * @param evt_buf: Pointer to event buffer
18444 * @param param: Pointer to hold data
18445 *
18446 * Return : QDF_STATUS_SUCCESS for success or error code
18447 */
18448static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
18449 uint8_t *evt_buf,
18450 struct wmi_host_pdev_utf_event *event)
18451{
18452 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053018453 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018454
18455 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
18456 event->data = param_buf->data;
18457 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053018458 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053018459 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018460 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053018461 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018462
18463 return QDF_STATUS_SUCCESS;
18464}
Govind Singhe7f2f342016-05-23 12:12:52 +053018465
Kiran Venkatappa06520822016-08-10 23:55:40 +053018466/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018467 * extract_chainmask_tables_tlv() - extract chain mask tables from event
18468 * @wmi_handle: wmi handle
18469 * @param evt_buf: pointer to event buffer
18470 * @param param: Pointer to hold evt buf
18471 *
18472 * Return: QDF_STATUS_SUCCESS for success or error code
18473 */
18474static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
18475 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
18476{
18477 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
18478 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
18479 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
18480 uint8_t i = 0, j = 0;
18481
18482 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
18483 if (!param_buf)
18484 return QDF_STATUS_E_INVAL;
18485
18486 hw_caps = param_buf->soc_hw_mode_caps;
18487 if (!hw_caps)
18488 return QDF_STATUS_E_INVAL;
18489
18490 if (!hw_caps->num_chainmask_tables)
18491 return QDF_STATUS_E_INVAL;
18492
18493 chainmask_caps = param_buf->mac_phy_chainmask_caps;
18494
18495 if (chainmask_caps == NULL)
18496 return QDF_STATUS_E_INVAL;
18497
18498 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
18499
18500 qdf_print("Dumping chain mask combo data for table : %d\n", i);
18501 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
18502
18503 chainmask_table[i].cap_list[j].chainmask =
18504 chainmask_caps->chainmask;
18505
18506 chainmask_table[i].cap_list[j].supports_chan_width_20 =
18507 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
18508
18509 chainmask_table[i].cap_list[j].supports_chan_width_40 =
18510 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
18511
18512 chainmask_table[i].cap_list[j].supports_chan_width_80 =
18513 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
18514
18515 chainmask_table[i].cap_list[j].supports_chan_width_160 =
18516 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
18517
18518 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
18519 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
18520
18521 chainmask_table[i].cap_list[j].chain_mask_2G =
18522 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
18523
18524 chainmask_table[i].cap_list[j].chain_mask_5G =
18525 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
18526
18527 chainmask_table[i].cap_list[j].chain_mask_tx =
18528 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
18529
18530 chainmask_table[i].cap_list[j].chain_mask_rx =
18531 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
18532
18533 chainmask_table[i].cap_list[j].supports_aDFS =
18534 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
18535
18536 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
18537 chainmask_caps->supported_flags,
18538 chainmask_caps->chainmask
18539 );
18540 chainmask_caps++;
18541 }
18542 }
18543
18544 return QDF_STATUS_SUCCESS;
18545}
18546
18547/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053018548 * extract_service_ready_ext_tlv() - extract basic extended service ready params
18549 * from event
18550 * @wmi_handle: wmi handle
18551 * @param evt_buf: pointer to event buffer
18552 * @param param: Pointer to hold evt buf
18553 *
18554 * Return: QDF_STATUS_SUCCESS for success or error code
18555 */
18556static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018557 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053018558{
18559 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
18560 wmi_service_ready_ext_event_fixed_param *ev;
18561 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
18562 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018563 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
18564 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018565
18566 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
18567 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018568 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018569
18570 ev = param_buf->fixed_param;
18571 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018572 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018573
18574 /* Move this to host based bitmap */
18575 param->default_conc_scan_config_bits =
18576 ev->default_conc_scan_config_bits;
18577 param->default_fw_config_bits = ev->default_fw_config_bits;
18578 param->he_cap_info = ev->he_cap_info;
18579 param->mpdu_density = ev->mpdu_density;
18580 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053018581 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053018582 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018583 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
18584
18585 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018586 if (hw_caps)
18587 param->num_hw_modes = hw_caps->num_hw_modes;
18588 else
18589 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018590
18591 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018592 if (reg_caps)
18593 param->num_phy = reg_caps->num_phy;
18594 else
18595 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018596
Kapil Gupta0692a1a2017-05-15 15:57:36 +053018597 if (hw_caps) {
18598 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
18599 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
18600 } else
18601 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018602
18603 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
18604
18605 if (chain_mask_combo == NULL)
18606 return QDF_STATUS_SUCCESS;
18607
18608 qdf_print("Dumping chain mask combo data\n");
18609
Kapil Gupta0692a1a2017-05-15 15:57:36 +053018610 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018611
18612 qdf_print("table_id : %d Num valid chainmasks: %d\n",
18613 chain_mask_combo->chainmask_table_id,
18614 chain_mask_combo->num_valid_chainmask
18615 );
18616
18617 param->chainmask_table[i].table_id =
18618 chain_mask_combo->chainmask_table_id;
18619 param->chainmask_table[i].num_valid_chainmasks =
18620 chain_mask_combo->num_valid_chainmask;
18621 chain_mask_combo++;
18622 }
18623 qdf_print("chain mask combo end\n");
18624
Kiran Venkatappa06520822016-08-10 23:55:40 +053018625 return QDF_STATUS_SUCCESS;
18626}
18627
18628/**
18629 * extract_hw_mode_cap_service_ready_ext_tlv() -
18630 * extract HW mode cap from service ready event
18631 * @wmi_handle: wmi handle
18632 * @param evt_buf: pointer to event buffer
18633 * @param param: Pointer to hold evt buf
18634 * @param hw_mode_idx: hw mode idx should be less than num_mode
18635 *
18636 * Return: QDF_STATUS_SUCCESS for success or error code
18637 */
18638static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
18639 wmi_unified_t wmi_handle,
18640 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018641 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053018642{
18643 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
18644 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
18645
18646 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
18647 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018648 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018649
18650 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018651 if (!hw_caps)
18652 return QDF_STATUS_E_INVAL;
18653
Kiran Venkatappa06520822016-08-10 23:55:40 +053018654 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018655 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018656
18657 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
18658 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
18659
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018660 param->hw_mode_config_type =
18661 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
18662
Kiran Venkatappa06520822016-08-10 23:55:40 +053018663 return QDF_STATUS_SUCCESS;
18664}
18665
18666/**
18667 * extract_mac_phy_cap_service_ready_ext_tlv() -
18668 * extract MAC phy cap from service ready event
18669 * @wmi_handle: wmi handle
18670 * @param evt_buf: pointer to event buffer
18671 * @param param: Pointer to hold evt buf
18672 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018673 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053018674 *
18675 * Return: QDF_STATUS_SUCCESS for success or error code
18676 */
18677static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
18678 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018679 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018680 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053018681{
18682 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018683 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018684 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
18685 uint32_t phy_map;
18686 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018687
18688 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
18689 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018690 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018691
18692 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018693 if (!hw_caps)
18694 return QDF_STATUS_E_INVAL;
18695
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018696 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
18697 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
18698 break;
18699
18700 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
18701 while (phy_map) {
18702 phy_map >>= 1;
18703 phy_idx++;
18704 }
18705 }
18706
18707 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018708 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018709
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018710 phy_idx += phy_id;
18711 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018712 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018713
18714 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053018715
18716 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018717 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18718 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053018719 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053018720 param->supports_11b =
18721 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
18722 param->supports_11g =
18723 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
18724 param->supports_11a =
18725 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
18726 param->supports_11n =
18727 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
18728 param->supports_11ac =
18729 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
18730 param->supports_11ax =
18731 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053018732
18733 param->supported_bands = mac_phy_caps->supported_bands;
18734 param->ampdu_density = mac_phy_caps->ampdu_density;
18735 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
18736 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
18737 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
18738 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
18739 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
18740 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
18741 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
18742 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
18743 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
18744 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
18745 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
18746 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
18747 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
18748 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
18749 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
18750 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080018751 qdf_mem_copy(&param->he_cap_phy_info_2G,
18752 &mac_phy_caps->he_cap_phy_info_2G,
18753 sizeof(param->he_cap_phy_info_2G));
18754 qdf_mem_copy(&param->he_cap_phy_info_5G,
18755 &mac_phy_caps->he_cap_phy_info_5G,
18756 sizeof(param->he_cap_phy_info_5G));
18757 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
18758 sizeof(param->he_ppet2G));
18759 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
18760 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018761 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018762
18763 return QDF_STATUS_SUCCESS;
18764}
18765
18766/**
18767 * extract_reg_cap_service_ready_ext_tlv() -
18768 * extract REG cap from service ready event
18769 * @wmi_handle: wmi handle
18770 * @param evt_buf: pointer to event buffer
18771 * @param param: Pointer to hold evt buf
18772 * @param phy_idx: phy idx should be less than num_mode
18773 *
18774 * Return: QDF_STATUS_SUCCESS for success or error code
18775 */
18776static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
18777 wmi_unified_t wmi_handle,
18778 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018779 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053018780{
18781 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
18782 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
18783 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
18784
18785 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
18786 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018787 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018788
18789 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018790 if (!reg_caps)
18791 return QDF_STATUS_E_INVAL;
18792
Kiran Venkatappa06520822016-08-10 23:55:40 +053018793 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018794 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053018795
18796 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
18797
18798 param->phy_id = ext_reg_cap->phy_id;
18799 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
18800 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
18801 param->regcap1 = ext_reg_cap->regcap1;
18802 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018803 param->wireless_modes = convert_wireless_modes_tlv(
18804 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053018805 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
18806 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
18807 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
18808 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
18809
18810 return QDF_STATUS_SUCCESS;
18811}
18812
Sathish Kumarf396c722017-11-17 17:30:41 +053018813static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
18814 wmi_unified_t wmi_handle,
18815 uint8_t *event, uint8_t idx,
18816 struct wlan_psoc_host_dbr_ring_caps *param)
18817{
18818 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
18819 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
18820
18821 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
18822 if (!param_buf)
18823 return QDF_STATUS_E_INVAL;
18824
18825 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
18826
18827 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18828 dbr_ring_caps->pdev_id);
18829 param->mod_id = dbr_ring_caps->mod_id;
18830 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
18831 param->min_buf_size = dbr_ring_caps->min_buf_size;
18832 param->min_buf_align = dbr_ring_caps->min_buf_align;
18833
18834 return QDF_STATUS_SUCCESS;
18835}
18836
18837static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
18838 uint8_t *event, struct direct_buf_rx_rsp *param)
18839{
18840 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
18841 wmi_dma_buf_release_fixed_param *ev;
18842
18843 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
18844 if (!param_buf)
18845 return QDF_STATUS_E_INVAL;
18846
18847 ev = param_buf->fixed_param;
18848 if (!ev)
18849 return QDF_STATUS_E_INVAL;
18850
18851 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18852 ev->pdev_id);
18853 param->mod_id = ev->mod_id;
18854 param->num_buf_release_entry = ev->num_buf_release_entry;
18855 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
18856 param->pdev_id, param->mod_id, param->num_buf_release_entry);
18857
18858 return QDF_STATUS_SUCCESS;
18859}
18860
18861static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
18862 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
18863{
18864 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
18865 wmi_dma_buf_release_entry *entry;
18866
18867 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
18868 if (!param_buf)
18869 return QDF_STATUS_E_INVAL;
18870
18871 entry = &param_buf->entries[idx];
18872
18873 if (!entry) {
18874 WMI_LOGE("%s: Entry is NULL\n", __func__);
18875 return QDF_STATUS_E_FAILURE;
18876 }
18877
18878 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
18879
18880 param->paddr_lo = entry->paddr_lo;
18881 param->paddr_hi = entry->paddr_hi;
18882
18883 return QDF_STATUS_SUCCESS;
18884}
18885
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018886/**
18887 * extract_dcs_interference_type_tlv() - extract dcs interference type
18888 * from event
18889 * @wmi_handle: wmi handle
18890 * @param evt_buf: pointer to event buffer
18891 * @param param: Pointer to hold dcs interference param
18892 *
18893 * Return: 0 for success or error code
18894 */
18895static QDF_STATUS extract_dcs_interference_type_tlv(
18896 wmi_unified_t wmi_handle,
18897 void *evt_buf, struct wmi_host_dcs_interference_param *param)
18898{
18899 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
18900
18901 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
18902 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018903 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018904
18905 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018906 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18907 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018908
18909 return QDF_STATUS_SUCCESS;
18910}
18911
18912/*
18913 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
18914 * @wmi_handle: wmi handle
18915 * @param evt_buf: pointer to event buffer
18916 * @param cw_int: Pointer to hold cw interference
18917 *
18918 * Return: 0 for success or error code
18919 */
18920static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
18921 void *evt_buf,
18922 wmi_host_ath_dcs_cw_int *cw_int)
18923{
18924 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
18925 wlan_dcs_cw_int *ev;
18926
18927 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
18928 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018929 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018930
18931 ev = param_buf->cw_int;
18932
18933 cw_int->channel = ev->channel;
18934
18935 return QDF_STATUS_SUCCESS;
18936}
18937
18938/**
18939 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
18940 * @wmi_handle: wmi handle
18941 * @param evt_buf: pointer to event buffer
18942 * @param wlan_stat: Pointer to hold wlan stats
18943 *
18944 * Return: 0 for success or error code
18945 */
18946static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
18947 void *evt_buf,
18948 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
18949{
18950 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
18951 wlan_dcs_im_tgt_stats_t *ev;
18952
18953 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
18954 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053018955 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018956
18957 ev = param_buf->wlan_stat;
18958 wlan_stat->reg_tsf32 = ev->reg_tsf32;
18959 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
18960 wlan_stat->tx_waste_time = ev->tx_waste_time;
18961 wlan_stat->rx_time = ev->rx_time;
18962 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
18963 wlan_stat->mib_stats.listen_time = ev->listen_time;
18964 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
18965 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
18966 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
18967 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
18968 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
18969 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
18970 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
18971 wlan_stat->chan_nf = ev->chan_nf;
18972 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
18973
18974 return QDF_STATUS_SUCCESS;
18975}
18976
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018977/**
18978 * extract_thermal_stats_tlv() - extract thermal stats from event
18979 * @wmi_handle: wmi handle
18980 * @param evt_buf: Pointer to event buffer
18981 * @param temp: Pointer to hold extracted temperature
18982 * @param level: Pointer to hold extracted level
18983 *
18984 * Return: 0 for success or error code
18985 */
18986static QDF_STATUS
18987extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
18988 void *evt_buf, uint32_t *temp,
18989 uint32_t *level, uint32_t *pdev_id)
18990{
18991 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
18992 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
18993
18994 param_buf =
18995 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
18996 if (!param_buf)
18997 return QDF_STATUS_E_INVAL;
18998
18999 tt_stats_event = param_buf->fixed_param;
19000
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019001 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19002 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019003 *temp = tt_stats_event->temp;
19004 *level = tt_stats_event->level;
19005
19006 return QDF_STATUS_SUCCESS;
19007}
19008
19009/**
19010 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19011 * @wmi_handle: wmi handle
19012 * @param evt_buf: pointer to event buffer
19013 * @param idx: Index to level stats
19014 * @param levelcount: Pointer to hold levelcount
19015 * @param dccount: Pointer to hold dccount
19016 *
19017 * Return: 0 for success or error code
19018 */
19019static QDF_STATUS
19020extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19021 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19022 uint32_t *dccount)
19023{
19024 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19025 wmi_therm_throt_level_stats_info *tt_level_info;
19026
19027 param_buf =
19028 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19029 if (!param_buf)
19030 return QDF_STATUS_E_INVAL;
19031
19032 tt_level_info = param_buf->therm_throt_level_stats_info;
19033
19034 if (idx < THERMAL_LEVELS) {
19035 *levelcount = tt_level_info[idx].level_count;
19036 *dccount = tt_level_info[idx].dc_count;
19037 return QDF_STATUS_SUCCESS;
19038 }
19039
19040 return QDF_STATUS_E_FAILURE;
19041}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019042#ifdef BIG_ENDIAN_HOST
19043/**
19044 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19045 * @param data_len - data length
19046 * @param data - pointer to data
19047 *
19048 * Return: QDF_STATUS - success or error status
19049 */
19050static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19051{
19052 uint8_t *data_aligned = NULL;
19053 int c;
19054 unsigned char *data_unaligned;
19055
19056 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19057 FIPS_ALIGN));
19058 /* Assigning unaligned space to copy the data */
19059 /* Checking if kmalloc does succesful allocation */
19060 if (data_unaligned == NULL)
19061 return QDF_STATUS_E_FAILURE;
19062
19063 /* Checking if space is alligned */
19064 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19065 /* align the data space */
19066 data_aligned =
19067 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19068 } else {
19069 data_aligned = (u_int8_t *)data_unaligned;
19070 }
19071
19072 /* memset and copy content from data to data aligned */
19073 OS_MEMSET(data_aligned, 0, data_len);
19074 OS_MEMCPY(data_aligned, data, data_len);
19075 /* Endianness to LE */
19076 for (c = 0; c < data_len/4; c++) {
19077 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019078 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019079 }
19080
19081 /* Copy content to event->data */
19082 OS_MEMCPY(data, data_aligned, data_len);
19083
19084 /* clean up allocated space */
19085 qdf_mem_free(data_unaligned);
19086 data_aligned = NULL;
19087 data_unaligned = NULL;
19088
19089 /*************************************************************/
19090
19091 return QDF_STATUS_SUCCESS;
19092}
19093#else
19094/**
19095 * fips_conv_data_be() - DUMMY for LE platform
19096 *
19097 * Return: QDF_STATUS - success
19098 */
19099static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19100{
19101 return QDF_STATUS_SUCCESS;
19102}
19103#endif
19104
19105/**
19106 * extract_fips_event_data_tlv() - extract fips event data
19107 * @wmi_handle: wmi handle
19108 * @param evt_buf: pointer to event buffer
19109 * @param param: pointer FIPS event params
19110 *
19111 * Return: 0 for success or error code
19112 */
19113static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19114 void *evt_buf, struct wmi_host_fips_event_param *param)
19115{
19116 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19117 wmi_pdev_fips_event_fixed_param *event;
19118
19119 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19120 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19121
19122 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19123 QDF_STATUS_SUCCESS)
19124 return QDF_STATUS_E_FAILURE;
19125
19126 param->data = (uint32_t *)param_buf->data;
19127 param->data_len = event->data_len;
19128 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019129 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19130 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019131
19132 return QDF_STATUS_SUCCESS;
19133}
19134
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019135/*
19136 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19137 * @wmi_handle: wmi handle
19138 * @param evt_buf: pointer to event buffer
19139 * @param vdev_id: Pointer to hold vdev_id
19140 * @param mac_addr: Pointer to hold peer mac address
19141 *
19142 * Return: QDF_STATUS_SUCCESS for success or error code
19143 */
19144static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19145 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19146{
19147 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19148 wmi_peer_delete_resp_event_fixed_param *ev;
19149
19150 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19151
19152 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19153 if (!ev) {
19154 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19155 return QDF_STATUS_E_FAILURE;
19156 }
19157
19158 param->vdev_id = ev->vdev_id;
19159 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19160 &param->mac_address.bytes[0]);
19161
19162 return QDF_STATUS_SUCCESS;
19163}
19164
Govind Singhecf03cd2016-05-12 12:45:51 +053019165static bool is_management_record_tlv(uint32_t cmd_id)
19166{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053019167 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053019168 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053019169
Govind Singhecf03cd2016-05-12 12:45:51 +053019170 return false;
19171}
19172
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019173static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19174{
19175 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19176
19177 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19178
19179 switch (set_cmd->param_id) {
19180 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19181 case WMI_VDEV_PARAM_DTIM_POLICY:
19182 return HTC_TX_PACKET_TAG_AUTO_PM;
19183 default:
19184 break;
19185 }
19186
19187 return 0;
19188}
19189
19190static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19191{
19192 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19193
19194 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19195
19196 switch (ps_cmd->param) {
19197 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19198 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19199 case WMI_STA_PS_ENABLE_QPOWER:
19200 return HTC_TX_PACKET_TAG_AUTO_PM;
19201 default:
19202 break;
19203 }
19204
19205 return 0;
19206}
19207
19208static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
19209 uint32_t cmd_id)
19210{
19211 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
19212 return 0;
19213
19214 switch (cmd_id) {
19215 case WMI_VDEV_SET_PARAM_CMDID:
19216 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
19217 case WMI_STA_POWERSAVE_PARAM_CMDID:
19218 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
19219 default:
19220 break;
19221 }
19222
19223 return 0;
19224}
19225
19226static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
19227{
19228 uint16_t tag = 0;
19229
19230 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
19231 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
19232 __func__);
19233 return tag;
19234 }
19235
19236 if (wmi_handle->tag_crash_inject)
19237 tag = HTC_TX_PACKET_TAG_AUTO_PM;
19238
19239 wmi_handle->tag_crash_inject = false;
19240 return tag;
19241}
19242
19243/**
19244 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
19245 * @wmi_handle: WMI handle
19246 * @buf: WMI buffer
19247 * @cmd_id: WMI command Id
19248 *
19249 * Return htc_tx_tag
19250 */
19251static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
19252 wmi_buf_t buf,
19253 uint32_t cmd_id)
19254{
19255 uint16_t htc_tx_tag = 0;
19256
19257 switch (cmd_id) {
19258 case WMI_WOW_ENABLE_CMDID:
19259 case WMI_PDEV_SUSPEND_CMDID:
19260 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
19261 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
19262 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
19263 case WMI_PDEV_RESUME_CMDID:
19264 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
19265 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
19266#ifdef FEATURE_WLAN_D0WOW
19267 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
19268#endif
19269 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
19270 break;
19271 case WMI_FORCE_FW_HANG_CMDID:
19272 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
19273 break;
19274 case WMI_VDEV_SET_PARAM_CMDID:
19275 case WMI_STA_POWERSAVE_PARAM_CMDID:
19276 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
19277 default:
19278 break;
19279 }
19280
19281 return htc_tx_tag;
19282}
19283
Sathish Kumard3ab1002017-02-07 17:10:59 +053019284/**
19285 * extract_channel_hopping_event_tlv() - extract channel hopping param
19286 * from event
19287 * @wmi_handle: wmi handle
19288 * @param evt_buf: pointer to event buffer
19289 * @param ch_hopping: Pointer to hold channel hopping param
19290 *
19291 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19292 */
19293static QDF_STATUS extract_channel_hopping_event_tlv(
19294 wmi_unified_t wmi_handle, void *evt_buf,
19295 wmi_host_pdev_channel_hopping_event *ch_hopping)
19296{
19297 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
19298 wmi_pdev_channel_hopping_event_fixed_param *event;
19299
19300 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
19301 event = (wmi_pdev_channel_hopping_event_fixed_param *)
19302 param_buf->fixed_param;
19303
19304 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
19305 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019306 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19307 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053019308
19309 return QDF_STATUS_SUCCESS;
19310}
19311
19312/**
19313 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
19314 * @wmi_handle: wmi handle
19315 * @param evt_buf: pointer to event buffer
19316 * @param param: Pointer to hold tpc param
19317 *
19318 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19319 */
19320static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
19321 void *evt_buf,
19322 wmi_host_pdev_tpc_event *param)
19323{
19324 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
19325 wmi_pdev_tpc_event_fixed_param *event;
19326
19327 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
19328 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
19329
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019330 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19331 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053019332 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
19333
19334 return QDF_STATUS_SUCCESS;
19335}
19336
19337
19338#ifdef BIG_ENDIAN_HOST
19339/**
19340 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
19341 * @param data_len - data length
19342 * @param data - pointer to data
19343 *
19344 * Return: QDF_STATUS - success or error status
19345 */
19346static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
19347{
19348 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019349 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053019350 /* Skip swapping the first word */
19351 datap += sizeof(uint32_t);
19352 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
19353 i++, datap += sizeof(uint32_t)) {
19354 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
19355 }
19356
19357 return QDF_STATUS_SUCCESS;
19358}
19359#else
19360/**
19361 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
19362 * @param data_len - data length
19363 * @param data - pointer to data
19364 *
19365 * Return: QDF_STATUS - success or error status
19366 */
19367static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
19368{
19369 return QDF_STATUS_SUCCESS;
19370}
19371#endif
19372
19373/**
19374 * extract_wds_addr_event_tlv() - extract wds address from event
19375 * @wmi_handle: wmi handle
19376 * @param evt_buf: pointer to event buffer
19377 * @param wds_ev: Pointer to hold wds address
19378 *
19379 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19380 */
19381static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
19382 void *evt_buf,
19383 uint16_t len, wds_addr_event_t *wds_ev)
19384{
19385 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
19386 wmi_wds_addr_event_fixed_param *ev;
19387 int i;
19388
19389 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
19390 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
19391
19392 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
19393 return QDF_STATUS_E_FAILURE;
19394
19395 qdf_mem_copy(wds_ev->event_type, ev->event_type,
19396 sizeof(wds_ev->event_type));
19397 for (i = 0; i < 4; i++) {
19398 wds_ev->peer_mac[i] =
19399 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
19400 wds_ev->dest_mac[i] =
19401 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
19402 }
19403 for (i = 0; i < 2; i++) {
19404 wds_ev->peer_mac[4+i] =
19405 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
19406 wds_ev->dest_mac[4+i] =
19407 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
19408 }
19409 return QDF_STATUS_SUCCESS;
19410}
19411
19412/**
19413 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
19414 * from event
19415 * @wmi_handle: wmi handle
19416 * @param evt_buf: pointer to event buffer
19417 * @param ev: Pointer to hold peer param and ps state
19418 *
19419 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19420 */
19421static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
19422 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
19423{
19424 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
19425 wmi_peer_sta_ps_statechange_event_fixed_param *event;
19426
19427 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
19428 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
19429 param_buf->fixed_param;
19430
19431 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
19432 ev->peer_ps_state = event->peer_ps_state;
19433
19434 return QDF_STATUS_SUCCESS;
19435}
19436
19437/**
19438 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
19439 * @wmi_handle: wmi handle
19440 * @param evt_buf: pointer to event buffer
19441 * @param inst_rssi_resp: Pointer to hold inst rssi response
19442 *
19443 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19444 */
19445static QDF_STATUS extract_inst_rssi_stats_event_tlv(
19446 wmi_unified_t wmi_handle, void *evt_buf,
19447 wmi_host_inst_stats_resp *inst_rssi_resp)
19448{
19449 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
19450 wmi_inst_rssi_stats_resp_fixed_param *event;
19451
19452 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
19453 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
19454
19455 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
19456 &(event->peer_macaddr), sizeof(wmi_mac_addr));
19457 inst_rssi_resp->iRSSI = event->iRSSI;
19458
19459 return QDF_STATUS_SUCCESS;
19460}
19461
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019462static struct cur_reg_rule
19463*create_reg_rules_from_wmi(uint32_t num_reg_rules,
19464 wmi_regulatory_rule_struct *wmi_reg_rule)
19465{
19466 struct cur_reg_rule *reg_rule_ptr;
19467 uint32_t count;
19468
19469 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
19470
19471 if (NULL == reg_rule_ptr) {
19472 WMI_LOGE("memory allocation failure");
19473 return NULL;
19474 }
19475
19476 for (count = 0; count < num_reg_rules; count++) {
19477 reg_rule_ptr[count].start_freq =
19478 WMI_REG_RULE_START_FREQ_GET(
19479 wmi_reg_rule[count].freq_info);
19480 reg_rule_ptr[count].end_freq =
19481 WMI_REG_RULE_END_FREQ_GET(
19482 wmi_reg_rule[count].freq_info);
19483 reg_rule_ptr[count].max_bw =
19484 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070019485 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019486 reg_rule_ptr[count].reg_power =
19487 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070019488 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053019489 reg_rule_ptr[count].ant_gain =
19490 WMI_REG_RULE_ANTENNA_GAIN_GET(
19491 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019492 reg_rule_ptr[count].flags =
19493 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070019494 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019495 }
19496
19497 return reg_rule_ptr;
19498}
19499
19500static QDF_STATUS extract_reg_chan_list_update_event_tlv(
19501 wmi_unified_t wmi_handle, uint8_t *evt_buf,
19502 struct cur_regulatory_info *reg_info, uint32_t len)
19503{
19504 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
19505 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
19506 wmi_regulatory_rule_struct *wmi_reg_rule;
19507 uint32_t num_2g_reg_rules, num_5g_reg_rules;
19508
19509 WMI_LOGD("processing regulatory channel list");
19510
19511 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
19512 if (!param_buf) {
19513 WMI_LOGE("invalid channel list event buf");
19514 return QDF_STATUS_E_FAILURE;
19515 }
19516
19517 chan_list_event_hdr = param_buf->fixed_param;
19518
19519 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
19520 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
19521 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053019522 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019523 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
19524 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070019525 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070019526 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053019527 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070019528 reg_info->ctry_code = chan_list_event_hdr->country_id;
19529 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
19530 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
19531 reg_info->status_code = REG_SET_CC_STATUS_PASS;
19532 else if (chan_list_event_hdr->status_code ==
19533 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
19534 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
19535 else if (chan_list_event_hdr->status_code ==
19536 WMI_REG_INIT_ALPHA2_NOT_FOUND)
19537 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
19538 else if (chan_list_event_hdr->status_code ==
19539 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
19540 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
19541 else if (chan_list_event_hdr->status_code ==
19542 WMI_REG_SET_CC_STATUS_NO_MEMORY)
19543 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
19544 else if (chan_list_event_hdr->status_code ==
19545 WMI_REG_SET_CC_STATUS_FAIL)
19546 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
19547
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019548 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
19549 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
19550 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
19551 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
19552
19553 num_2g_reg_rules = reg_info->num_2g_reg_rules;
19554 num_5g_reg_rules = reg_info->num_5g_reg_rules;
19555
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070019556 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
19557 __func__, reg_info->alpha2, reg_info->dfs_region,
19558 reg_info->min_bw_2g, reg_info->max_bw_2g,
19559 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019560
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070019561 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
19562 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070019563 wmi_reg_rule =
19564 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
19565 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
19566 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019567 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
19568 wmi_reg_rule);
19569 wmi_reg_rule += num_2g_reg_rules;
19570
19571 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
19572 wmi_reg_rule);
19573
19574 WMI_LOGD("processed regulatory channel list");
19575
19576 return QDF_STATUS_SUCCESS;
19577}
19578
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070019579static QDF_STATUS extract_reg_11d_new_country_event_tlv(
19580 wmi_unified_t wmi_handle, uint8_t *evt_buf,
19581 struct reg_11d_new_country *reg_11d_country, uint32_t len)
19582{
19583 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
19584 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
19585
19586 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
19587 if (!param_buf) {
19588 WMI_LOGE("invalid 11d country event buf");
19589 return QDF_STATUS_E_FAILURE;
19590 }
19591
19592 reg_11d_country_event = param_buf->fixed_param;
19593
19594 qdf_mem_copy(reg_11d_country->alpha2,
19595 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
19596
19597 WMI_LOGD("processed 11d country event, new cc %s",
19598 reg_11d_country->alpha2);
19599
19600 return QDF_STATUS_SUCCESS;
19601}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070019602
19603static QDF_STATUS extract_reg_ch_avoid_event_tlv(
19604 wmi_unified_t wmi_handle, uint8_t *evt_buf,
19605 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
19606{
19607 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
19608 wmi_avoid_freq_range_desc *afr_desc;
19609 uint32_t num_freq_ranges, freq_range_idx;
19610 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
19611 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
19612
19613 if (!param_buf) {
19614 WMI_LOGE("Invalid channel avoid event buffer");
19615 return QDF_STATUS_E_INVAL;
19616 }
19617
19618 afr_fixed_param = param_buf->fixed_param;
19619 if (!afr_fixed_param) {
19620 WMI_LOGE("Invalid channel avoid event fixed param buffer");
19621 return QDF_STATUS_E_INVAL;
19622 }
19623
19624 if (!ch_avoid_ind) {
19625 WMI_LOGE("Invalid channel avoid indication buffer");
19626 return QDF_STATUS_E_INVAL;
19627 }
19628 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
19629 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
19630 afr_fixed_param->num_freq_ranges;
19631
19632 WMI_LOGD("Channel avoid event received with %d ranges",
19633 num_freq_ranges);
19634
19635 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
19636 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
19637 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
19638 freq_range_idx++) {
19639 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
19640 afr_desc->start_freq;
19641 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
19642 afr_desc->end_freq;
19643 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
19644 freq_range_idx, afr_desc->tlv_header,
19645 afr_desc->start_freq, afr_desc->end_freq);
19646 afr_desc++;
19647 }
19648
19649 return QDF_STATUS_SUCCESS;
19650}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019651#ifdef DFS_COMPONENT_ENABLE
19652/**
19653 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
19654 * @wmi_handle: wma handle
19655 * @evt_buf: event buffer
19656 * @vdev_id: vdev id
19657 * @len: length of buffer
19658 *
19659 * Return: 0 for success or error code
19660 */
19661static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
19662 uint8_t *evt_buf,
19663 uint32_t *vdev_id,
19664 uint32_t len)
19665{
19666 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
19667 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
19668
19669 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
19670 if (!param_tlvs) {
19671 WMI_LOGE("invalid cac complete event buf");
19672 return QDF_STATUS_E_FAILURE;
19673 }
19674
19675 cac_event = param_tlvs->fixed_param;
19676 *vdev_id = cac_event->vdev_id;
19677 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
19678
19679 return QDF_STATUS_SUCCESS;
19680}
19681
19682/**
19683 * extract_dfs_radar_detection_event_tlv() - extract radar found event
19684 * @wmi_handle: wma handle
19685 * @evt_buf: event buffer
19686 * @radar_found: radar found event info
19687 * @len: length of buffer
19688 *
19689 * Return: 0 for success or error code
19690 */
19691static QDF_STATUS extract_dfs_radar_detection_event_tlv(
19692 wmi_unified_t wmi_handle,
19693 uint8_t *evt_buf,
19694 struct radar_found_info *radar_found,
19695 uint32_t len)
19696{
19697 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
19698 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
19699
19700 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
19701 if (!param_tlv) {
19702 WMI_LOGE("invalid radar detection event buf");
19703 return QDF_STATUS_E_FAILURE;
19704 }
19705
19706 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070019707 radar_found->pdev_id = wmi_handle->ops->
19708 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019709 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070019710 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019711 radar_found->chan_width = radar_event->chan_width;
19712 radar_found->detector_id = radar_event->detector_id;
19713 radar_found->segment_id = radar_event->segment_id;
19714 radar_found->timestamp = radar_event->timestamp;
19715 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070019716 radar_found->freq_offset = radar_event->freq_offset;
19717 radar_found->sidx = radar_event->sidx;
19718
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019719
19720 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070019721 WMI_LOGD("Radar Event Info:");
19722 WMI_LOGD("pdev_id %d", radar_event->pdev_id);
19723 WMI_LOGD("detection mode %d", radar_event->detection_mode);
19724 WMI_LOGD("chan_freq (dur) %d", radar_event->chan_freq);
19725 WMI_LOGD("chan_width (RSSI) %d", radar_event->chan_width);
19726 WMI_LOGD("detector_id (false_radar) %d", radar_event->detector_id);
19727 WMI_LOGD("segment_id %d", radar_event->segment_id);
19728 WMI_LOGD("timestamp %d", radar_event->timestamp);
19729 WMI_LOGD("is_chirp %d", radar_event->is_chirp);
19730 WMI_LOGD("freq_offset (radar_check) %d", radar_event->freq_offset);
19731 WMI_LOGD("sidx %d", radar_event->sidx);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019732
19733 return QDF_STATUS_SUCCESS;
19734}
19735#endif
19736
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070019737/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053019738 * send_get_rcpi_cmd_tlv() - send request for rcpi value
19739 * @wmi_handle: wmi handle
19740 * @get_rcpi_param: rcpi params
19741 *
19742 * Return: QDF status
19743 */
19744static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
19745 struct rcpi_req *get_rcpi_param)
19746{
19747 wmi_buf_t buf;
19748 wmi_request_rcpi_cmd_fixed_param *cmd;
19749 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
19750
19751 buf = wmi_buf_alloc(wmi_handle, len);
19752 if (!buf) {
19753 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
19754 return QDF_STATUS_E_NOMEM;
19755 }
19756
19757 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
19758 WMITLV_SET_HDR(&cmd->tlv_header,
19759 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
19760 WMITLV_GET_STRUCT_TLVLEN
19761 (wmi_request_rcpi_cmd_fixed_param));
19762
19763 cmd->vdev_id = get_rcpi_param->vdev_id;
19764 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
19765 &cmd->peer_macaddr);
19766 cmd->measurement_type = get_rcpi_param->measurement_type;
19767 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
19768 if (wmi_unified_cmd_send(wmi_handle, buf, len,
19769 WMI_REQUEST_RCPI_CMDID)) {
19770
19771 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
19772 __func__);
19773 wmi_buf_free(buf);
19774 return QDF_STATUS_E_FAILURE;
19775 }
19776
19777 return QDF_STATUS_SUCCESS;
19778}
19779
19780/**
19781 * extract_rcpi_response_event_tlv() - Extract RCPI event params
19782 * @wmi_handle: wmi handle
19783 * @evt_buf: pointer to event buffer
19784 * @res: pointer to hold rcpi response from firmware
19785 *
19786 * Return: QDF_STATUS_SUCCESS for successful event parse
19787 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
19788 */
19789static QDF_STATUS
19790extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
19791 void *evt_buf, struct rcpi_res *res)
19792{
19793 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
19794 wmi_update_rcpi_event_fixed_param *event;
19795
19796 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
19797 if (!param_buf) {
19798 WMI_LOGE(FL("Invalid rcpi event"));
19799 return QDF_STATUS_E_INVAL;
19800 }
19801
19802 event = param_buf->fixed_param;
19803 res->vdev_id = event->vdev_id;
19804 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
19805
19806 switch (event->measurement_type) {
19807
19808 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
19809 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
19810 break;
19811
19812 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
19813 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
19814 break;
19815
19816 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
19817 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
19818 break;
19819
19820 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
19821 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
19822 break;
19823
19824 default:
19825 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
19826 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
19827 return QDF_STATUS_E_FAILURE;
19828 }
19829
19830 if (event->status)
19831 return QDF_STATUS_E_FAILURE;
19832 else
19833 return QDF_STATUS_SUCCESS;
19834}
19835
19836/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019837 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
19838 * host to target defines. For legacy there is not conversion
19839 * required. Just return pdev_id as it is.
19840 * @param pdev_id: host pdev_id to be converted.
19841 * Return: target pdev_id after conversion.
19842 */
19843static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
19844 uint32_t pdev_id)
19845{
19846 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
19847 return WMI_PDEV_ID_SOC;
19848
19849 /*No conversion required*/
19850 return pdev_id;
19851}
19852
19853/**
19854 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
19855 * target to host defines. For legacy there is not conversion
19856 * required. Just return pdev_id as it is.
19857 * @param pdev_id: target pdev_id to be converted.
19858 * Return: host pdev_id after conversion.
19859 */
19860static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
19861 uint32_t pdev_id)
19862{
19863 /*No conversion required*/
19864 return pdev_id;
19865}
19866
19867/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070019868 * send_set_country_cmd_tlv() - WMI scan channel list function
19869 * @param wmi_handle : handle to WMI.
19870 * @param param : pointer to hold scan channel list parameter
19871 *
19872 * Return: 0 on success and -ve on failure.
19873 */
19874static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
19875 struct set_country *params)
19876{
19877 wmi_buf_t buf;
19878 QDF_STATUS qdf_status;
19879 wmi_set_current_country_cmd_fixed_param *cmd;
19880 uint16_t len = sizeof(*cmd);
19881
19882 buf = wmi_buf_alloc(wmi_handle, len);
19883 if (!buf) {
19884 WMI_LOGE("Failed to allocate memory");
19885 qdf_status = QDF_STATUS_E_NOMEM;
19886 goto end;
19887 }
19888
19889 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
19890 WMITLV_SET_HDR(&cmd->tlv_header,
19891 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
19892 WMITLV_GET_STRUCT_TLVLEN
19893 (wmi_set_current_country_cmd_fixed_param));
19894
19895 WMI_LOGD("setting cuurnet country to %s", params->country);
19896
19897 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
19898
19899 cmd->pdev_id = params->pdev_id;
19900
19901 qdf_status = wmi_unified_cmd_send(wmi_handle,
19902 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
19903
19904 if (QDF_IS_STATUS_ERROR(qdf_status)) {
19905 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
19906 wmi_buf_free(buf);
19907 }
19908
19909end:
19910 return qdf_status;
19911}
19912
Abhijit Pradhand38a2692017-06-29 12:32:20 +053019913#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
19914 WMI_SET_BITS(alpha, 0, 8, val0); \
19915 WMI_SET_BITS(alpha, 8, 8, val1); \
19916 WMI_SET_BITS(alpha, 16, 8, val2); \
19917 } while (0)
19918
19919static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
19920 uint8_t pdev_id, struct cc_regdmn_s *rd)
19921{
19922 wmi_set_init_country_cmd_fixed_param *cmd;
19923 uint16_t len;
19924 wmi_buf_t buf;
19925 int ret;
19926
19927 len = sizeof(wmi_set_init_country_cmd_fixed_param);
19928 buf = wmi_buf_alloc(wmi_handle, len);
19929 if (!buf) {
19930 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
19931 return QDF_STATUS_E_NOMEM;
19932 }
19933 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
19934 WMITLV_SET_HDR(&cmd->tlv_header,
19935 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
19936 WMITLV_GET_STRUCT_TLVLEN
19937 (wmi_set_init_country_cmd_fixed_param));
19938
19939 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
19940
19941 if (rd->flags == CC_IS_SET) {
19942 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
19943 cmd->country_code.country_id = rd->cc.country_code;
19944 } else if (rd->flags == ALPHA_IS_SET) {
19945 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
19946 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
19947 rd->cc.alpha[0],
19948 rd->cc.alpha[1],
19949 rd->cc.alpha[2]);
19950 } else if (rd->flags == REGDMN_IS_SET) {
19951 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
19952 cmd->country_code.domain_code = rd->cc.regdmn_id;
19953 }
19954
19955 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
19956 WMI_SET_INIT_COUNTRY_CMDID);
19957 if (ret) {
19958 WMI_LOGE("Failed to config wow wakeup event");
19959 wmi_buf_free(buf);
19960 return QDF_STATUS_E_FAILURE;
19961 }
19962
19963 return QDF_STATUS_SUCCESS;
19964}
19965
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053019966/**
19967 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
19968 * configuration params
19969 * @wmi_handle: wmi handler
19970 * @limit_off_chan_param: pointer to wmi_off_chan_param
19971 *
19972 * Return: 0 for success and non zero for failure
19973 */
19974static
19975QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
19976 struct wmi_limit_off_chan_param *limit_off_chan_param)
19977{
19978 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
19979 wmi_buf_t buf;
19980 uint32_t len = sizeof(*cmd);
19981 int err;
19982
19983 buf = wmi_buf_alloc(wmi_handle, len);
19984 if (!buf) {
19985 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
19986 __func__);
19987 return QDF_STATUS_E_NOMEM;
19988 }
19989
19990 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
19991
19992 WMITLV_SET_HDR(&cmd->tlv_header,
19993 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
19994 WMITLV_GET_STRUCT_TLVLEN(
19995 wmi_vdev_limit_offchan_cmd_fixed_param));
19996
19997 cmd->vdev_id = limit_off_chan_param->vdev_id;
19998
19999 cmd->flags &= 0;
20000 if (limit_off_chan_param->status)
20001 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20002 if (limit_off_chan_param->skip_dfs_chans)
20003 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20004
20005 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20006 cmd->rest_time = limit_off_chan_param->rest_time;
20007
20008 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20009 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20010 cmd->rest_time);
20011
20012 err = wmi_unified_cmd_send(wmi_handle, buf,
20013 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20014 if (QDF_IS_STATUS_ERROR(err)) {
20015 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20016 wmi_buf_free(buf);
20017 return QDF_STATUS_E_FAILURE;
20018 }
20019
20020 return QDF_STATUS_SUCCESS;
20021}
20022
Anurag Chouhan97f00422017-09-11 14:56:30 +053020023/**
20024 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20025 * @wmi_handle: wmi handler
20026 * @req_buf: set arp stats request buffer
20027 *
20028 * Return: 0 for success and non zero for failure
20029 */
20030static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20031 struct set_arp_stats *req_buf)
20032{
20033 wmi_buf_t buf = NULL;
20034 QDF_STATUS status;
20035 int len;
20036 uint8_t *buf_ptr;
20037 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20038
20039 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20040 buf = wmi_buf_alloc(wmi_handle, len);
20041 if (!buf) {
20042 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20043 return QDF_STATUS_E_NOMEM;
20044 }
20045
20046 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20047 wmi_set_arp =
20048 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20049 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20050 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20051 WMITLV_GET_STRUCT_TLVLEN
20052 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20053
20054 /* fill in per roam config values */
20055 wmi_set_arp->vdev_id = req_buf->vdev_id;
20056
20057 wmi_set_arp->set_clr = req_buf->flag;
20058 wmi_set_arp->pkt_type = req_buf->pkt_type;
20059 wmi_set_arp->ipv4 = req_buf->ip_addr;
20060
20061 /* Send per roam config parameters */
20062 status = wmi_unified_cmd_send(wmi_handle, buf,
20063 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20064 if (QDF_IS_STATUS_ERROR(status)) {
20065 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
20066 status);
20067 goto error;
20068 }
20069
20070 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
20071 req_buf->flag, req_buf->vdev_id);
20072 return QDF_STATUS_SUCCESS;
20073error:
20074 wmi_buf_free(buf);
20075
20076 return status;
20077}
20078
20079/**
20080 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
20081 * @wmi_handle: wmi handler
20082 * @req_buf: get arp stats request buffer
20083 *
20084 * Return: 0 for success and non zero for failure
20085 */
20086static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20087 struct get_arp_stats *req_buf)
20088{
20089 wmi_buf_t buf = NULL;
20090 QDF_STATUS status;
20091 int len;
20092 uint8_t *buf_ptr;
20093 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
20094
20095 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
20096 buf = wmi_buf_alloc(wmi_handle, len);
20097 if (!buf) {
20098 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20099 return QDF_STATUS_E_NOMEM;
20100 }
20101
20102 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20103 get_arp_stats =
20104 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
20105 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
20106 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
20107 WMITLV_GET_STRUCT_TLVLEN
20108 (wmi_vdev_get_arp_stats_cmd_fixed_param));
20109
20110 /* fill in arp stats req cmd values */
20111 get_arp_stats->vdev_id = req_buf->vdev_id;
20112
20113 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
20114 /* Send per roam config parameters */
20115 status = wmi_unified_cmd_send(wmi_handle, buf,
20116 len, WMI_VDEV_GET_ARP_STAT_CMDID);
20117 if (QDF_IS_STATUS_ERROR(status)) {
20118 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
20119 status);
20120 goto error;
20121 }
20122
20123 return QDF_STATUS_SUCCESS;
20124error:
20125 wmi_buf_free(buf);
20126
20127 return status;
20128}
20129
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020130/**
20131 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
20132 * @wmi_handle: wmi handler
20133 * @pmk_info: pointer to PMK cache entry
20134 * @vdev_id: vdev id
20135 *
20136 * Return: 0 for success and non zero for failure
20137 */
20138static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
20139 struct wmi_unified_pmk_cache *pmk_info)
20140{
20141 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
20142 wmi_buf_t buf;
20143 QDF_STATUS status;
20144 uint8_t *buf_ptr;
20145 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020146 uint32_t len = sizeof(*cmd);
20147
20148 if (pmk_info->pmk_len)
20149 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020150
20151 buf = wmi_buf_alloc(wmi_handle, len);
20152 if (!buf) {
20153 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
20154 __func__);
20155 return QDF_STATUS_E_NOMEM;
20156 }
20157
20158 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20159 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
20160
20161 WMITLV_SET_HDR(&cmd->tlv_header,
20162 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
20163 WMITLV_GET_STRUCT_TLVLEN(
20164 wmi_pdev_update_pmk_cache_cmd_fixed_param));
20165
20166 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020167
20168 /* If pmk_info->pmk_len is 0, this is a flush request */
20169 if (!pmk_info->pmk_len) {
20170 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
20171 cmd->num_cache = 0;
20172 goto send_cmd;
20173 }
20174
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020175 cmd->num_cache = 1;
20176 buf_ptr += sizeof(*cmd);
20177
20178 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
20179 sizeof(*pmksa));
20180 buf_ptr += WMI_TLV_HDR_SIZE;
20181
20182 pmksa = (wmi_pmk_cache *)buf_ptr;
20183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
20184 WMITLV_GET_STRUCT_TLVLEN
20185 (wmi_pmk_cache));
20186 pmksa->pmk_len = pmk_info->pmk_len;
20187 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
20188 pmksa->pmkid_len = pmk_info->pmkid_len;
20189 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
20190 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
20191 pmksa->ssid.ssid_len = pmk_info->ssid.length;
20192 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
20193 pmksa->ssid.ssid_len);
20194 pmksa->cache_id = pmk_info->cache_id;
20195 pmksa->cat_flag = pmk_info->cat_flag;
20196 pmksa->action_flag = pmk_info->action_flag;
20197
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020198send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020199 status = wmi_unified_cmd_send(wmi_handle, buf, len,
20200 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
20201 if (status != QDF_STATUS_SUCCESS) {
20202 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
20203 __func__, status);
20204 wmi_buf_free(buf);
20205 }
20206
20207 return status;
20208}
20209
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053020210/**
20211 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
20212 * @wmi_handle: wmi handle
20213 * @param: reserved param
20214 *
20215 * Return: 0 for success or error code
20216 */
20217static QDF_STATUS
20218send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
20219 uint32_t param)
20220{
20221 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
20222 wmi_buf_t buf;
20223 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
20224
20225 buf = wmi_buf_alloc(wmi_handle, len);
20226 if (!buf) {
20227 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
20228 return QDF_STATUS_E_FAILURE;
20229 }
20230 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
20231 WMITLV_SET_HDR(&cmd->tlv_header,
20232 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
20233 WMITLV_GET_STRUCT_TLVLEN
20234 (wmi_pdev_check_cal_version_cmd_fixed_param));
20235 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
20236 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20237 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
20238 wmi_buf_free(buf);
20239 return QDF_STATUS_E_FAILURE;
20240 }
20241
20242 return QDF_STATUS_SUCCESS;
20243}
20244
20245/**
20246 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
20247 * @wmi_handle: wmi handle
20248 * @param evt_buf: pointer to event buffer
20249 * @param param: Pointer to hold peer caldata version data
20250 *
20251 * Return: 0 for success or error code
20252 */
20253static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
20254 wmi_unified_t wmi_handle,
20255 void *evt_buf,
20256 wmi_host_pdev_check_cal_version_event *param)
20257{
20258 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
20259 wmi_pdev_check_cal_version_event_fixed_param *event;
20260
20261 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
20262 if (!param_tlvs) {
20263 WMI_LOGE("invalid cal version event buf");
20264 return QDF_STATUS_E_FAILURE;
20265 }
20266 event = param_tlvs->fixed_param;
20267 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
20268 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
20269 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
20270 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
20271
20272 param->software_cal_version = event->software_cal_version;
20273 param->board_cal_version = event->board_cal_version;
20274 param->cal_ok = event->cal_status;
20275
20276 return QDF_STATUS_SUCCESS;
20277}
20278
Govind Singh5eb51532016-03-09 11:34:12 +053020279struct wmi_ops tlv_ops = {
20280 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
20281 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
20282 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053020283 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
20284 .send_hidden_ssid_vdev_restart_cmd =
20285 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020286 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
20287 .send_peer_param_cmd = send_peer_param_cmd_tlv,
20288 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053020289 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020290 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053020291 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070020292 .send_peer_rx_reorder_queue_setup_cmd =
20293 send_peer_rx_reorder_queue_setup_cmd_tlv,
20294 .send_peer_rx_reorder_queue_remove_cmd =
20295 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053020296 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
20297 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
20298 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020299 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
20300 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
20301 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
20302 .send_suspend_cmd = send_suspend_cmd_tlv,
20303 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080020304#ifdef FEATURE_WLAN_D0WOW
20305 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
20306 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
20307#endif
Govind Singh5eb51532016-03-09 11:34:12 +053020308 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
20309 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
20310 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
20311 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
20312 .send_dbglog_cmd = send_dbglog_cmd_tlv,
20313 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
20314 .send_stats_request_cmd = send_stats_request_cmd_tlv,
20315 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070020316 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020317 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053020318 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020319 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
20320 .send_scan_start_cmd = send_scan_start_cmd_tlv,
20321 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
20322 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053020323 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053020324 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053020325 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
20326 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020327 .send_set_sta_uapsd_auto_trig_cmd =
20328 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053020329 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
20330 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
20331 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080020332#ifdef CONVERGED_P2P_ENABLE
20333 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
20334 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
20335#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053020336 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
20337 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053020338 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
20339 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
20340 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
20341 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
20342 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
20343 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
20344 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020345 .send_ocb_start_timing_advert_cmd =
20346 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053020347 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
20348 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
20349 .send_set_mcc_channel_time_latency_cmd =
20350 send_set_mcc_channel_time_latency_cmd_tlv,
20351 .send_set_mcc_channel_time_quota_cmd =
20352 send_set_mcc_channel_time_quota_cmd_tlv,
20353 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
20354 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053020355 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020356 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
20357 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
20358 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020359 .send_probe_rsp_tmpl_send_cmd =
20360 send_probe_rsp_tmpl_send_cmd_tlv,
20361 .send_p2p_go_set_beacon_ie_cmd =
20362 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053020363 .send_setup_install_key_cmd =
20364 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020365 .send_set_gateway_params_cmd =
20366 send_set_gateway_params_cmd_tlv,
20367 .send_set_rssi_monitoring_cmd =
20368 send_set_rssi_monitoring_cmd_tlv,
20369 .send_scan_probe_setoui_cmd =
20370 send_scan_probe_setoui_cmd_tlv,
20371 .send_reset_passpoint_network_list_cmd =
20372 send_reset_passpoint_network_list_cmd_tlv,
20373 .send_set_passpoint_network_list_cmd =
20374 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053020375 .send_roam_scan_offload_rssi_thresh_cmd =
20376 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070020377 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053020378 .send_roam_scan_filter_cmd =
20379 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020380 .send_set_epno_network_list_cmd =
20381 send_set_epno_network_list_cmd_tlv,
20382 .send_ipa_offload_control_cmd =
20383 send_ipa_offload_control_cmd_tlv,
20384 .send_extscan_get_capabilities_cmd =
20385 send_extscan_get_capabilities_cmd_tlv,
20386 .send_extscan_get_cached_results_cmd =
20387 send_extscan_get_cached_results_cmd_tlv,
20388 .send_extscan_stop_change_monitor_cmd =
20389 send_extscan_stop_change_monitor_cmd_tlv,
20390 .send_extscan_start_change_monitor_cmd =
20391 send_extscan_start_change_monitor_cmd_tlv,
20392 .send_extscan_stop_hotlist_monitor_cmd =
20393 send_extscan_stop_hotlist_monitor_cmd_tlv,
20394 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
20395 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
20396 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
20397 .send_plm_start_cmd = send_plm_start_cmd_tlv,
20398 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
20399 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070020400 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053020401 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
20402 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
20403 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
20404 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053020405 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020406 .send_snr_request_cmd = send_snr_request_cmd_tlv,
20407 .send_snr_cmd = send_snr_cmd_tlv,
20408 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053020409#ifdef WLAN_PMO_ENABLE
20410 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
20411 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
20412 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
20413 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053020414 .send_multiple_add_clear_mcbc_filter_cmd =
20415 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070020416 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053020417 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
20418 .send_process_gtk_offload_getinfo_cmd =
20419 send_process_gtk_offload_getinfo_cmd_tlv,
20420 .send_enable_enhance_multicast_offload_cmd =
20421 send_enable_enhance_multicast_offload_tlv,
20422 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
20423#ifdef FEATURE_WLAN_RA_FILTERING
20424 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
20425#endif
20426 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020427 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
20428 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053020429 .send_lphb_config_tcp_pkt_filter_cmd =
20430 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020431 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
20432 .send_lphb_config_udp_pkt_filter_cmd =
20433 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053020434 .send_enable_disable_packet_filter_cmd =
20435 send_enable_disable_packet_filter_cmd_tlv,
20436 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053020437#endif /* End of WLAN_PMO_ENABLE */
20438#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053020439 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
20440 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
20441 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053020442 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053020443 .send_roam_scan_offload_mode_cmd =
20444 send_roam_scan_offload_mode_cmd_tlv,
20445 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
20446 .send_roam_scan_offload_ap_profile_cmd =
20447 send_roam_scan_offload_ap_profile_cmd_tlv,
20448#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053020449 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
20450 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020451 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080020452 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020453 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070020454#ifdef WLAN_FEATURE_CIF_CFR
20455 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
20456#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053020457 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020458 .send_dfs_phyerr_filter_offload_en_cmd =
20459 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020460 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
20461 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
20462 .send_del_ts_cmd = send_del_ts_cmd_tlv,
20463 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
20464 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020465 .send_process_add_periodic_tx_ptrn_cmd =
20466 send_process_add_periodic_tx_ptrn_cmd_tlv,
20467 .send_process_del_periodic_tx_ptrn_cmd =
20468 send_process_del_periodic_tx_ptrn_cmd_tlv,
20469 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
20470 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
20471 .send_set_app_type2_params_in_fw_cmd =
20472 send_set_app_type2_params_in_fw_cmd_tlv,
20473 .send_set_auto_shutdown_timer_cmd =
20474 send_set_auto_shutdown_timer_cmd_tlv,
20475 .send_nan_req_cmd = send_nan_req_cmd_tlv,
20476 .send_process_dhcpserver_offload_cmd =
20477 send_process_dhcpserver_offload_cmd_tlv,
20478 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
20479 .send_process_ch_avoid_update_cmd =
20480 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053020481 .send_pdev_set_regdomain_cmd =
20482 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053020483 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
20484 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
20485 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
20486 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
20487 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
20488 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053020489 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020490 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053020491 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053020492 .send_set_base_macaddr_indicate_cmd =
20493 send_set_base_macaddr_indicate_cmd_tlv,
20494 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
20495 .send_enable_specific_fw_logs_cmd =
20496 send_enable_specific_fw_logs_cmd_tlv,
20497 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053020498 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053020499 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053020500 .send_pdev_set_dual_mac_config_cmd =
20501 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053020502 .send_app_type1_params_in_fw_cmd =
20503 send_app_type1_params_in_fw_cmd_tlv,
20504 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
20505 .send_process_roam_synch_complete_cmd =
20506 send_process_roam_synch_complete_cmd_tlv,
20507 .send_unit_test_cmd = send_unit_test_cmd_tlv,
20508 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
20509 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053020510 .send_roam_scan_offload_scan_period_cmd =
20511 send_roam_scan_offload_scan_period_cmd_tlv,
20512 .send_roam_scan_offload_chan_list_cmd =
20513 send_roam_scan_offload_chan_list_cmd_tlv,
20514 .send_roam_scan_offload_rssi_change_cmd =
20515 send_roam_scan_offload_rssi_change_cmd_tlv,
20516 .send_get_buf_extscan_hotlist_cmd =
20517 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080020518 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053020519 .send_adapt_dwelltime_params_cmd =
20520 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053020521 .send_dbs_scan_sel_params_cmd =
20522 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020523 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053020524 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
20525 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
20526 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
20527 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
20528 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
20529 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053020530 .send_vdev_set_custom_aggr_size_cmd =
20531 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053020532 .send_vdev_set_qdepth_thresh_cmd =
20533 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053020534 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
20535 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
20536 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053020537 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
20538 .send_smart_ant_set_training_info_cmd =
20539 send_smart_ant_set_training_info_cmd_tlv,
20540 .send_smart_ant_set_node_config_cmd =
20541 send_smart_ant_set_node_config_cmd_tlv,
20542 .send_set_atf_cmd = send_set_atf_cmd_tlv,
20543 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
20544 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053020545 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
20546 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
20547 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
20548 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053020549 .send_periodic_chan_stats_config_cmd =
20550 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053020551 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
20552 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
20553 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053020554 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
20555 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
20556 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
20557 .send_vdev_spectral_configure_cmd =
20558 send_vdev_spectral_configure_cmd_tlv,
20559 .send_vdev_spectral_enable_cmd =
20560 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020561 .send_thermal_mitigation_param_cmd =
20562 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053020563 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
20564 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053020565 .send_process_update_edca_param_cmd =
20566 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053020567 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020568 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053020569 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020570 .get_target_cap_from_service_ready = extract_service_ready_tlv,
20571 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
20572 .extract_host_mem_req = extract_host_mem_req_tlv,
20573 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053020574 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020575 .is_service_enabled = is_service_enabled_tlv,
20576 .save_fw_version = save_fw_version_in_service_ready_tlv,
20577 .ready_extract_init_status = ready_extract_init_status_tlv,
20578 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070020579 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053020580 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020581 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
20582 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053020583 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020584 .extract_tbttoffset_update_params =
20585 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053020586 .extract_ext_tbttoffset_update_params =
20587 extract_ext_tbttoffset_update_params_tlv,
20588 .extract_tbttoffset_num_vdevs =
20589 extract_tbttoffset_num_vdevs_tlv,
20590 .extract_ext_tbttoffset_num_vdevs =
20591 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020592 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
20593 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
20594 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
20595 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080020596#ifdef CONVERGED_TDLS_ENABLE
20597 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
20598#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053020599 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053020600 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020601 .extract_swba_tim_info = extract_swba_tim_info_tlv,
20602 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080020603#ifdef CONVERGED_P2P_ENABLE
20604 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
20605 .extract_p2p_lo_stop_ev_param =
20606 extract_p2p_lo_stop_ev_param_tlv,
20607#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053020608 .extract_offchan_data_tx_compl_param =
20609 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020610 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
20611 .extract_all_stats_count = extract_all_stats_counts_tlv,
20612 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070020613 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020614 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
20615 .extract_vdev_stats = extract_vdev_stats_tlv,
20616 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053020617 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053020618 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
20619 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
20620 .extract_chan_stats = extract_chan_stats_tlv,
20621 .extract_profile_ctx = extract_profile_ctx_tlv,
20622 .extract_profile_data = extract_profile_data_tlv,
20623 .extract_chan_info_event = extract_chan_info_event_tlv,
20624 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053020625 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053020626 .send_encrypt_decrypt_send_cmd =
20627 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080020628 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053020629 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053020630 .send_multiple_vdev_restart_req_cmd =
20631 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053020632 .extract_service_ready_ext = extract_service_ready_ext_tlv,
20633 .extract_hw_mode_cap_service_ready_ext =
20634 extract_hw_mode_cap_service_ready_ext_tlv,
20635 .extract_mac_phy_cap_service_ready_ext =
20636 extract_mac_phy_cap_service_ready_ext_tlv,
20637 .extract_reg_cap_service_ready_ext =
20638 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053020639 .extract_dbr_ring_cap_service_ready_ext =
20640 extract_dbr_ring_cap_service_ready_ext_tlv,
20641 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
20642 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053020643 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020644 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020645 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
20646 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
20647 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020648 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053020649 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020650 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053020651 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053020652 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053020653 .extract_pdev_csa_switch_count_status =
20654 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053020655 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
20656 .extract_wds_addr_event = extract_wds_addr_event_tlv,
20657 .extract_peer_sta_ps_statechange_ev =
20658 extract_peer_sta_ps_statechange_ev_tlv,
20659 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053020660 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080020661 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
20662 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020663 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020664 extract_reg_chan_list_update_event_tlv,
20665 .extract_chainmask_tables =
20666 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020667 .extract_thermal_stats = extract_thermal_stats_tlv,
20668 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020669 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
20670 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020671#ifdef DFS_COMPONENT_ENABLE
20672 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
20673 .extract_dfs_radar_detection_event =
20674 extract_dfs_radar_detection_event_tlv,
20675#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020676 .convert_pdev_id_host_to_target =
20677 convert_host_pdev_id_to_target_pdev_id_legacy,
20678 .convert_pdev_id_target_to_host =
20679 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020680
20681 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
20682 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
20683 .extract_reg_11d_new_country_event =
20684 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020685 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020686 .send_limit_off_chan_cmd =
20687 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020688 .extract_reg_ch_avoid_event =
20689 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053020690 .send_pdev_caldata_version_check_cmd =
20691 send_pdev_caldata_version_check_cmd_tlv,
20692 .extract_pdev_caldata_version_check_ev_param =
20693 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053020694 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
20695 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020696 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
20697#if defined(WLAN_FEATURE_FILS_SK)
20698 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
20699#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070020700 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053020701};
20702
Govind Singhe7f2f342016-05-23 12:12:52 +053020703/**
20704 * populate_tlv_event_id() - populates wmi event ids
20705 *
20706 * @param event_ids: Pointer to hold event ids
20707 * Return: None
20708 */
20709static void populate_tlv_events_id(uint32_t *event_ids)
20710{
20711 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
20712 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
20713 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
20714 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
20715 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
20716 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
20717 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
20718 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
20719 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
20720 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
20721 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
20722 event_ids[wmi_service_ready_ext_event_id] =
20723 WMI_SERVICE_READY_EXT_EVENTID;
20724 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
20725 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
20726 event_ids[wmi_vdev_install_key_complete_event_id] =
20727 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
20728 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
20729 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
20730
20731 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
20732 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
20733 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
20734 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
20735 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
20736 event_ids[wmi_peer_estimated_linkspeed_event_id] =
20737 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
20738 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020739 event_ids[wmi_peer_delete_response_event_id] =
20740 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020741 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
20742 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
20743 event_ids[wmi_tbttoffset_update_event_id] =
20744 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053020745 event_ids[wmi_ext_tbttoffset_update_event_id] =
20746 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020747 event_ids[wmi_offload_bcn_tx_status_event_id] =
20748 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
20749 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
20750 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
20751 event_ids[wmi_mgmt_tx_completion_event_id] =
20752 WMI_MGMT_TX_COMPLETION_EVENTID;
20753
20754 event_ids[wmi_tx_delba_complete_event_id] =
20755 WMI_TX_DELBA_COMPLETE_EVENTID;
20756 event_ids[wmi_tx_addba_complete_event_id] =
20757 WMI_TX_ADDBA_COMPLETE_EVENTID;
20758 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
20759
20760 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
20761
20762 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
20763 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
20764
20765 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053020766 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020767
20768 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
20769
20770 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080020771 event_ids[wmi_p2p_lo_stop_event_id] =
20772 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020773 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
20774 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080020775 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053020776 WMI_D0_WOW_DISABLE_ACK_EVENTID;
20777 event_ids[wmi_wow_initial_wakeup_event_id] =
20778 WMI_WOW_INITIAL_WAKEUP_EVENTID;
20779
20780 event_ids[wmi_rtt_meas_report_event_id] =
20781 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
20782 event_ids[wmi_tsf_meas_report_event_id] =
20783 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
20784 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
20785 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
20786 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
20787 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
20788 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
20789 event_ids[wmi_update_fw_mem_dump_event_id] =
20790 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
20791 event_ids[wmi_diag_event_id_log_supported_event_id] =
20792 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
20793 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
20794 event_ids[wmi_nlo_scan_complete_event_id] =
20795 WMI_NLO_SCAN_COMPLETE_EVENTID;
20796 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
20797 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
20798
20799 event_ids[wmi_gtk_offload_status_event_id] =
20800 WMI_GTK_OFFLOAD_STATUS_EVENTID;
20801 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
20802 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
20803 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
20804
20805 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
20806
20807 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
20808
20809 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
20810 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
20811 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
20812 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
20813 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
20814 event_ids[wmi_wlan_profile_data_event_id] =
20815 WMI_WLAN_PROFILE_DATA_EVENTID;
20816 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
20817 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
20818 event_ids[wmi_vdev_get_keepalive_event_id] =
20819 WMI_VDEV_GET_KEEPALIVE_EVENTID;
20820 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
20821
20822 event_ids[wmi_diag_container_event_id] =
20823 WMI_DIAG_DATA_CONTAINER_EVENTID;
20824
20825 event_ids[wmi_host_auto_shutdown_event_id] =
20826 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
20827
20828 event_ids[wmi_update_whal_mib_stats_event_id] =
20829 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
20830
20831 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
20832 event_ids[wmi_update_vdev_rate_stats_event_id] =
20833 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
20834
20835 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070020836 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020837
20838 /** Set OCB Sched Response, deprecated */
20839 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
20840
20841 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
20842 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
20843 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
20844
20845 /* GPIO Event */
20846 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
20847 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
20848
20849 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
20850 event_ids[wmi_rfkill_state_change_event_id] =
20851 WMI_RFKILL_STATE_CHANGE_EVENTID;
20852
20853 /* TDLS Event */
20854 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
20855
20856 event_ids[wmi_batch_scan_enabled_event_id] =
20857 WMI_BATCH_SCAN_ENABLED_EVENTID;
20858 event_ids[wmi_batch_scan_result_event_id] =
20859 WMI_BATCH_SCAN_RESULT_EVENTID;
20860 /* OEM Event */
20861 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
20862 event_ids[wmi_oem_meas_report_event_id] =
20863 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
20864 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
20865
20866 /* NAN Event */
20867 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
20868
20869 /* LPI Event */
20870 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
20871 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
20872 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
20873
20874 /* ExtScan events */
20875 event_ids[wmi_extscan_start_stop_event_id] =
20876 WMI_EXTSCAN_START_STOP_EVENTID;
20877 event_ids[wmi_extscan_operation_event_id] =
20878 WMI_EXTSCAN_OPERATION_EVENTID;
20879 event_ids[wmi_extscan_table_usage_event_id] =
20880 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
20881 event_ids[wmi_extscan_cached_results_event_id] =
20882 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
20883 event_ids[wmi_extscan_wlan_change_results_event_id] =
20884 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
20885 event_ids[wmi_extscan_hotlist_match_event_id] =
20886 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
20887 event_ids[wmi_extscan_capabilities_event_id] =
20888 WMI_EXTSCAN_CAPABILITIES_EVENTID;
20889 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
20890 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
20891
20892 /* mDNS offload events */
20893 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
20894
20895 /* SAP Authentication offload events */
20896 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
20897 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
20898
20899 /** Out-of-context-of-bss (OCB) events */
20900 event_ids[wmi_ocb_set_config_resp_event_id] =
20901 WMI_OCB_SET_CONFIG_RESP_EVENTID;
20902 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
20903 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
20904 event_ids[wmi_dcc_get_stats_resp_event_id] =
20905 WMI_DCC_GET_STATS_RESP_EVENTID;
20906 event_ids[wmi_dcc_update_ndl_resp_event_id] =
20907 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
20908 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
20909 /* System-On-Chip events */
20910 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
20911 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
20912 event_ids[wmi_soc_hw_mode_transition_event_id] =
20913 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
20914 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
20915 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053020916 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053020917 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
20918 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020919 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053020920 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
20921 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
20922 event_ids[wmi_peer_sta_ps_statechg_event_id] =
20923 WMI_PEER_STA_PS_STATECHG_EVENTID;
20924 event_ids[wmi_pdev_channel_hopping_event_id] =
20925 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053020926 event_ids[wmi_offchan_data_tx_completion_event] =
20927 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020928 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
20929 event_ids[wmi_dfs_radar_detection_event_id] =
20930 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020931 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070020932 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053020933 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053020934 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053020935 event_ids[wmi_service_available_event_id] =
20936 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020937 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053020938 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053020939 /* NDP events */
20940 event_ids[wmi_ndp_initiator_rsp_event_id] =
20941 WMI_NDP_INITIATOR_RSP_EVENTID;
20942 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
20943 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
20944 event_ids[wmi_ndp_responder_rsp_event_id] =
20945 WMI_NDP_RESPONDER_RSP_EVENTID;
20946 event_ids[wmi_ndp_end_indication_event_id] =
20947 WMI_NDP_END_INDICATION_EVENTID;
20948 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
20949
20950 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
20951 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
20952 event_ids[wmi_pdev_chip_power_stats_event_id] =
20953 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
20954 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
20955 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
20956 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
20957 event_ids[wmi_bpf_capability_info_event_id] =
20958 WMI_BPF_CAPABILIY_INFO_EVENTID;
20959 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
20960 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
20961 event_ids[wmi_report_rx_aggr_failure_event_id] =
20962 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
20963 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
20964 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
20965 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
20966 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
20967 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
20968 event_ids[wmi_pdev_hw_mode_transition_event_id] =
20969 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
20970 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
20971 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
20972 event_ids[wmi_coex_bt_activity_event_id] =
20973 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
20974 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
20975 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
20976 event_ids[wmi_radio_tx_power_level_stats_event_id] =
20977 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
20978 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053020979 event_ids[wmi_dma_buf_release_event_id] =
20980 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053020981}
20982
Soumya Bhat488092d2017-03-22 14:41:01 +053020983#ifndef CONFIG_MCL
20984/**
20985 * populate_tlv_service() - populates wmi services
20986 *
20987 * @param wmi_service: Pointer to hold wmi_service
20988 * Return: None
20989 */
20990static void populate_tlv_service(uint32_t *wmi_service)
20991{
20992 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053020993 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053020994 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
20995 wmi_service[wmi_service_roam_scan_offload] =
20996 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
20997 wmi_service[wmi_service_bcn_miss_offload] =
20998 WMI_SERVICE_BCN_MISS_OFFLOAD;
20999 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
21000 wmi_service[wmi_service_sta_advanced_pwrsave] =
21001 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
21002 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
21003 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
21004 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
21005 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
21006 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
21007 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
21008 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
21009 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
21010 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
21011 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
21012 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
21013 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
21014 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
21015 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
21016 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
21017 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
21018 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
21019 wmi_service[wmi_service_packet_power_save] =
21020 WMI_SERVICE_PACKET_POWER_SAVE;
21021 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
21022 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
21023 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
21024 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
21025 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
21026 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
21027 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
21028 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
21029 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
21030 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
21031 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
21032 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
21033 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
21034 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
21035 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
21036 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
21037 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
21038 wmi_service[wmi_service_mcc_bcn_interval_change] =
21039 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
21040 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
21041 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
21042 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
21043 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
21044 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
21045 wmi_service[wmi_service_lte_ant_share_support] =
21046 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
21047 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
21048 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
21049 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
21050 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
21051 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
21052 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
21053 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
21054 wmi_service[wmi_service_bcn_txrate_override] =
21055 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
21056 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
21057 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
21058 wmi_service[wmi_service_estimate_linkspeed] =
21059 WMI_SERVICE_ESTIMATE_LINKSPEED;
21060 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
21061 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
21062 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
21063 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
21064 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
21065 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
21066 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
21067 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
21068 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
21069 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
21070 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
21071 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
21072 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
21073 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
21074 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
21075 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
21076 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
21077 wmi_service[wmi_service_sap_auth_offload] =
21078 WMI_SERVICE_SAP_AUTH_OFFLOAD;
21079 wmi_service[wmi_service_dual_band_simultaneous_support] =
21080 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
21081 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
21082 wmi_service[wmi_service_ap_arpns_offload] =
21083 WMI_SERVICE_AP_ARPNS_OFFLOAD;
21084 wmi_service[wmi_service_per_band_chainmask_support] =
21085 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
21086 wmi_service[wmi_service_packet_filter_offload] =
21087 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
21088 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
21089 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
21090 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
21091 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
21092 wmi_service[wmi_service_multiple_vdev_restart] =
21093 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
21094
21095 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
21096 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
21097 wmi_service[wmi_service_smart_antenna_sw_support] =
21098 WMI_SERVICE_UNAVAILABLE;
21099 wmi_service[wmi_service_smart_antenna_hw_support] =
21100 WMI_SERVICE_UNAVAILABLE;
21101 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053021102 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053021103 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053021104 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
21105 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
21106 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
21107 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
21108 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
21109 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
21110 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
21111 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053021112 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
21113 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
21114 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053021115 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053021116 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
21117 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
21118 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
21119 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
21120 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
21121 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053021122 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
21123 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
21124 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
21125 wmi_service[wmi_service_unified_wow_capability] =
21126 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
21127 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
21128 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
21129 wmi_service[wmi_service_sync_delete_cmds] =
21130 WMI_SERVICE_SYNC_DELETE_CMDS;
21131 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
21132 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
21133 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
21134 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
21135 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
21136 wmi_service[wmi_service_deprecated_replace] =
21137 WMI_SERVICE_DEPRECATED_REPLACE;
21138 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
21139 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
21140 wmi_service[wmi_service_enhanced_mcast_filter] =
21141 WMI_SERVICE_ENHANCED_MCAST_FILTER;
21142 wmi_service[wmi_service_half_rate_quarter_rate_support] =
21143 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
21144 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
21145 wmi_service[wmi_service_p2p_listen_offload_support] =
21146 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
21147 wmi_service[wmi_service_mark_first_wakeup_packet] =
21148 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
21149 wmi_service[wmi_service_multiple_mcast_filter_set] =
21150 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
21151 wmi_service[wmi_service_host_managed_rx_reorder] =
21152 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
21153 wmi_service[wmi_service_flash_rdwr_support] =
21154 WMI_SERVICE_FLASH_RDWR_SUPPORT;
21155 wmi_service[wmi_service_wlan_stats_report] =
21156 WMI_SERVICE_WLAN_STATS_REPORT;
21157 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
21158 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
21159 wmi_service[wmi_service_dfs_phyerr_offload] =
21160 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
21161 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
21162 wmi_service[wmi_service_fw_mem_dump_support] =
21163 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
21164 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
21165 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
21166 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
21167 wmi_service[wmi_service_hw_data_filtering] =
21168 WMI_SERVICE_HW_DATA_FILTERING;
21169 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
21170 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053021171 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053021172 wmi_service[wmi_service_extended_nss_support] =
21173 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053021174 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053021175 wmi_service[wmi_service_bcn_offload_start_stop_support] =
21176 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053021177 wmi_service[wmi_service_offchan_data_tid_support] =
21178 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053021179 wmi_service[wmi_service_support_dma] =
21180 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Soumya Bhat488092d2017-03-22 14:41:01 +053021181}
21182
Govind Singhe7f2f342016-05-23 12:12:52 +053021183/**
21184 * populate_pdev_param_tlv() - populates pdev params
21185 *
21186 * @param pdev_param: Pointer to hold pdev params
21187 * Return: None
21188 */
21189static void populate_pdev_param_tlv(uint32_t *pdev_param)
21190{
21191 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
21192 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
21193 pdev_param[wmi_pdev_param_txpower_limit2g] =
21194 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
21195 pdev_param[wmi_pdev_param_txpower_limit5g] =
21196 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
21197 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
21198 pdev_param[wmi_pdev_param_beacon_gen_mode] =
21199 WMI_PDEV_PARAM_BEACON_GEN_MODE;
21200 pdev_param[wmi_pdev_param_beacon_tx_mode] =
21201 WMI_PDEV_PARAM_BEACON_TX_MODE;
21202 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
21203 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
21204 pdev_param[wmi_pdev_param_protection_mode] =
21205 WMI_PDEV_PARAM_PROTECTION_MODE;
21206 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
21207 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
21208 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
21209 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
21210 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
21211 pdev_param[wmi_pdev_param_sta_kickout_th] =
21212 WMI_PDEV_PARAM_STA_KICKOUT_TH;
21213 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
21214 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
21215 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
21216 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
21217 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
21218 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
21219 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
21220 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
21221 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
21222 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
21223 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
21224 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
21225 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
21226 pdev_param[wmi_pdev_param_ltr_sleep_override] =
21227 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
21228 pdev_param[wmi_pdev_param_ltr_rx_override] =
21229 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
21230 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
21231 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
21232 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
21233 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
21234 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
21235 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
21236 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
21237 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
21238 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
21239 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
21240 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
21241 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
21242 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
21243 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
21244 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
21245 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
21246 pdev_param[wmi_pdev_param_peer_stats_update_period] =
21247 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
21248 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
21249 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
21250 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
21251 pdev_param[wmi_pdev_param_arp_ac_override] =
21252 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
21253 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
21254 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
21255 pdev_param[wmi_pdev_param_ani_poll_period] =
21256 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
21257 pdev_param[wmi_pdev_param_ani_listen_period] =
21258 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
21259 pdev_param[wmi_pdev_param_ani_ofdm_level] =
21260 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
21261 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
21262 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
21263 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
21264 pdev_param[wmi_pdev_param_idle_ps_config] =
21265 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
21266 pdev_param[wmi_pdev_param_power_gating_sleep] =
21267 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
21268 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
21269 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
21270 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
21271 pdev_param[wmi_pdev_param_hw_rfkill_config] =
21272 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
21273 pdev_param[wmi_pdev_param_low_power_rf_enable] =
21274 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
21275 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
21276 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
21277 pdev_param[wmi_pdev_param_power_collapse_enable] =
21278 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
21279 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
21280 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
21281 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
21282 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
21283 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
21284 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
21285 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
21286 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
21287 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
21288 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
21289 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
21290 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
21291 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
21292 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
21293 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
21294 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
21295 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
21296 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
21297 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
21298 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
21299 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
21300 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
21301 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
21302 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
21303 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
21304 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
21305 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
21306 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
21307 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
21308 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
21309 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
21310 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
21311 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
21312 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
21313 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
21314 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
21315 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
21316 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
21317 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
21318 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
21319 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
21320 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
21321 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
21322 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021323 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
21324 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
21325 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053021326 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
21327 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021328 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053021329 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053021330 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
21331 pdev_param[wmi_pdev_param_proxy_sta_mode] =
21332 WMI_PDEV_PARAM_PROXY_STA_MODE;
21333 pdev_param[wmi_pdev_param_mu_group_policy] =
21334 WMI_PDEV_PARAM_MU_GROUP_POLICY;
21335 pdev_param[wmi_pdev_param_noise_detection] =
21336 WMI_PDEV_PARAM_NOISE_DETECTION;
21337 pdev_param[wmi_pdev_param_noise_threshold] =
21338 WMI_PDEV_PARAM_NOISE_THRESHOLD;
21339 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
21340 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
21341 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053021342 pdev_param[wmi_pdev_param_atf_strict_sch] =
21343 WMI_PDEV_PARAM_ATF_STRICT_SCH;
21344 pdev_param[wmi_pdev_param_atf_sched_duration] =
21345 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021346 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
21347 pdev_param[wmi_pdev_param_sensitivity_level] =
21348 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
21349 pdev_param[wmi_pdev_param_signed_txpower_2g] =
21350 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
21351 pdev_param[wmi_pdev_param_signed_txpower_5g] =
21352 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070021353 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
21354 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
21355 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
21356 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021357 pdev_param[wmi_pdev_param_cca_threshold] =
21358 WMI_PDEV_PARAM_CCA_THRESHOLD;
21359 pdev_param[wmi_pdev_param_rts_fixed_rate] =
21360 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053021361 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021362 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
21363 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
21364 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
21365 pdev_param[wmi_pdev_param_arp_srcaddr] =
21366 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
21367 pdev_param[wmi_pdev_param_arp_dstaddr] =
21368 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
21369 pdev_param[wmi_pdev_param_txpower_decr_db] =
21370 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053021371 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
21372 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053021373 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
21374 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053021375 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053021376 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021377 pdev_param[wmi_pdev_param_cust_txpower_scale] =
21378 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053021379 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
21380 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053021381 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
21382 WMI_UNAVAILABLE_PARAM;
21383 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
21384 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021385 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
21386 pdev_param[wmi_pdev_param_block_interbss] =
21387 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053021388 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053021389 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
21390 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
21391 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021392 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053021393 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053021394 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
21395 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053021396 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053021397 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
21398 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053021399 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
21400 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
21401 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
21402 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
21403 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
21404 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
21405 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
21406 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
21407 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
21408 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
21409 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
21410 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
21411 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
21412 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
21413 pdev_param[wmi_pdev_param_fast_channel_reset] =
21414 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
21415 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053021416 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053021417}
21418
21419/**
21420 * populate_vdev_param_tlv() - populates vdev params
21421 *
21422 * @param vdev_param: Pointer to hold vdev params
21423 * Return: None
21424 */
21425static void populate_vdev_param_tlv(uint32_t *vdev_param)
21426{
21427 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
21428 vdev_param[wmi_vdev_param_fragmentation_threshold] =
21429 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
21430 vdev_param[wmi_vdev_param_beacon_interval] =
21431 WMI_VDEV_PARAM_BEACON_INTERVAL;
21432 vdev_param[wmi_vdev_param_listen_interval] =
21433 WMI_VDEV_PARAM_LISTEN_INTERVAL;
21434 vdev_param[wmi_vdev_param_multicast_rate] =
21435 WMI_VDEV_PARAM_MULTICAST_RATE;
21436 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
21437 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
21438 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
21439 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
21440 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
21441 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
21442 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
21443 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
21444 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
21445 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
21446 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
21447 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
21448 vdev_param[wmi_vdev_param_bmiss_count_max] =
21449 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
21450 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
21451 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
21452 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
21453 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
21454 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
21455 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
21456 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
21457 vdev_param[wmi_vdev_param_disable_htprotection] =
21458 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
21459 vdev_param[wmi_vdev_param_sta_quickkickout] =
21460 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
21461 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
21462 vdev_param[wmi_vdev_param_protection_mode] =
21463 WMI_VDEV_PARAM_PROTECTION_MODE;
21464 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
21465 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
21466 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
21467 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
21468 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
21469 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
21470 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
21471 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
21472 vdev_param[wmi_vdev_param_bcast_data_rate] =
21473 WMI_VDEV_PARAM_BCAST_DATA_RATE;
21474 vdev_param[wmi_vdev_param_mcast_data_rate] =
21475 WMI_VDEV_PARAM_MCAST_DATA_RATE;
21476 vdev_param[wmi_vdev_param_mcast_indicate] =
21477 WMI_VDEV_PARAM_MCAST_INDICATE;
21478 vdev_param[wmi_vdev_param_dhcp_indicate] =
21479 WMI_VDEV_PARAM_DHCP_INDICATE;
21480 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
21481 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
21482 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
21483 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
21484 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
21485 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
21486 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
21487 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
21488 vdev_param[wmi_vdev_param_ap_enable_nawds] =
21489 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
21490 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
21491 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
21492 vdev_param[wmi_vdev_param_packet_powersave] =
21493 WMI_VDEV_PARAM_PACKET_POWERSAVE;
21494 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
21495 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
21496 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
21497 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
21498 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
21499 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
21500 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
21501 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
21502 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
21503 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
21504 vdev_param[wmi_vdev_param_early_rx_slop_step] =
21505 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
21506 vdev_param[wmi_vdev_param_early_rx_init_slop] =
21507 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
21508 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
21509 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
21510 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
21511 vdev_param[wmi_vdev_param_snr_num_for_cal] =
21512 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
21513 vdev_param[wmi_vdev_param_roam_fw_offload] =
21514 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
21515 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
21516 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
21517 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
21518 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
21519 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
21520 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
21521 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
21522 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
21523 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
21524 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
21525 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
21526 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
21527 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
21528 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
21529 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
21530 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
21531 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
21532 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
21533 vdev_param[wmi_vdev_param_inactivity_cnt] =
21534 WMI_VDEV_PARAM_INACTIVITY_CNT;
21535 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
21536 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
21537 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
21538 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
21539 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
21540 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
21541 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
21542 vdev_param[wmi_vdev_param_rx_leak_window] =
21543 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
21544 vdev_param[wmi_vdev_param_stats_avg_factor] =
21545 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
21546 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
21547 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
21548 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
21549 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
21550 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
21551 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053021552 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
21553 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053021554 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080021555 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
21556 vdev_param[wmi_vdev_param_he_range_ext_enable] =
21557 WMI_VDEV_PARAM_HE_RANGE_EXT;
21558 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
21559 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070021560 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053021561 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
21562 vdev_param[wmi_vdev_param_dtim_enable_cts] =
21563 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
21564 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
21565 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
21566 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
21567 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053021568 vdev_param[wmi_vdev_param_mcast2ucast_set] =
21569 WMI_VDEV_PARAM_MCAST2UCAST_SET;
21570 vdev_param[wmi_vdev_param_rc_num_retries] =
21571 WMI_VDEV_PARAM_RC_NUM_RETRIES;
21572 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
21573 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
21574 vdev_param[wmi_vdev_param_rts_fixed_rate] =
21575 WMI_VDEV_PARAM_RTS_FIXED_RATE;
21576 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
21577 vdev_param[wmi_vdev_param_vht80_ratemask] =
21578 WMI_VDEV_PARAM_VHT80_RATEMASK;
21579 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
21580 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
21581 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika88e11832017-09-18 15:59:34 -070021582 vdev_param[wmi_vdev_param_set_he_ltf] = WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053021583 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
21584 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Govind Singhe7f2f342016-05-23 12:12:52 +053021585}
21586#endif
21587
Govind Singh5eb51532016-03-09 11:34:12 +053021588/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021589 * populate_target_defines_tlv() - Populate target defines and params
21590 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053021591 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053021592 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053021593 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053021594#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021595static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053021596{
Govind Singhe7f2f342016-05-23 12:12:52 +053021597 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053021598 populate_pdev_param_tlv(wmi_handle->pdev_param);
21599 populate_vdev_param_tlv(wmi_handle->vdev_param);
21600}
21601#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021602static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
21603{ }
21604#endif
21605
21606/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021607 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21608 * host to target defines.
21609 * @param pdev_id: host pdev_id to be converted.
21610 * Return: target pdev_id after conversion.
21611 */
21612static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21613{
21614 switch (pdev_id) {
21615 case WMI_HOST_PDEV_ID_SOC:
21616 return WMI_PDEV_ID_SOC;
21617 case WMI_HOST_PDEV_ID_0:
21618 return WMI_PDEV_ID_1ST;
21619 case WMI_HOST_PDEV_ID_1:
21620 return WMI_PDEV_ID_2ND;
21621 case WMI_HOST_PDEV_ID_2:
21622 return WMI_PDEV_ID_3RD;
21623 }
21624
21625 QDF_ASSERT(0);
21626
21627 return WMI_PDEV_ID_SOC;
21628}
21629
21630/**
21631 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21632 * target to host defines.
21633 * @param pdev_id: target pdev_id to be converted.
21634 * Return: host pdev_id after conversion.
21635 */
21636static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21637{
21638 switch (pdev_id) {
21639 case WMI_PDEV_ID_SOC:
21640 return WMI_HOST_PDEV_ID_SOC;
21641 case WMI_PDEV_ID_1ST:
21642 return WMI_HOST_PDEV_ID_0;
21643 case WMI_PDEV_ID_2ND:
21644 return WMI_HOST_PDEV_ID_1;
21645 case WMI_PDEV_ID_3RD:
21646 return WMI_HOST_PDEV_ID_2;
21647 }
21648
21649 QDF_ASSERT(0);
21650
21651 return WMI_HOST_PDEV_ID_SOC;
21652}
21653
21654/**
21655 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21656 *
21657 * Return None.
21658 */
21659void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21660{
21661 wmi_handle->ops->convert_pdev_id_host_to_target =
21662 convert_host_pdev_id_to_target_pdev_id;
21663 wmi_handle->ops->convert_pdev_id_target_to_host =
21664 convert_target_pdev_id_to_host_pdev_id;
21665}
21666/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021667 * wmi_tlv_attach() - Attach TLV APIs
21668 *
21669 * Return: None
21670 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053021671void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053021672{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053021673 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053021674#ifdef WMI_INTERFACE_EVENT_LOGGING
21675 wmi_handle->log_info.buf_offset_command = 2;
21676 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053021677#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053021678 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021679 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053021680}