blob: 5d7ab3fc47a726b5c95dc4620b92acd6891b88db [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);
Govind Singhb53420c2016-03-09 14:32:57 +0530107 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +0530108 __func__, param->if_id,
109 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
346 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530347 cmd->beacon_interval = req->beacon_intval;
348 cmd->dtim_period = req->dtim_period;
349
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 /* Copy the SSID */
351 if (req->ssid.length) {
352 if (req->ssid.length < sizeof(cmd->ssid.ssid))
353 cmd->ssid.ssid_len = req->ssid.length;
354 else
355 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
356 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
357 cmd->ssid.ssid_len);
358 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530359
360 if (req->hidden_ssid)
361 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
362
363 if (req->pmf_enabled)
364 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530365 }
366
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700367 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530368 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530369 cmd->preferred_rx_streams = req->preferred_rx_streams;
370 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700371 cmd->cac_duration_ms = req->cac_duration_ms;
372 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700373 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530374
375 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
376 sizeof(wmi_channel));
377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
378 cmd->num_noa_descriptors *
379 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800380 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530381 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
382 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700383 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800384 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385 req->is_dfs, req->beacon_intval, cmd->dtim_period,
386 chan->band_center_freq1, chan->band_center_freq2,
387 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700388 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700389 req->ldpc_rx_enabled, req->cac_duration_ms,
390 req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530391
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 if (req->is_restart)
393 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
394 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530395 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
397 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530398 if (ret) {
399 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530400 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530402 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530403
404 return QDF_STATUS_SUCCESS;
405}
406
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407/**
408 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
409 * @wmi_handle: wmi handle
410 * @restart_params: vdev restart params
411 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530412 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530414static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530415 struct hidden_ssid_vdev_restart_params *restart_params)
416{
417 wmi_vdev_start_request_cmd_fixed_param *cmd;
418 wmi_buf_t buf;
419 wmi_channel *chan;
420 int32_t len;
421 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530422 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530423
424 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
425 buf = wmi_buf_alloc(wmi_handle, len);
426 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530427 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530428 return QDF_STATUS_E_NOMEM;
429 }
430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
431 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
432 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
433
434 WMITLV_SET_HDR(&cmd->tlv_header,
435 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
436 WMITLV_GET_STRUCT_TLVLEN
437 (wmi_vdev_start_request_cmd_fixed_param));
438
439 WMITLV_SET_HDR(&chan->tlv_header,
440 WMITLV_TAG_STRUC_wmi_channel,
441 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
442
443 cmd->vdev_id = restart_params->session_id;
444 cmd->ssid.ssid_len = restart_params->ssid_len;
445 qdf_mem_copy(cmd->ssid.ssid,
446 restart_params->ssid,
447 cmd->ssid.ssid_len);
448 cmd->flags = restart_params->flags;
449 cmd->requestor_id = restart_params->requestor_id;
450 cmd->disable_hw_ack = restart_params->disable_hw_ack;
451
452 chan->mhz = restart_params->mhz;
453 chan->band_center_freq1 =
454 restart_params->band_center_freq1;
455 chan->band_center_freq2 =
456 restart_params->band_center_freq2;
457 chan->info = restart_params->info;
458 chan->reg_info_1 = restart_params->reg_info_1;
459 chan->reg_info_2 = restart_params->reg_info_2;
460
461 cmd->num_noa_descriptors = 0;
462 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
463 sizeof(wmi_channel));
464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
465 cmd->num_noa_descriptors *
466 sizeof(wmi_p2p_noa_descriptor));
467
468 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
469 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530470 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530471 wmi_buf_free(buf);
472 return QDF_STATUS_E_FAILURE;
473 }
474 return QDF_STATUS_SUCCESS;
475}
476
477
478/**
Govind Singh5eb51532016-03-09 11:34:12 +0530479 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
480 * @wmi: wmi handle
481 * @peer_addr: peer mac address
482 * @param: pointer to hold peer flush tid parameter
483 *
484 * Return: 0 for sucess or error code
485 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530486static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530487 uint8_t peer_addr[IEEE80211_ADDR_LEN],
488 struct peer_flush_params *param)
489{
490 wmi_peer_flush_tids_cmd_fixed_param *cmd;
491 wmi_buf_t buf;
492 int32_t len = sizeof(*cmd);
493
494 buf = wmi_buf_alloc(wmi, len);
495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530496 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530497 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530498 }
499 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
500 WMITLV_SET_HDR(&cmd->tlv_header,
501 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
502 WMITLV_GET_STRUCT_TLVLEN
503 (wmi_peer_flush_tids_cmd_fixed_param));
504 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
505 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
506 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530507 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530508 peer_addr, param->vdev_id,
509 param->peer_tid_bitmap);
510 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530511 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530512 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530513 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530514 }
515
516 return 0;
517}
518
519/**
520 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
521 * @wmi: wmi handle
522 * @peer_addr: peer mac addr
523 * @vdev_id: vdev id
524 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530525 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530526 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530527static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530528 uint8_t peer_addr[IEEE80211_ADDR_LEN],
529 uint8_t vdev_id)
530{
531 wmi_peer_delete_cmd_fixed_param *cmd;
532 wmi_buf_t buf;
533 int32_t len = sizeof(*cmd);
534 buf = wmi_buf_alloc(wmi, len);
535 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530536 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530537 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530538 }
539 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
540 WMITLV_SET_HDR(&cmd->tlv_header,
541 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
542 WMITLV_GET_STRUCT_TLVLEN
543 (wmi_peer_delete_cmd_fixed_param));
544 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
545 cmd->vdev_id = vdev_id;
546
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800547 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530548 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530549 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530550 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530551 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530552 }
Govind Singh5eb51532016-03-09 11:34:12 +0530553
554 return 0;
555}
556
557/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530558 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
559 * to target id.
560 * @targ_paramid: Target parameter id to hold the result.
561 * @peer_param_id: host param id.
562 *
563 * Return: QDF_STATUS_SUCCESS for success
564 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
565 */
566#ifdef CONFIG_MCL
567static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
568 uint32_t *targ_paramid,
569 uint32_t peer_param_id)
570{
571 *targ_paramid = peer_param_id;
572 return QDF_STATUS_SUCCESS;
573}
574#else
575static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
576 uint32_t *targ_paramid,
577 uint32_t peer_param_id)
578{
579 switch (peer_param_id) {
580 case WMI_HOST_PEER_MIMO_PS_STATE:
581 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
582 break;
583 case WMI_HOST_PEER_AMPDU:
584 *targ_paramid = WMI_PEER_AMPDU;
585 break;
586 case WMI_HOST_PEER_AUTHORIZE:
587 *targ_paramid = WMI_PEER_AUTHORIZE;
588 break;
589 case WMI_HOST_PEER_CHWIDTH:
590 *targ_paramid = WMI_PEER_CHWIDTH;
591 break;
592 case WMI_HOST_PEER_NSS:
593 *targ_paramid = WMI_PEER_NSS;
594 break;
595 case WMI_HOST_PEER_USE_4ADDR:
596 *targ_paramid = WMI_PEER_USE_4ADDR;
597 break;
598 case WMI_HOST_PEER_MEMBERSHIP:
599 *targ_paramid = WMI_PEER_MEMBERSHIP;
600 break;
601 case WMI_HOST_PEER_USERPOS:
602 *targ_paramid = WMI_PEER_USERPOS;
603 break;
604 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
605 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
606 break;
607 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
608 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
609 break;
610 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
611 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
612 break;
613 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
614 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
615 break;
616 case WMI_HOST_PEER_PHYMODE:
617 *targ_paramid = WMI_PEER_PHYMODE;
618 break;
619 case WMI_HOST_PEER_USE_FIXED_PWR:
620 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
621 break;
622 case WMI_HOST_PEER_PARAM_FIXED_RATE:
623 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
624 break;
625 case WMI_HOST_PEER_SET_MU_WHITELIST:
626 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
627 break;
628 case WMI_HOST_PEER_SET_MAC_TX_RATE:
629 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
630 break;
631 case WMI_HOST_PEER_SET_MIN_TX_RATE:
632 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
633 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530634 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
635 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
636 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530637 default:
638 return QDF_STATUS_E_NOSUPPORT;
639 }
640
641 return QDF_STATUS_SUCCESS;
642}
643#endif
644/**
Govind Singh5eb51532016-03-09 11:34:12 +0530645 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530646 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530647 * @peer_addr: peer mac address
648 * @param : pointer to hold peer set parameter
649 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530650 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530651 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530652static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530653 uint8_t peer_addr[IEEE80211_ADDR_LEN],
654 struct peer_set_params *param)
655{
656 wmi_peer_set_param_cmd_fixed_param *cmd;
657 wmi_buf_t buf;
658 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530659 uint32_t param_id;
660
661 if (convert_host_peer_id_to_target_id_tlv(&param_id,
662 param->param_id) != QDF_STATUS_SUCCESS)
663 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530664
665 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
666 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530667 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530668 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530669 }
670 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
671 WMITLV_SET_HDR(&cmd->tlv_header,
672 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
673 WMITLV_GET_STRUCT_TLVLEN
674 (wmi_peer_set_param_cmd_fixed_param));
675 cmd->vdev_id = param->vdev_id;
676 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530677 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530678 cmd->param_value = param->param_value;
679 err = wmi_unified_cmd_send(wmi, buf,
680 sizeof(wmi_peer_set_param_cmd_fixed_param),
681 WMI_PEER_SET_PARAM_CMDID);
682 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530683 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530684 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530685 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530686 }
687
688 return 0;
689}
690
691/**
692 * send_vdev_up_cmd_tlv() - send vdev up command in fw
693 * @wmi: wmi handle
694 * @bssid: bssid
695 * @vdev_up_params: pointer to hold vdev up parameter
696 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530697 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530698 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530699static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530700 uint8_t bssid[IEEE80211_ADDR_LEN],
701 struct vdev_up_params *params)
702{
703 wmi_vdev_up_cmd_fixed_param *cmd;
704 wmi_buf_t buf;
705 int32_t len = sizeof(*cmd);
706
Govind Singhb53420c2016-03-09 14:32:57 +0530707 WMI_LOGD("%s: VDEV_UP", __func__);
708 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530709 params->vdev_id, params->assoc_id, bssid);
710 buf = wmi_buf_alloc(wmi, len);
711 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530712 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530713 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530714 }
715 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
716 WMITLV_SET_HDR(&cmd->tlv_header,
717 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
718 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
719 cmd->vdev_id = params->vdev_id;
720 cmd->vdev_assoc_id = params->assoc_id;
721 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
722 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530723 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530724 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530725 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530726 }
727
728 return 0;
729}
730
731/**
732 * send_peer_create_cmd_tlv() - send peer create command to fw
733 * @wmi: wmi handle
734 * @peer_addr: peer mac address
735 * @peer_type: peer type
736 * @vdev_id: vdev id
737 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530738 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530739 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530740static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530741 struct peer_create_params *param)
742{
743 wmi_peer_create_cmd_fixed_param *cmd;
744 wmi_buf_t buf;
745 int32_t len = sizeof(*cmd);
746
747 buf = wmi_buf_alloc(wmi, len);
748 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530749 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530750 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530751 }
752 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
753 WMITLV_SET_HDR(&cmd->tlv_header,
754 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
755 WMITLV_GET_STRUCT_TLVLEN
756 (wmi_peer_create_cmd_fixed_param));
757 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
758 cmd->peer_type = param->peer_type;
759 cmd->vdev_id = param->vdev_id;
760
761 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530762 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530763 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530764 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530765 }
Govind Singhb53420c2016-03-09 14:32:57 +0530766 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530767 param->vdev_id);
768
769 return 0;
770}
771
772/**
Leo Changeee40872016-09-28 13:43:36 -0700773 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
774 * command to fw
775 * @wmi: wmi handle
776 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
777 *
778 * Return: 0 for success or error code
779 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700780static
Leo Changeee40872016-09-28 13:43:36 -0700781QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
782 struct rx_reorder_queue_setup_params *param)
783{
784 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
785 wmi_buf_t buf;
786 int32_t len = sizeof(*cmd);
787
788 buf = wmi_buf_alloc(wmi, len);
789 if (!buf) {
790 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
791 return QDF_STATUS_E_NOMEM;
792 }
793 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
794 WMITLV_SET_HDR(&cmd->tlv_header,
795 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
796 WMITLV_GET_STRUCT_TLVLEN
797 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
798 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
799 cmd->vdev_id = param->vdev_id;
800 cmd->tid = param->tid;
801 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
802 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
803 cmd->queue_no = param->queue_no;
804
805 if (wmi_unified_cmd_send(wmi, buf, len,
806 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
807 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
808 __func__);
809 qdf_nbuf_free(buf);
810 return QDF_STATUS_E_FAILURE;
811 }
812 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
813 param->peer_macaddr, param->vdev_id, param->tid);
814
815 return QDF_STATUS_SUCCESS;
816}
817
818/**
819 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
820 * command to fw
821 * @wmi: wmi handle
822 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
823 *
824 * Return: 0 for success or error code
825 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700826static
Leo Changeee40872016-09-28 13:43:36 -0700827QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
828 struct rx_reorder_queue_remove_params *param)
829{
830 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
831 wmi_buf_t buf;
832 int32_t len = sizeof(*cmd);
833
834 buf = wmi_buf_alloc(wmi, len);
835 if (!buf) {
836 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
837 return QDF_STATUS_E_NOMEM;
838 }
839 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
840 wmi_buf_data(buf);
841 WMITLV_SET_HDR(&cmd->tlv_header,
842 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
843 WMITLV_GET_STRUCT_TLVLEN
844 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
845 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
846 cmd->vdev_id = param->vdev_id;
847 cmd->tid_mask = param->peer_tid_bitmap;
848
849 if (wmi_unified_cmd_send(wmi, buf, len,
850 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
851 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
852 __func__);
853 qdf_nbuf_free(buf);
854 return QDF_STATUS_E_FAILURE;
855 }
856 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
857 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
858
859 return QDF_STATUS_SUCCESS;
860}
861
862/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530863 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
864 * @wmi_handle: wmi handle
865 * @param: pointer holding peer details
866 *
867 * Return: 0 for success or error code
868 */
869static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
870 struct peer_add_wds_entry_params *param)
871{
872 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
873 wmi_buf_t buf;
874 int len = sizeof(*cmd);
875
876 buf = wmi_buf_alloc(wmi_handle, len);
877 if (!buf) {
878 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
879 return QDF_STATUS_E_FAILURE;
880 }
881 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
882 WMITLV_SET_HDR(&cmd->tlv_header,
883 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
884 WMITLV_GET_STRUCT_TLVLEN
885 (wmi_peer_add_wds_entry_cmd_fixed_param));
886 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
887 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
888 cmd->flags = param->flags;
889
890 return wmi_unified_cmd_send(wmi_handle, buf, len,
891 WMI_PEER_ADD_WDS_ENTRY_CMDID);
892}
893
894/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530895 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530896 * @wmi_handle: wmi handle
897 * @param: pointer holding peer details
898 *
899 * Return: 0 for success or error code
900 */
901static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
902 struct peer_del_wds_entry_params *param)
903{
904 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
905 wmi_buf_t buf;
906 int len = sizeof(*cmd);
907
908 buf = wmi_buf_alloc(wmi_handle, len);
909 if (!buf) {
910 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
911 return QDF_STATUS_E_NOMEM;
912 }
913 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
914 WMITLV_SET_HDR(&cmd->tlv_header,
915 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
916 WMITLV_GET_STRUCT_TLVLEN
917 (wmi_peer_remove_wds_entry_cmd_fixed_param));
918 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
919 return wmi_unified_cmd_send(wmi_handle, buf, len,
920 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
921}
922
923/**
924 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
925 * @wmi_handle: wmi handle
926 * @param: pointer holding peer details
927 *
928 * Return: 0 for success or error code
929 */
930static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
931 struct peer_update_wds_entry_params *param)
932{
933 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
934 wmi_buf_t buf;
935 int len = sizeof(*cmd);
936
937 buf = wmi_buf_alloc(wmi_handle, len);
938 if (!buf) {
939 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
940 return QDF_STATUS_E_NOMEM;
941 }
942
943 /* wmi_buf_alloc returns zeroed command buffer */
944 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
945 WMITLV_SET_HDR(&cmd->tlv_header,
946 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
947 WMITLV_GET_STRUCT_TLVLEN
948 (wmi_peer_update_wds_entry_cmd_fixed_param));
949 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
950 if (param->wds_macaddr)
951 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
952 &cmd->wds_macaddr);
953 if (param->peer_macaddr)
954 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
955 &cmd->peer_macaddr);
956 return wmi_unified_cmd_send(wmi_handle, buf, len,
957 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
958}
959
960
961
962/**
Govind Singh5eb51532016-03-09 11:34:12 +0530963 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
964 * @wmi_handle: wmi handle
965 * @value: value
966 * @mac_id: mac id to have radio context
967 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530968 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530969 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530970static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530971 uint32_t value, uint8_t mac_id)
972{
973 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
974 wmi_buf_t buf;
975 int32_t len = sizeof(*cmd);
976
Govind Singhb53420c2016-03-09 14:32:57 +0530977 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530978
979 buf = wmi_buf_alloc(wmi_handle, len);
980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530981 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530982 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530983 }
984
985 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
986 WMITLV_SET_HDR(&cmd->tlv_header,
987 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
988 WMITLV_GET_STRUCT_TLVLEN
989 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530990 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530991 cmd->enable = value;
992
993 if (wmi_unified_cmd_send(wmi_handle, buf, len,
994 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530995 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530996 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530997 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530998 }
999
1000 return 0;
1001}
1002
1003/**
1004 * send_pdev_utf_cmd_tlv() - send utf command to fw
1005 * @wmi_handle: wmi handle
1006 * @param: pointer to pdev_utf_params
1007 * @mac_id: mac id to have radio context
1008 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301009 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301010 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301011static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301012send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1013 struct pdev_utf_params *param,
1014 uint8_t mac_id)
1015{
1016 wmi_buf_t buf;
1017 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001018 /* if param->len is 0 no data is sent, return error */
1019 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301020 static uint8_t msgref = 1;
1021 uint8_t segNumber = 0, segInfo, numSegments;
1022 uint16_t chunk_len, total_bytes;
1023 uint8_t *bufpos;
1024 struct seg_hdr_info segHdrInfo;
1025
1026 bufpos = param->utf_payload;
1027 total_bytes = param->len;
1028 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1029 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1030 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1031
1032 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1033 numSegments++;
1034
1035 while (param->len) {
1036 if (param->len > MAX_WMI_UTF_LEN)
1037 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1038 else
1039 chunk_len = param->len;
1040
1041 buf = wmi_buf_alloc(wmi_handle,
1042 (chunk_len + sizeof(segHdrInfo) +
1043 WMI_TLV_HDR_SIZE));
1044 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301045 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301046 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301047 }
1048
1049 cmd = (uint8_t *) wmi_buf_data(buf);
1050
1051 segHdrInfo.len = total_bytes;
1052 segHdrInfo.msgref = msgref;
1053 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1054 segHdrInfo.segmentInfo = segInfo;
1055 segHdrInfo.pad = 0;
1056
Govind Singhb53420c2016-03-09 14:32:57 +05301057 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301058 " segHdrInfo.segmentInfo = %d",
1059 __func__, segHdrInfo.len, segHdrInfo.msgref,
1060 segHdrInfo.segmentInfo);
1061
Govind Singhb53420c2016-03-09 14:32:57 +05301062 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301063 "chunk len %d", __func__, total_bytes, segNumber,
1064 numSegments, chunk_len);
1065
1066 segNumber++;
1067
1068 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1069 (chunk_len + sizeof(segHdrInfo)));
1070 cmd += WMI_TLV_HDR_SIZE;
1071 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1072 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1073
1074 ret = wmi_unified_cmd_send(wmi_handle, buf,
1075 (chunk_len + sizeof(segHdrInfo) +
1076 WMI_TLV_HDR_SIZE),
1077 WMI_PDEV_UTF_CMDID);
1078
Govind Singh67922e82016-04-01 16:48:57 +05301079 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301081 wmi_buf_free(buf);
1082 break;
1083 }
1084
1085 param->len -= chunk_len;
1086 bufpos += chunk_len;
1087 }
1088
1089 msgref++;
1090
1091 return ret;
1092}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301093#ifdef CONFIG_MCL
1094static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1095 uint32_t host_param)
1096{
1097 return host_param;
1098}
1099#else
1100static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1101 uint32_t host_param)
1102{
1103 if (host_param < wmi_pdev_param_max)
1104 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301105
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301106 return WMI_UNAVAILABLE_PARAM;
1107}
1108#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301109/**
1110 * send_pdev_param_cmd_tlv() - set pdev parameters
1111 * @wmi_handle: wmi handle
1112 * @param: pointer to pdev parameter
1113 * @mac_id: radio context
1114 *
1115 * Return: 0 on success, errno on failure
1116 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301117static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301118send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1119 struct pdev_params *param,
1120 uint8_t mac_id)
1121{
Govind Singh67922e82016-04-01 16:48:57 +05301122 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301123 wmi_pdev_set_param_cmd_fixed_param *cmd;
1124 wmi_buf_t buf;
1125 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301126 uint32_t pdev_param;
1127
1128 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1129 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1130 WMI_LOGW("%s: Unavailable param %d\n",
1131 __func__, param->param_id);
1132 return QDF_STATUS_E_INVAL;
1133 }
Govind Singh5eb51532016-03-09 11:34:12 +05301134
1135 buf = wmi_buf_alloc(wmi_handle, len);
1136 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301137 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301138 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301139 }
1140 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1141 WMITLV_SET_HDR(&cmd->tlv_header,
1142 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1143 WMITLV_GET_STRUCT_TLVLEN
1144 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301145 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301146 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301147 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301148 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301149 param->param_value);
1150 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1151 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301152 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301153 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301154 wmi_buf_free(buf);
1155 }
1156 return ret;
1157}
1158
1159/**
1160 * send_suspend_cmd_tlv() - WMI suspend function
1161 * @param wmi_handle : handle to WMI.
1162 * @param param : pointer to hold suspend parameter
1163 * @mac_id: radio context
1164 *
1165 * Return 0 on success and -ve on failure.
1166 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301167static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301168 struct suspend_params *param,
1169 uint8_t mac_id)
1170{
1171 wmi_pdev_suspend_cmd_fixed_param *cmd;
1172 wmi_buf_t wmibuf;
1173 uint32_t len = sizeof(*cmd);
1174 int32_t ret;
1175
1176 /*
1177 * send the comand to Target to ignore the
1178 * PCIE reset so as to ensure that Host and target
1179 * states are in sync
1180 */
1181 wmibuf = wmi_buf_alloc(wmi_handle, len);
1182 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301183 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301184
1185 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1186 WMITLV_SET_HDR(&cmd->tlv_header,
1187 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1188 WMITLV_GET_STRUCT_TLVLEN
1189 (wmi_pdev_suspend_cmd_fixed_param));
1190 if (param->disable_target_intr)
1191 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1192 else
1193 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301194
1195 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1196
Govind Singh5eb51532016-03-09 11:34:12 +05301197 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1198 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301199 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301200 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301201 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301202 }
1203
1204 return ret;
1205}
1206
1207/**
1208 * send_resume_cmd_tlv() - WMI resume function
1209 * @param wmi_handle : handle to WMI.
1210 * @mac_id: radio context
1211 *
1212 * Return: 0 on success and -ve on failure.
1213 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301214static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301215 uint8_t mac_id)
1216{
1217 wmi_buf_t wmibuf;
1218 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301219 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301220
1221 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1222 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301223 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301224 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1225 WMITLV_SET_HDR(&cmd->tlv_header,
1226 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1227 WMITLV_GET_STRUCT_TLVLEN
1228 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301229 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301230 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1231 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301232 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301233 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301234 wmi_buf_free(wmibuf);
1235 }
1236
1237 return ret;
1238}
1239
1240/**
1241 * send_wow_enable_cmd_tlv() - WMI wow enable function
1242 * @param wmi_handle : handle to WMI.
1243 * @param param : pointer to hold wow enable parameter
1244 * @mac_id: radio context
1245 *
1246 * Return: 0 on success and -ve on failure.
1247 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301248static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301249 struct wow_cmd_params *param,
1250 uint8_t mac_id)
1251{
1252 wmi_wow_enable_cmd_fixed_param *cmd;
1253 wmi_buf_t buf;
1254 int32_t len;
1255 int32_t ret;
1256
1257 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1258
1259 buf = wmi_buf_alloc(wmi_handle, len);
1260 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301261 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1262 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301263 }
1264 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1265 WMITLV_SET_HDR(&cmd->tlv_header,
1266 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1267 WMITLV_GET_STRUCT_TLVLEN
1268 (wmi_wow_enable_cmd_fixed_param));
1269 cmd->enable = param->enable;
1270 if (param->can_suspend_link)
1271 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1272 else
1273 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001274 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301275
Govind Singhb53420c2016-03-09 14:32:57 +05301276 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301277 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1278 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1279
1280 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1281 WMI_WOW_ENABLE_CMDID);
1282 if (ret)
1283 wmi_buf_free(buf);
1284
1285 return ret;
1286}
1287
1288/**
1289 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301290 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301291 * @peer_addr: peer mac address
1292 * @param: pointer to ap_ps parameter structure
1293 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301294 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301295 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301296static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301297 uint8_t *peer_addr,
1298 struct ap_ps_params *param)
1299{
1300 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1301 wmi_buf_t buf;
1302 int32_t err;
1303
1304 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1305 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301306 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301307 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301308 }
1309 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1310 WMITLV_SET_HDR(&cmd->tlv_header,
1311 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1312 WMITLV_GET_STRUCT_TLVLEN
1313 (wmi_ap_ps_peer_cmd_fixed_param));
1314 cmd->vdev_id = param->vdev_id;
1315 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1316 cmd->param = param->param;
1317 cmd->value = param->value;
1318 err = wmi_unified_cmd_send(wmi_handle, buf,
1319 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1320 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301321 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301322 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301323 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301324 }
1325
1326 return 0;
1327}
1328
1329/**
1330 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301331 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301332 * @peer_addr: peer mac address
1333 * @param: pointer to sta_ps parameter structure
1334 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301335 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301336 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301337static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301338 struct sta_ps_params *param)
1339{
1340 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1341 wmi_buf_t buf;
1342 int32_t len = sizeof(*cmd);
1343
1344 buf = wmi_buf_alloc(wmi_handle, len);
1345 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301346 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301347 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301348 }
1349
1350 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1351 WMITLV_SET_HDR(&cmd->tlv_header,
1352 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1353 WMITLV_GET_STRUCT_TLVLEN
1354 (wmi_sta_powersave_param_cmd_fixed_param));
1355 cmd->vdev_id = param->vdev_id;
1356 cmd->param = param->param;
1357 cmd->value = param->value;
1358
1359 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1360 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301361 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301362 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301363 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301364 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301365 }
1366
1367 return 0;
1368}
1369
1370/**
1371 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301372 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301373 * @param: ponirt to crash inject paramter structure
1374 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301375 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301376 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301377static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301378 struct crash_inject *param)
1379{
1380 int32_t ret = 0;
1381 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1382 uint16_t len = sizeof(*cmd);
1383 wmi_buf_t buf;
1384
1385 buf = wmi_buf_alloc(wmi_handle, len);
1386 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301387 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301388 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301389 }
1390
1391 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1392 WMITLV_SET_HDR(&cmd->tlv_header,
1393 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1394 WMITLV_GET_STRUCT_TLVLEN
1395 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1396 cmd->type = param->type;
1397 cmd->delay_time_ms = param->delay_time_ms;
1398
1399 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1400 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301401 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301402 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301403 __func__, ret);
1404 wmi_buf_free(buf);
1405 }
1406
1407 return ret;
1408}
1409
1410/**
1411 * send_dbglog_cmd_tlv() - set debug log level
1412 * @param wmi_handle : handle to WMI.
1413 * @param param : pointer to hold dbglog level parameter
1414 *
1415 * Return: 0 on success and -ve on failure.
1416 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301417 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301418send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1419 struct dbglog_params *dbglog_param)
1420{
1421 wmi_buf_t buf;
1422 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001423 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301424 int32_t i;
1425 int32_t len;
1426 int8_t *buf_ptr;
1427 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1428
1429 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1430
1431 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1432 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1433 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1434 buf = wmi_buf_alloc(wmi_handle, len);
1435 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001436 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301437
1438 configmsg =
1439 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1440 buf_ptr = (int8_t *) configmsg;
1441 WMITLV_SET_HDR(&configmsg->tlv_header,
1442 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1443 WMITLV_GET_STRUCT_TLVLEN
1444 (wmi_debug_log_config_cmd_fixed_param));
1445 configmsg->dbg_log_param = dbglog_param->param;
1446 configmsg->value = dbglog_param->val;
1447 /* Filling in the data part of second tlv -- should
1448 * follow first tlv _ WMI_TLV_HDR_SIZE */
1449 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1450 sizeof
1451 (wmi_debug_log_config_cmd_fixed_param)
1452 + WMI_TLV_HDR_SIZE);
1453 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1454 WMITLV_TAG_ARRAY_UINT32,
1455 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1456 if (dbglog_param->module_id_bitmap) {
1457 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1458 module_id_bitmap_array[i] =
1459 dbglog_param->module_id_bitmap[i];
1460 }
1461 }
1462
1463 status = wmi_unified_cmd_send(wmi_handle, buf,
1464 len, WMI_DBGLOG_CFG_CMDID);
1465
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001466 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301467 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301468
1469 return status;
1470}
1471
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301472#ifdef CONFIG_MCL
1473static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1474 uint32_t host_param)
1475{
1476 return host_param;
1477}
1478#else
1479static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1480 uint32_t host_param)
1481{
1482 if (host_param < wmi_vdev_param_max)
1483 return wmi_handle->vdev_param[host_param];
1484
1485 return WMI_UNAVAILABLE_PARAM;
1486}
1487#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301488/**
1489 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1490 * @param wmi_handle : handle to WMI.
1491 * @param macaddr : MAC address
1492 * @param param : pointer to hold vdev set parameter
1493 *
1494 * Return: 0 on success and -ve on failure.
1495 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301496static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301497 struct vdev_set_params *param)
1498{
Govind Singh67922e82016-04-01 16:48:57 +05301499 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301500 wmi_vdev_set_param_cmd_fixed_param *cmd;
1501 wmi_buf_t buf;
1502 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301503 uint32_t vdev_param;
1504
1505 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1506 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1507 WMI_LOGW("%s:Vdev param %d not available", __func__,
1508 param->param_id);
1509 return QDF_STATUS_E_INVAL;
1510
1511 }
Govind Singh5eb51532016-03-09 11:34:12 +05301512
1513 buf = wmi_buf_alloc(wmi_handle, len);
1514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301515 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301516 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301517 }
1518 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1519 WMITLV_SET_HDR(&cmd->tlv_header,
1520 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1521 WMITLV_GET_STRUCT_TLVLEN
1522 (wmi_vdev_set_param_cmd_fixed_param));
1523 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301524 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301525 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301526 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301527 param->if_id, param->param_id, param->param_value);
1528 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1529 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301530 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301531 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301532 wmi_buf_free(buf);
1533 }
1534
1535 return ret;
1536}
1537
1538/**
1539 * send_stats_request_cmd_tlv() - WMI request stats function
1540 * @param wmi_handle : handle to WMI.
1541 * @param macaddr : MAC address
1542 * @param param : pointer to hold stats request parameter
1543 *
1544 * Return: 0 on success and -ve on failure.
1545 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301546static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301547 uint8_t macaddr[IEEE80211_ADDR_LEN],
1548 struct stats_request_params *param)
1549{
Govind Singhd3156eb2016-02-26 17:50:39 +05301550 int32_t ret;
1551 wmi_request_stats_cmd_fixed_param *cmd;
1552 wmi_buf_t buf;
1553 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1554
1555 buf = wmi_buf_alloc(wmi_handle, len);
1556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301557 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1558 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301559 }
1560
1561 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1562 WMITLV_SET_HDR(&cmd->tlv_header,
1563 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1564 WMITLV_GET_STRUCT_TLVLEN
1565 (wmi_request_stats_cmd_fixed_param));
1566 cmd->stats_id = param->stats_id;
1567 cmd->vdev_id = param->vdev_id;
1568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1569 WMI_REQUEST_STATS_CMDID);
1570 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301571 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301572 wmi_buf_free(buf);
1573 }
1574
1575 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301576}
1577
Govind Singh87542482016-06-08 19:40:11 +05301578#ifdef CONFIG_WIN
1579/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001580 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301581 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001582 * @param PKTLOG_EVENT : packet log event
1583 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301584 *
1585 * Return: 0 on success and -ve on failure.
1586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301587static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001588 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301589{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001590 int32_t ret;
1591 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1592 wmi_buf_t buf;
1593 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1594
1595 buf = wmi_buf_alloc(wmi_handle, len);
1596 if (!buf) {
1597 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1598 return -QDF_STATUS_E_NOMEM;
1599 }
1600
1601 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1602 WMITLV_SET_HDR(&cmd->tlv_header,
1603 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1604 WMITLV_GET_STRUCT_TLVLEN
1605 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1606 cmd->evlist = PKTLOG_EVENT;
1607 cmd->pdev_id = mac_id;
1608 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1609 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1610 if (ret) {
1611 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1612 wmi_buf_free(buf);
1613 }
1614
1615 return ret;
1616}
1617
1618/**
1619 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1620 * @param wmi_handle : handle to WMI.
1621 * @mac_id: mac id to have radio context
1622 *
1623 * Return: 0 on success and -ve on failure.
1624 */
1625static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001626 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001627{
1628 int32_t ret;
1629 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1630 wmi_buf_t buf;
1631 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1632
1633 buf = wmi_buf_alloc(wmi_handle, len);
1634 if (!buf) {
1635 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1636 return -QDF_STATUS_E_NOMEM;
1637 }
1638
1639 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1640 WMITLV_SET_HDR(&cmd->tlv_header,
1641 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1642 WMITLV_GET_STRUCT_TLVLEN
1643 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1644 cmd->pdev_id = mac_id;
1645 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1646 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1647 if (ret) {
1648 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1649 wmi_buf_free(buf);
1650 }
1651
1652 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301653}
1654#else
Govind Singh5eb51532016-03-09 11:34:12 +05301655/**
Keyur Parekhde522342017-08-18 14:01:05 -07001656 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1657 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301658 * @param wmi_handle : handle to WMI.
1659 * @param macaddr : MAC address
1660 * @param param : pointer to hold stats request parameter
1661 *
1662 * Return: 0 on success and -ve on failure.
1663 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301664static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301665 uint8_t macaddr[IEEE80211_ADDR_LEN],
1666 struct packet_enable_params *param)
1667{
1668 return 0;
1669}
Keyur Parekhde522342017-08-18 14:01:05 -07001670/**
1671 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1672 * packet-log
1673 * @param wmi_handle : handle to WMI.
1674 * @mac_id: mac id to have radio context
1675 *
1676 * Return: 0 on success and -ve on failure.
1677 */
1678static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1679 uint8_t mac_id)
1680{
1681 return 0;
1682}
Govind Singh87542482016-06-08 19:40:11 +05301683#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301684
Sathish Kumarfd347372017-02-13 12:29:09 +05301685static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301686 struct beacon_params *param)
1687{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301688 QDF_STATUS ret;
1689 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1690 wmi_buf_t wmi_buf;
1691 qdf_dma_addr_t dma_addr;
1692 uint32_t dtim_flag = 0;
1693
1694 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1695 if (!wmi_buf) {
1696 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1697 return QDF_STATUS_E_NOMEM;
1698 }
1699 if (param->is_dtim_count_zero) {
1700 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1701 if (param->is_bitctl_reqd) {
1702 /* deliver CAB traffic in next DTIM beacon */
1703 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1704 }
1705 }
1706 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1707 WMITLV_SET_HDR(&cmd->tlv_header,
1708 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1709 WMITLV_GET_STRUCT_TLVLEN
1710 (wmi_bcn_send_from_host_cmd_fixed_param));
1711 cmd->vdev_id = param->vdev_id;
1712 cmd->data_len = qdf_nbuf_len(param->wbuf);
1713 cmd->frame_ctrl = param->frame_ctrl;
1714 cmd->dtim_flag = dtim_flag;
1715 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1716 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1717#if defined(HTT_PADDR64)
1718 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1719#endif
1720 cmd->bcn_antenna = param->bcn_txant;
1721
1722 ret = wmi_unified_cmd_send(wmi_handle,
1723 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1724 if (ret != QDF_STATUS_SUCCESS) {
1725 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1726 wmi_buf_free(wmi_buf);
1727 }
1728
1729 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301730}
1731
1732/**
1733 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1734 * @param wmi_handle : handle to WMI.
1735 * @param param : pointer to hold beacon send cmd parameter
1736 *
1737 * Return: 0 on success and -ve on failure.
1738 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301739static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301740 struct beacon_tmpl_params *param)
1741{
1742 int32_t ret;
1743 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1744 wmi_bcn_prb_info *bcn_prb_info;
1745 wmi_buf_t wmi_buf;
1746 uint8_t *buf_ptr;
1747 uint32_t wmi_buf_len;
1748
Sathish Kumar45e991b2017-02-27 10:35:40 +05301749 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301750 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1751 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1752 param->tmpl_len_aligned;
1753 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1754 if (!wmi_buf) {
1755 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1756 return QDF_STATUS_E_NOMEM;
1757 }
1758 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1759 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1760 WMITLV_SET_HDR(&cmd->tlv_header,
1761 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1762 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1763 cmd->vdev_id = param->vdev_id;
1764 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301765 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1766 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301767 cmd->buf_len = param->tmpl_len;
1768 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1769
1770 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1771 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1772 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1773 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1774 bcn_prb_info->caps = 0;
1775 bcn_prb_info->erp = 0;
1776 buf_ptr += sizeof(wmi_bcn_prb_info);
1777
1778 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1779 buf_ptr += WMI_TLV_HDR_SIZE;
1780 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1781
1782 ret = wmi_unified_cmd_send(wmi_handle,
1783 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1784 if (ret) {
1785 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1786 wmi_buf_free(wmi_buf);
1787 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301788
Govind Singh87542482016-06-08 19:40:11 +05301789 return 0;
1790}
Govind Singh5eb51532016-03-09 11:34:12 +05301791
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301792#ifdef CONFIG_MCL
1793static inline void copy_peer_flags_tlv(
1794 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1795 struct peer_assoc_params *param)
1796{
1797 cmd->peer_flags = param->peer_flags;
1798}
1799#else
1800static inline void copy_peer_flags_tlv(
1801 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1802 struct peer_assoc_params *param)
1803{
1804 /*
1805 * The target only needs a subset of the flags maintained in the host.
1806 * Just populate those flags and send it down
1807 */
1808 cmd->peer_flags = 0;
1809
1810 /*
1811 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1812 */
1813 if (param->is_wme_set) {
1814
1815 if (param->qos_flag)
1816 cmd->peer_flags |= WMI_PEER_QOS;
1817 if (param->apsd_flag)
1818 cmd->peer_flags |= WMI_PEER_APSD;
1819 if (param->ht_flag)
1820 cmd->peer_flags |= WMI_PEER_HT;
1821 if (param->bw_40)
1822 cmd->peer_flags |= WMI_PEER_40MHZ;
1823 if (param->bw_80)
1824 cmd->peer_flags |= WMI_PEER_80MHZ;
1825 if (param->bw_160)
1826 cmd->peer_flags |= WMI_PEER_160MHZ;
1827
1828 /* Typically if STBC is enabled for VHT it should be enabled
1829 * for HT as well
1830 **/
1831 if (param->stbc_flag)
1832 cmd->peer_flags |= WMI_PEER_STBC;
1833
1834 /* Typically if LDPC is enabled for VHT it should be enabled
1835 * for HT as well
1836 **/
1837 if (param->ldpc_flag)
1838 cmd->peer_flags |= WMI_PEER_LDPC;
1839
1840 if (param->static_mimops_flag)
1841 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1842 if (param->dynamic_mimops_flag)
1843 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1844 if (param->spatial_mux_flag)
1845 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1846 if (param->vht_flag)
1847 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001848 if (param->he_flag)
1849 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301850 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001851
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301852 if (param->is_pmf_enabled)
1853 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301854 /*
1855 * Suppress authorization for all AUTH modes that need 4-way handshake
1856 * (during re-association).
1857 * Authorization will be done for these modes on key installation.
1858 */
1859 if (param->auth_flag)
1860 cmd->peer_flags |= WMI_PEER_AUTH;
1861 if (param->need_ptk_4_way)
1862 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1863 else
1864 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1865 if (param->need_gtk_2_way)
1866 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1867 /* safe mode bypass the 4-way handshake */
1868 if (param->safe_mode_enabled)
1869 cmd->peer_flags &=
1870 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1871 /* Disable AMSDU for station transmit, if user configures it */
1872 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1873 * it
1874 * if (param->amsdu_disable) Add after FW support
1875 **/
1876
1877 /* Target asserts if node is marked HT and all MCS is set to 0.
1878 * Mark the node as non-HT if all the mcs rates are disabled through
1879 * iwpriv
1880 **/
1881 if (param->peer_ht_rates.num_rates == 0)
1882 cmd->peer_flags &= ~WMI_PEER_HT;
1883}
1884#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301885
1886#ifdef CONFIG_MCL
1887static inline void copy_peer_mac_addr_tlv(
1888 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1889 struct peer_assoc_params *param)
1890{
1891 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1892 sizeof(param->peer_macaddr));
1893}
1894#else
1895static inline void copy_peer_mac_addr_tlv(
1896 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1897 struct peer_assoc_params *param)
1898{
1899 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1900}
1901#endif
1902
Govind Singh5eb51532016-03-09 11:34:12 +05301903/**
1904 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1905 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301906 * @param param : pointer to peer assoc parameter
1907 *
1908 * Return: 0 on success and -ve on failure.
1909 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301910static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301911 struct peer_assoc_params *param)
1912{
Govind Singhd3156eb2016-02-26 17:50:39 +05301913 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1914 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001915 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301916 wmi_buf_t buf;
1917 int32_t len;
1918 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301919 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301920 uint32_t peer_legacy_rates_align;
1921 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001922 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301923
1924
1925 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1926 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301927
1928 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001929 (peer_legacy_rates_align * sizeof(uint8_t)) +
1930 WMI_TLV_HDR_SIZE +
1931 (peer_ht_rates_align * sizeof(uint8_t)) +
1932 sizeof(wmi_vht_rate_set) +
1933 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1934 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301935
1936 buf = wmi_buf_alloc(wmi_handle, len);
1937 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301938 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301939 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301940 }
1941
1942 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1943 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1944 WMITLV_SET_HDR(&cmd->tlv_header,
1945 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1946 WMITLV_GET_STRUCT_TLVLEN
1947 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301948
Govind Singhd3156eb2016-02-26 17:50:39 +05301949 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301950
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 cmd->peer_new_assoc = param->peer_new_assoc;
1952 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301953
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301954 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301955 copy_peer_mac_addr_tlv(cmd, param);
1956
Govind Singhd3156eb2016-02-26 17:50:39 +05301957 cmd->peer_rate_caps = param->peer_rate_caps;
1958 cmd->peer_caps = param->peer_caps;
1959 cmd->peer_listen_intval = param->peer_listen_intval;
1960 cmd->peer_ht_caps = param->peer_ht_caps;
1961 cmd->peer_max_mpdu = param->peer_max_mpdu;
1962 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301963 cmd->peer_vht_caps = param->peer_vht_caps;
1964 cmd->peer_phymode = param->peer_phymode;
1965
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001966 /* Update 11ax capabilities */
1967 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1968 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001969 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1970 sizeof(param->peer_he_cap_phyinfo));
1971 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1972 sizeof(param->peer_ppet));
1973
Govind Singhd3156eb2016-02-26 17:50:39 +05301974 /* Update peer legacy rate information */
1975 buf_ptr += sizeof(*cmd);
1976 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301977 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301978 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301979 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301980 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301981 param->peer_legacy_rates.num_rates);
1982
1983 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001984 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301985 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301986 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301988 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301989 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301990 param->peer_ht_rates.num_rates);
1991
1992 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001993 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301994 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1995 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1996
1997 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301998
1999 /* Update bandwidth-NSS mapping */
2000 cmd->peer_bw_rxnss_override = 0;
2001 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2002
Govind Singhd3156eb2016-02-26 17:50:39 +05302003 mcs = (wmi_vht_rate_set *) buf_ptr;
2004 if (param->vht_capable) {
2005 mcs->rx_max_rate = param->rx_max_rate;
2006 mcs->rx_mcs_set = param->rx_mcs_set;
2007 mcs->tx_max_rate = param->tx_max_rate;
2008 mcs->tx_mcs_set = param->tx_mcs_set;
2009 }
2010
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002011 /* HE Rates */
2012 cmd->peer_he_mcs = param->peer_he_mcs_count;
2013 buf_ptr += sizeof(wmi_vht_rate_set);
2014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2015 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2016 buf_ptr += WMI_TLV_HDR_SIZE;
2017
2018 /* Loop through the HE rate set */
2019 for (i = 0; i < param->peer_he_mcs_count; i++) {
2020 he_mcs = (wmi_he_rate_set *) buf_ptr;
2021 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2022 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2023
2024 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2025 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2026 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2027 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2028 buf_ptr += sizeof(wmi_he_rate_set);
2029 }
2030
2031
Govind Singhb53420c2016-03-09 14:32:57 +05302032 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302033 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2034 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002035 "cmd->peer_vht_caps %x "
2036 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302037 "HE phy %x %x %x "
2038 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302039 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2040 cmd->peer_rate_caps, cmd->peer_caps,
2041 cmd->peer_listen_intval, cmd->peer_ht_caps,
2042 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2043 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002044 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2045 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302046 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2047 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302048
2049 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2050 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302051 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302052 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302053 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302054 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302055 }
2056
2057 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302058}
2059
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302060/* copy_scan_notify_events() - Helper routine to copy scan notify events
2061 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302062static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302063 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302064 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302065{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302066
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302067 /* Scan events subscription */
2068 if (param->scan_ev_started)
2069 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2070 if (param->scan_ev_completed)
2071 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2072 if (param->scan_ev_bss_chan)
2073 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2074 if (param->scan_ev_foreign_chan)
2075 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2076 if (param->scan_ev_dequeued)
2077 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2078 if (param->scan_ev_preempted)
2079 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2080 if (param->scan_ev_start_failed)
2081 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2082 if (param->scan_ev_restarted)
2083 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2084 if (param->scan_ev_foreign_chn_exit)
2085 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2086 if (param->scan_ev_suspended)
2087 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2088 if (param->scan_ev_resumed)
2089 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302090
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302091 /** Set scan control flags */
2092 cmd->scan_ctrl_flags = 0;
2093 if (param->scan_f_passive)
2094 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2095 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302096 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302097 if (param->scan_f_promisc_mode)
2098 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2099 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302100 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302101 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302102 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302103 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302104 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302105 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302106 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302107 if (param->scan_f_ofdm_rates)
2108 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2109 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302110 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302111 if (param->scan_f_filter_prb_req)
2112 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2113 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302114 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302115 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302116 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302117 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302118 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302119 if (param->scan_f_force_active_dfs_chn)
2120 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2121 if (param->scan_f_add_tpc_ie_in_probe)
2122 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2123 if (param->scan_f_add_ds_ie_in_probe)
2124 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2125 if (param->scan_f_add_spoofed_mac_in_probe)
2126 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2127 if (param->scan_f_add_rand_seq_in_probe)
2128 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2129 if (param->scan_f_en_ie_whitelist_in_probe)
2130 cmd->scan_ctrl_flags |=
2131 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302132
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302133 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2134 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2135 param->adaptive_dwell_time_mode);
2136}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302137
2138/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302139static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302140 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302141{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302142 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302143}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302144
Anish Natarajdd855152017-03-20 12:49:08 +05302145/*
2146 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2147 * @param wmi_handle : Handle to WMI
2148 * @param vdev_id : vdev identifier
2149 *
2150 * Return : void *
2151 */
2152static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2153{
2154 struct wlan_objmgr_vdev *vdev = NULL;
2155 struct wlan_objmgr_pdev *pdev = NULL;
2156 uint8_t pdev_id = 0;
2157
2158 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2159 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2160 vdev_id, WLAN_SCAN_ID);
2161 if (vdev) {
2162 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2163 pdev = wlan_vdev_get_pdev(vdev);
2164 if (pdev)
2165 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2166 else {
2167 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2168 }
2169 } else {
2170 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2171 }
2172
2173 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2174}
2175
Govind Singh5eb51532016-03-09 11:34:12 +05302176/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302177 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2178 * @mac: random mac addr
2179 * @mask: random mac mask
2180 * @mac_addr: wmi random mac
2181 * @mac_mask: wmi random mac mask
2182 *
2183 * Return None.
2184 */
2185static inline
2186void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2187 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2188{
2189 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2190 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2191}
2192
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302193/*
2194 * wmi_fill_vendor_oui() - fill vendor OUIs
2195 * @buf_ptr: pointer to wmi tlv buffer
2196 * @num_vendor_oui: number of vendor OUIs to be filled
2197 * @param_voui: pointer to OUI buffer
2198 *
2199 * This function populates the wmi tlv buffer when vendor specific OUIs are
2200 * present.
2201 *
2202 * Return: None
2203 */
2204static inline
2205void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2206 uint32_t *pvoui)
2207{
2208 wmi_vendor_oui *voui = NULL;
2209 uint32_t i;
2210
2211 voui = (wmi_vendor_oui *)buf_ptr;
2212
2213 for (i = 0; i < num_vendor_oui; i++) {
2214 WMITLV_SET_HDR(&voui[i].tlv_header,
2215 WMITLV_TAG_STRUC_wmi_vendor_oui,
2216 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2217 voui[i].oui_type_subtype = pvoui[i];
2218 }
2219}
2220
2221/*
2222 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2223 * @ie_bitmap: output pointer to ie bit map in cmd
2224 * @num_vendor_oui: output pointer to num vendor OUIs
2225 * @ie_whitelist: input parameter
2226 *
2227 * This function populates the IE whitelist attrs of scan, pno and
2228 * scan oui commands for ie_whitelist parameter.
2229 *
2230 * Return: None
2231 */
2232static inline
2233void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2234 uint32_t *num_vendor_oui,
2235 struct probe_req_whitelist_attr *ie_whitelist)
2236{
2237 uint32_t i = 0;
2238
2239 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2240 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2241
2242 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2243}
2244
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302245/**
Govind Singh5eb51532016-03-09 11:34:12 +05302246 * send_scan_start_cmd_tlv() - WMI scan start function
2247 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302248 * @param param : pointer to hold scan start cmd parameter
2249 *
2250 * Return: 0 on success and -ve on failure.
2251 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302252static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302253 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302254{
Govind Singhd3156eb2016-02-26 17:50:39 +05302255 int32_t ret = 0;
2256 int32_t i;
2257 wmi_buf_t wmi_buf;
2258 wmi_start_scan_cmd_fixed_param *cmd;
2259 uint8_t *buf_ptr;
2260 uint32_t *tmp_ptr;
2261 wmi_ssid *ssid = NULL;
2262 wmi_mac_addr *bssid;
2263 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302264 uint8_t extraie_len_with_pad = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302265 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302266
2267 /* Length TLV placeholder for array of uint32_t */
2268 len += WMI_TLV_HDR_SIZE;
2269 /* calculate the length of buffer required */
2270 if (params->num_chan)
2271 len += params->num_chan * sizeof(uint32_t);
2272
2273 /* Length TLV placeholder for array of wmi_ssid structures */
2274 len += WMI_TLV_HDR_SIZE;
2275 if (params->num_ssids)
2276 len += params->num_ssids * sizeof(wmi_ssid);
2277
2278 /* Length TLV placeholder for array of wmi_mac_addr structures */
2279 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302280 if (params->num_bssid)
2281 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302282
2283 /* Length TLV placeholder for array of bytes */
2284 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302285 if (params->extraie.len)
2286 extraie_len_with_pad =
2287 roundup(params->extraie.len, sizeof(uint32_t));
2288 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302289
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302290 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2291 if (ie_whitelist->num_vendor_oui)
2292 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2293
Govind Singhd3156eb2016-02-26 17:50:39 +05302294 /* Allocate the memory */
2295 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2296 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302297 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302298 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302299 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302300 }
2301 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2302 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2303 WMITLV_SET_HDR(&cmd->tlv_header,
2304 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2305 WMITLV_GET_STRUCT_TLVLEN
2306 (wmi_start_scan_cmd_fixed_param));
2307
2308 cmd->scan_id = params->scan_id;
2309 cmd->scan_req_id = params->scan_req_id;
2310 cmd->vdev_id = params->vdev_id;
2311 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302312
2313 copy_scan_event_cntrl_flags(cmd, params);
2314
Govind Singhd3156eb2016-02-26 17:50:39 +05302315 cmd->dwell_time_active = params->dwell_time_active;
2316 cmd->dwell_time_passive = params->dwell_time_passive;
2317 cmd->min_rest_time = params->min_rest_time;
2318 cmd->max_rest_time = params->max_rest_time;
2319 cmd->repeat_probe_time = params->repeat_probe_time;
2320 cmd->probe_spacing_time = params->probe_spacing_time;
2321 cmd->idle_time = params->idle_time;
2322 cmd->max_scan_time = params->max_scan_time;
2323 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302324 cmd->burst_duration = params->burst_duration;
2325 cmd->num_chan = params->num_chan;
2326 cmd->num_bssid = params->num_bssid;
2327 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302328 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302329 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302330 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2331
2332 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2333
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302334 if (params->scan_random.randomize)
2335 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2336 params->scan_random.mac_mask,
2337 &cmd->mac_addr,
2338 &cmd->mac_mask);
2339
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302340 if (ie_whitelist->white_list)
2341 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2342 &cmd->num_vendor_oui,
2343 ie_whitelist);
2344
Govind Singhd3156eb2016-02-26 17:50:39 +05302345 buf_ptr += sizeof(*cmd);
2346 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2347 for (i = 0; i < params->num_chan; ++i)
2348 tmp_ptr[i] = params->chan_list[i];
2349
2350 WMITLV_SET_HDR(buf_ptr,
2351 WMITLV_TAG_ARRAY_UINT32,
2352 (params->num_chan * sizeof(uint32_t)));
2353 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302354 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302355 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302356 goto error;
2357 }
2358
2359 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2360 (params->num_ssids * sizeof(wmi_ssid)));
2361
2362 if (params->num_ssids) {
2363 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2364 for (i = 0; i < params->num_ssids; ++i) {
2365 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302366 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302367 params->ssid[i].length);
2368 ssid++;
2369 }
2370 }
2371 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2372
2373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2374 (params->num_bssid * sizeof(wmi_mac_addr)));
2375 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302376
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302377 if (params->num_bssid) {
2378 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302379 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2380 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302381 bssid++;
2382 }
2383 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302384
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302385 buf_ptr += WMI_TLV_HDR_SIZE +
2386 (params->num_bssid * sizeof(wmi_mac_addr));
2387
2388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2389 if (params->extraie.len)
2390 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2391 params);
2392
2393 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302394
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302395 /* probe req ie whitelisting */
2396 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2397 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2398
2399 buf_ptr += WMI_TLV_HDR_SIZE;
2400
2401 if (cmd->num_vendor_oui) {
2402 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2403 ie_whitelist->voui);
2404 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2405 }
2406
Anish Natarajdd855152017-03-20 12:49:08 +05302407 ret = wmi_unified_cmd_send(
2408 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302409 len, WMI_START_SCAN_CMDID);
2410 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302411 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302412 wmi_buf_free(wmi_buf);
2413 }
2414 return ret;
2415error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302416 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302417 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302418}
2419
2420/**
2421 * send_scan_stop_cmd_tlv() - WMI scan start function
2422 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302423 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302424 *
2425 * Return: 0 on success and -ve on failure.
2426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302427static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302428 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302429{
Govind Singhd3156eb2016-02-26 17:50:39 +05302430 wmi_stop_scan_cmd_fixed_param *cmd;
2431 int ret;
2432 int len = sizeof(*cmd);
2433 wmi_buf_t wmi_buf;
2434
2435 /* Allocate the memory */
2436 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2437 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302438 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302439 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302440 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302441 goto error;
2442 }
2443
2444 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2445 WMITLV_SET_HDR(&cmd->tlv_header,
2446 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2447 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2448 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302449 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302450 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302451 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2452 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302453 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302454 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2455 /* Cancelling all scans */
2456 cmd->req_type = WMI_SCAN_STOP_ALL;
2457 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2458 /* Cancelling VAP scans */
2459 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2460 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2461 /* Cancelling specific scan */
2462 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302463 } else {
2464 WMI_LOGE("%s: Invalid Command : ", __func__);
2465 wmi_buf_free(wmi_buf);
2466 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302467 }
2468
Anish Natarajdd855152017-03-20 12:49:08 +05302469 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302470 len, WMI_STOP_SCAN_CMDID);
2471 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302472 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302473 wmi_buf_free(wmi_buf);
2474 }
2475
2476error:
2477 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302478}
2479
Govind Singh87542482016-06-08 19:40:11 +05302480#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302481/**
2482 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2483 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302484 * @param param : pointer to hold scan channel list parameter
2485 *
2486 * Return: 0 on success and -ve on failure.
2487 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302488static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302489 struct scan_chan_list_params *chan_list)
2490{
2491 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302492 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302493 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302494 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302495 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302496 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302497 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2498
2499 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2500 buf = wmi_buf_alloc(wmi_handle, len);
2501 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302502 WMI_LOGE("Failed to allocate memory");
2503 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302504 goto end;
2505 }
2506
2507 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2508 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2509 WMITLV_SET_HDR(&cmd->tlv_header,
2510 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2511 WMITLV_GET_STRUCT_TLVLEN
2512 (wmi_scan_chan_list_cmd_fixed_param));
2513
Govind Singhb53420c2016-03-09 14:32:57 +05302514 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302515
2516 cmd->num_scan_chans = chan_list->num_scan_chans;
2517 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2518 WMITLV_TAG_ARRAY_STRUC,
2519 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302520 chan_info = (wmi_channel_param *)
2521 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302522 tchan_info = chan_list->chan_info;
2523
2524 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2525 WMITLV_SET_HDR(&chan_info->tlv_header,
2526 WMITLV_TAG_STRUC_wmi_channel,
2527 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2528 chan_info->mhz = tchan_info->mhz;
2529 chan_info->band_center_freq1 =
2530 tchan_info->band_center_freq1;
2531 chan_info->band_center_freq2 =
2532 tchan_info->band_center_freq2;
2533 chan_info->info = tchan_info->info;
2534 chan_info->reg_info_1 = tchan_info->reg_info_1;
2535 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302536 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302537
2538 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2539 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2540 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2541 tchan_info++;
2542 chan_info++;
2543 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302544 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2545 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302546
Anish Natarajdd855152017-03-20 12:49:08 +05302547 qdf_status = wmi_unified_cmd_send(wmi_handle,
2548 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302549
Govind Singh67922e82016-04-01 16:48:57 +05302550 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302551 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302552 wmi_buf_free(buf);
2553 }
Govind Singh67922e82016-04-01 16:48:57 +05302554
Govind Singhd3156eb2016-02-26 17:50:39 +05302555end:
Govind Singhb53420c2016-03-09 14:32:57 +05302556 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302557}
Govind Singh87542482016-06-08 19:40:11 +05302558#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302559static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302560 struct scan_chan_list_params *chan_list)
2561{
2562 wmi_buf_t buf;
2563 QDF_STATUS qdf_status;
2564 wmi_scan_chan_list_cmd_fixed_param *cmd;
2565 int i;
2566 uint8_t *buf_ptr;
2567 wmi_channel *chan_info;
2568 struct channel_param *tchan_info;
2569 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302570
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302571 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302572 buf = wmi_buf_alloc(wmi_handle, len);
2573 if (!buf) {
2574 WMI_LOGE("Failed to allocate memory");
2575 qdf_status = QDF_STATUS_E_NOMEM;
2576 goto end;
2577 }
2578
2579 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2580 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2581 WMITLV_SET_HDR(&cmd->tlv_header,
2582 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2583 WMITLV_GET_STRUCT_TLVLEN
2584 (wmi_scan_chan_list_cmd_fixed_param));
2585
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302586 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302587
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302588 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2589 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302590 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302591 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2592 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302593 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302594 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2595 tchan_info = &(chan_list->ch_param[0]);
2596
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302597 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302598 WMITLV_SET_HDR(&chan_info->tlv_header,
2599 WMITLV_TAG_STRUC_wmi_channel,
2600 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2601 chan_info->mhz = tchan_info->mhz;
2602 chan_info->band_center_freq1 =
2603 tchan_info->cfreq1;
2604 chan_info->band_center_freq2 =
2605 tchan_info->cfreq2;
2606
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302607 if (tchan_info->is_chan_passive)
2608 WMI_SET_CHANNEL_FLAG(chan_info,
2609 WMI_CHAN_FLAG_PASSIVE);
2610
2611 if (tchan_info->allow_vht)
2612 WMI_SET_CHANNEL_FLAG(chan_info,
2613 WMI_CHAN_FLAG_ALLOW_VHT);
2614 else if (tchan_info->allow_ht)
2615 WMI_SET_CHANNEL_FLAG(chan_info,
2616 WMI_CHAN_FLAG_ALLOW_HT);
2617 WMI_SET_CHANNEL_MODE(chan_info,
2618 tchan_info->phy_mode);
2619
2620 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2621 * after FW support
2622 */
2623
2624 /* also fill in power information */
2625 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2626 tchan_info->minpower);
2627 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2628 tchan_info->maxpower);
2629 WMI_SET_CHANNEL_REG_POWER(chan_info,
2630 tchan_info->maxregpower);
2631 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2632 tchan_info->antennamax);
2633 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2634 tchan_info->reg_class_id);
2635
Govind Singh87542482016-06-08 19:40:11 +05302636 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2637
Govind Singh87542482016-06-08 19:40:11 +05302638 tchan_info++;
2639 chan_info++;
2640 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302641 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2642 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302643
Anish Natarajdd855152017-03-20 12:49:08 +05302644 qdf_status = wmi_unified_cmd_send(
2645 wmi_handle,
2646 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302647
2648 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2649 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2650 wmi_buf_free(buf);
2651 }
2652
2653end:
2654 return qdf_status;
2655}
2656#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302657
2658/**
2659 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2660 *
2661 * @bufp: Pointer to buffer
2662 * @param: Pointer to tx param
2663 *
2664 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2665 */
2666static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2667 struct tx_send_params param)
2668{
2669 wmi_tx_send_params *tx_param;
2670 QDF_STATUS status = QDF_STATUS_SUCCESS;
2671
2672 if (!bufp) {
2673 status = QDF_STATUS_E_FAILURE;
2674 return status;
2675 }
2676 tx_param = (wmi_tx_send_params *)bufp;
2677 WMITLV_SET_HDR(&tx_param->tlv_header,
2678 WMITLV_TAG_STRUC_wmi_tx_send_params,
2679 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2680 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2681 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2682 param.mcs_mask);
2683 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2684 param.nss_mask);
2685 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2686 param.retry_limit);
2687 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2688 param.chain_mask);
2689 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2690 param.bw_mask);
2691 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2692 param.preamble_type);
2693 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2694 param.frame_type);
2695
2696 return status;
2697}
2698
Govind Singhd3156eb2016-02-26 17:50:39 +05302699/**
2700 * send_mgmt_cmd_tlv() - WMI scan start function
2701 * @wmi_handle : handle to WMI.
2702 * @param : pointer to hold mgmt cmd parameter
2703 *
2704 * Return: 0 on success and -ve on failure.
2705 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302706static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302707 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302708{
Govind Singh427ee5a2016-02-26 18:09:36 +05302709 wmi_buf_t buf;
2710 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2711 int32_t cmd_len;
2712 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302713 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302714 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302715 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302716 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2717 mgmt_tx_dl_frm_len;
2718
2719 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302720 WMI_TLV_HDR_SIZE +
2721 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302722
Sathish Kumar5b636932017-06-28 14:40:32 +05302723 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2726 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302727 }
2728
2729 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2730 bufp = (uint8_t *) cmd;
2731 WMITLV_SET_HDR(&cmd->tlv_header,
2732 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2733 WMITLV_GET_STRUCT_TLVLEN
2734 (wmi_mgmt_tx_send_cmd_fixed_param));
2735
2736 cmd->vdev_id = param->vdev_id;
2737
Govind Singh224a7312016-06-21 14:33:26 +05302738 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302739 cmd->chanfreq = param->chanfreq;
2740 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2741 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2742 sizeof(uint32_t)));
2743 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302744 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302745
2746 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2747 QDF_DMA_TO_DEVICE);
2748 if (status != QDF_STATUS_SUCCESS) {
2749 WMI_LOGE("%s: wmi buf map failed", __func__);
2750 goto err1;
2751 }
2752
Govind Singhb53420c2016-03-09 14:32:57 +05302753 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302754 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002755#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302756 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2757#endif
2758 cmd->frame_len = param->frm_len;
2759 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302760 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002762 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002763 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002764
Sathish Kumar5b636932017-06-28 14:40:32 +05302765 bufp += roundup(bufp_len, sizeof(uint32_t));
2766 if (param->tx_params_valid) {
2767 status = populate_tx_send_params(bufp, param->tx_param);
2768 if (status != QDF_STATUS_SUCCESS) {
2769 WMI_LOGE("%s: Populate TX send params failed",
2770 __func__);
2771 goto err1;
2772 }
2773 cmd_len += sizeof(wmi_tx_send_params);
2774 }
2775
Govind Singh427ee5a2016-02-26 18:09:36 +05302776 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2777 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302778 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302779 goto err1;
2780 }
Govind Singhb53420c2016-03-09 14:32:57 +05302781 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302782
2783err1:
2784 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302785 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302786}
2787
2788/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302789 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2790 * @wmi_handle : handle to WMI.
2791 * @param : pointer to offchan data tx cmd parameter
2792 *
2793 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2794 */
2795static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2796 struct wmi_offchan_data_tx_params *param)
2797{
2798 wmi_buf_t buf;
2799 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2800 int32_t cmd_len;
2801 uint64_t dma_addr;
2802 void *qdf_ctx = param->qdf_ctx;
2803 uint8_t *bufp;
2804 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2805 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302806 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302807
2808 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302809 WMI_TLV_HDR_SIZE +
2810 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302811
Sathish Kumar5b636932017-06-28 14:40:32 +05302812 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302813 if (!buf) {
2814 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2815 return QDF_STATUS_E_NOMEM;
2816 }
2817
2818 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2819 bufp = (uint8_t *) cmd;
2820 WMITLV_SET_HDR(&cmd->tlv_header,
2821 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2822 WMITLV_GET_STRUCT_TLVLEN
2823 (wmi_offchan_data_tx_send_cmd_fixed_param));
2824
2825 cmd->vdev_id = param->vdev_id;
2826
2827 cmd->desc_id = param->desc_id;
2828 cmd->chanfreq = param->chanfreq;
2829 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2830 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2831 sizeof(uint32_t)));
2832 bufp += WMI_TLV_HDR_SIZE;
2833 qdf_mem_copy(bufp, param->pdata, bufp_len);
2834 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2835 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2836 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2837#if defined(HTT_PADDR64)
2838 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2839#endif
2840 cmd->frame_len = param->frm_len;
2841 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302842 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302843
2844 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2845 bufp, cmd->vdev_id, cmd->chanfreq);
2846
Sathish Kumar5b636932017-06-28 14:40:32 +05302847 bufp += roundup(bufp_len, sizeof(uint32_t));
2848 if (param->tx_params_valid) {
2849 status = populate_tx_send_params(bufp, param->tx_param);
2850 if (status != QDF_STATUS_SUCCESS) {
2851 WMI_LOGE("%s: Populate TX send params failed",
2852 __func__);
2853 goto err1;
2854 }
2855 cmd_len += sizeof(wmi_tx_send_params);
2856 }
2857
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302858 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2859 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2860 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05302861 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302862 }
2863
2864 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05302865
2866err1:
2867 wmi_buf_free(buf);
2868 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302869}
2870
2871/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302872 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2873 * @wmi_handle: wmi handle
2874 * @param_value: parameter value
2875 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302876 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302877 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302878static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302879 uint32_t param_value)
2880{
Govind Singh67922e82016-04-01 16:48:57 +05302881 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302882 wmi_modem_power_state_cmd_param *cmd;
2883 wmi_buf_t buf;
2884 uint16_t len = sizeof(*cmd);
2885
2886 buf = wmi_buf_alloc(wmi_handle, len);
2887 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302888 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302889 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302890 }
2891 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2892 WMITLV_SET_HDR(&cmd->tlv_header,
2893 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2894 WMITLV_GET_STRUCT_TLVLEN
2895 (wmi_modem_power_state_cmd_param));
2896 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302897 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302898 param_value);
2899 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2900 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302901 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302902 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302903 wmi_buf_free(buf);
2904 }
Govind Singh67922e82016-04-01 16:48:57 +05302905
Govind Singh427ee5a2016-02-26 18:09:36 +05302906 return ret;
2907}
2908
2909/**
2910 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2911 * @wmi_handle: wmi handle
2912 * @vdev_id: vdev id
2913 * @val: value
2914 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302915 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302916 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302917static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302918 uint32_t vdev_id, uint8_t val)
2919{
2920 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2921 wmi_buf_t buf;
2922 int32_t len = sizeof(*cmd);
2923
Govind Singhb53420c2016-03-09 14:32:57 +05302924 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302925
2926 buf = wmi_buf_alloc(wmi_handle, len);
2927 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302928 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302929 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302930 }
2931 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2932 WMITLV_SET_HDR(&cmd->tlv_header,
2933 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2934 WMITLV_GET_STRUCT_TLVLEN
2935 (wmi_sta_powersave_mode_cmd_fixed_param));
2936 cmd->vdev_id = vdev_id;
2937 if (val)
2938 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2939 else
2940 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2941
2942 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2943 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302944 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302945 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302946 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302947 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302948 }
Govind Singh5eb51532016-03-09 11:34:12 +05302949 return 0;
2950}
2951
Govind Singh427ee5a2016-02-26 18:09:36 +05302952/**
2953 * send_set_mimops_cmd_tlv() - set MIMO powersave
2954 * @wmi_handle: wmi handle
2955 * @vdev_id: vdev id
2956 * @value: value
2957 *
Govind Singhb53420c2016-03-09 14:32:57 +05302958 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302959 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302960static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302961 uint8_t vdev_id, int value)
2962{
Govind Singh67922e82016-04-01 16:48:57 +05302963 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302964 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2965 wmi_buf_t buf;
2966 uint16_t len = sizeof(*cmd);
2967
2968 buf = wmi_buf_alloc(wmi_handle, len);
2969 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302970 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302971 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302972 }
2973 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2974 WMITLV_SET_HDR(&cmd->tlv_header,
2975 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2976 WMITLV_GET_STRUCT_TLVLEN
2977 (wmi_sta_smps_force_mode_cmd_fixed_param));
2978
2979 cmd->vdev_id = vdev_id;
2980
Houston Hoffmanb5168052016-04-14 02:18:01 -07002981 /* WMI_SMPS_FORCED_MODE values do not directly map
2982 * to SM power save values defined in the specification.
2983 * Make sure to send the right mapping.
2984 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302985 switch (value) {
2986 case 0:
2987 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2988 break;
2989 case 1:
2990 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2991 break;
2992 case 2:
2993 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2994 break;
2995 case 3:
2996 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2997 break;
2998 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302999 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3000 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303001 }
3002
Govind Singhb53420c2016-03-09 14:32:57 +05303003 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303004
3005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3006 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303008 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303009 wmi_buf_free(buf);
3010 }
3011
3012 return ret;
3013}
3014
3015/**
3016 * send_set_smps_params_cmd_tlv() - set smps params
3017 * @wmi_handle: wmi handle
3018 * @vdev_id: vdev id
3019 * @value: value
3020 *
Govind Singhb53420c2016-03-09 14:32:57 +05303021 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303022 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303023static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303024 int value)
3025{
Govind Singh67922e82016-04-01 16:48:57 +05303026 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303027 wmi_sta_smps_param_cmd_fixed_param *cmd;
3028 wmi_buf_t buf;
3029 uint16_t len = sizeof(*cmd);
3030
3031 buf = wmi_buf_alloc(wmi_handle, len);
3032 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303033 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303034 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303035 }
3036 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3037 WMITLV_SET_HDR(&cmd->tlv_header,
3038 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3039 WMITLV_GET_STRUCT_TLVLEN
3040 (wmi_sta_smps_param_cmd_fixed_param));
3041
3042 cmd->vdev_id = vdev_id;
3043 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3044 cmd->param =
3045 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3046
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303048 cmd->param);
3049
3050 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3051 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303052 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303053 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303054 wmi_buf_free(buf);
3055 }
3056
3057 return ret;
3058}
3059
3060/**
3061 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3062 * @wmi_handle: wmi handle
3063 * @noa: p2p power save parameters
3064 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303065 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303066 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303067static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303068 struct p2p_ps_params *noa)
3069{
3070 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3071 wmi_p2p_noa_descriptor *noa_discriptor;
3072 wmi_buf_t buf;
3073 uint8_t *buf_ptr;
3074 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303075 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303076 uint32_t duration;
3077
Govind Singhb53420c2016-03-09 14:32:57 +05303078 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303079 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3080 buf = wmi_buf_alloc(wmi_handle, len);
3081 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303082 WMI_LOGE("Failed to allocate memory");
3083 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303084 goto end;
3085 }
3086
3087 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3088 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3089 WMITLV_SET_HDR(&cmd->tlv_header,
3090 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3091 WMITLV_GET_STRUCT_TLVLEN
3092 (wmi_p2p_set_noa_cmd_fixed_param));
3093 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3094 cmd->vdev_id = noa->session_id;
3095 cmd->enable = (duration) ? true : false;
3096 cmd->num_noa = 1;
3097
3098 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3099 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3100 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3101 sizeof
3102 (wmi_p2p_set_noa_cmd_fixed_param)
3103 + WMI_TLV_HDR_SIZE);
3104 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3105 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3106 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3107 noa_discriptor->type_count = noa->count;
3108 noa_discriptor->duration = duration;
3109 noa_discriptor->interval = noa->interval;
3110 noa_discriptor->start_time = 0;
3111
Govind Singhb53420c2016-03-09 14:32:57 +05303112 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303113 cmd->vdev_id, noa->count, noa_discriptor->duration,
3114 noa->interval);
3115 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3116 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303117 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303118 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303119 wmi_buf_free(buf);
3120 }
3121
3122end:
Govind Singhb53420c2016-03-09 14:32:57 +05303123 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303124 return status;
3125}
3126
3127
3128/**
3129 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3130 * @wmi_handle: wmi handle
3131 * @noa: p2p opp power save parameters
3132 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303133 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303134 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303135static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303136 struct p2p_ps_params *oppps)
3137{
3138 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3139 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303140 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303141
Govind Singhb53420c2016-03-09 14:32:57 +05303142 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303143 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303145 WMI_LOGE("Failed to allocate memory");
3146 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303147 goto end;
3148 }
3149
3150 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3151 WMITLV_SET_HDR(&cmd->tlv_header,
3152 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3153 WMITLV_GET_STRUCT_TLVLEN
3154 (wmi_p2p_set_oppps_cmd_fixed_param));
3155 cmd->vdev_id = oppps->session_id;
3156 if (oppps->ctwindow)
3157 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3158
3159 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303160 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303161 cmd->vdev_id, oppps->ctwindow);
3162 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3163 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303164 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303165 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303166 wmi_buf_free(buf);
3167 }
3168
3169end:
Govind Singhb53420c2016-03-09 14:32:57 +05303170 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303171 return status;
3172}
3173
Wu Gaocd3a8512017-03-13 20:17:34 +08003174#ifdef CONVERGED_P2P_ENABLE
3175/**
3176 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3177 * @wmi_handle: wmi handle
3178 * @param: p2p listen offload start parameters
3179 *
3180 * Return: QDF status
3181 */
3182static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3183 struct p2p_lo_start *param)
3184{
3185 wmi_buf_t buf;
3186 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3187 int32_t len = sizeof(*cmd);
3188 uint8_t *buf_ptr;
3189 QDF_STATUS status;
3190 int device_types_len_aligned;
3191 int probe_resp_len_aligned;
3192
3193 if (!param) {
3194 WMI_LOGE("lo start param is null");
3195 return QDF_STATUS_E_INVAL;
3196 }
3197
3198 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3199
3200 device_types_len_aligned =
3201 qdf_roundup(param->dev_types_len,
3202 sizeof(A_UINT32));
3203 probe_resp_len_aligned =
3204 qdf_roundup(param->probe_resp_len,
3205 sizeof(A_UINT32));
3206
3207 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3208 probe_resp_len_aligned;
3209
3210 buf = wmi_buf_alloc(wmi_handle, len);
3211 if (!buf) {
3212 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3213 __func__);
3214 return QDF_STATUS_E_NOMEM;
3215 }
3216
3217 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3218 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3219
3220 WMITLV_SET_HDR(&cmd->tlv_header,
3221 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3222 WMITLV_GET_STRUCT_TLVLEN(
3223 wmi_p2p_lo_start_cmd_fixed_param));
3224
3225 cmd->vdev_id = param->vdev_id;
3226 cmd->ctl_flags = param->ctl_flags;
3227 cmd->channel = param->freq;
3228 cmd->period = param->period;
3229 cmd->interval = param->interval;
3230 cmd->count = param->count;
3231 cmd->device_types_len = param->dev_types_len;
3232 cmd->prob_resp_len = param->probe_resp_len;
3233
3234 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3235 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3236 device_types_len_aligned);
3237 buf_ptr += WMI_TLV_HDR_SIZE;
3238 qdf_mem_copy(buf_ptr, param->device_types,
3239 param->dev_types_len);
3240
3241 buf_ptr += device_types_len_aligned;
3242 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3243 probe_resp_len_aligned);
3244 buf_ptr += WMI_TLV_HDR_SIZE;
3245 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3246 param->probe_resp_len);
3247
3248 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3249 cmd->channel, cmd->period, cmd->interval, cmd->count);
3250
3251 status = wmi_unified_cmd_send(wmi_handle,
3252 buf, len,
3253 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3254 if (status != QDF_STATUS_SUCCESS) {
3255 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3256 __func__, status);
3257 wmi_buf_free(buf);
3258 return status;
3259 }
3260
3261 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3262
3263 return QDF_STATUS_SUCCESS;
3264}
3265
3266/**
3267 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3268 * @wmi_handle: wmi handle
3269 * @param: p2p listen offload stop parameters
3270 *
3271 * Return: QDF status
3272 */
3273static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3274 uint8_t vdev_id)
3275{
3276 wmi_buf_t buf;
3277 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3278 int32_t len;
3279 QDF_STATUS status;
3280
3281 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3282
3283 len = sizeof(*cmd);
3284 buf = wmi_buf_alloc(wmi_handle, len);
3285 if (!buf) {
3286 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3287 __func__);
3288 return QDF_STATUS_E_NOMEM;
3289 }
3290 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3291
3292 WMITLV_SET_HDR(&cmd->tlv_header,
3293 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3294 WMITLV_GET_STRUCT_TLVLEN(
3295 wmi_p2p_lo_stop_cmd_fixed_param));
3296
3297 cmd->vdev_id = vdev_id;
3298
3299 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3300
3301 status = wmi_unified_cmd_send(wmi_handle,
3302 buf, len,
3303 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3304 if (status != QDF_STATUS_SUCCESS) {
3305 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3306 __func__, status);
3307 wmi_buf_free(buf);
3308 return status;
3309 }
3310
3311 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3312
3313 return QDF_STATUS_SUCCESS;
3314}
3315#endif /* End of CONVERGED_P2P_ENABLE */
3316
Govind Singh427ee5a2016-02-26 18:09:36 +05303317/**
3318 * send_get_temperature_cmd_tlv() - get pdev temperature req
3319 * @wmi_handle: wmi handle
3320 *
Govind Singhb53420c2016-03-09 14:32:57 +05303321 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303323static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303324{
3325 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3326 wmi_buf_t wmi_buf;
3327 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3328 uint8_t *buf_ptr;
3329
3330 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303331 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3332 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303333 }
3334
3335 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3336 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303337 WMI_LOGE(FL("wmi_buf_alloc failed"));
3338 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303339 }
3340
3341 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3342
3343 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3344 WMITLV_SET_HDR(&cmd->tlv_header,
3345 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3346 WMITLV_GET_STRUCT_TLVLEN
3347 (wmi_pdev_get_temperature_cmd_fixed_param));
3348
3349 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3350 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303351 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303352 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303353 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303354 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303355
Govind Singhb53420c2016-03-09 14:32:57 +05303356 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303357}
3358
3359/**
3360 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3361 * @wmi_handle: wmi handle
3362 * @vdevid: vdev id
3363 * @peer_addr: peer mac address
3364 * @auto_triggerparam: auto trigger parameters
3365 * @num_ac: number of access category
3366 *
3367 * This function sets the trigger
3368 * uapsd params such as service interval, delay interval
3369 * and suspend interval which will be used by the firmware
3370 * to send trigger frames periodically when there is no
3371 * traffic on the transmit side.
3372 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303373 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303375static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303376 struct sta_uapsd_trig_params *param)
3377{
3378 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303379 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303380 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3381 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3382 uint32_t i;
3383 wmi_buf_t buf;
3384 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003385 struct sta_uapsd_params *uapsd_param;
3386 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303387
3388 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3389 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303390 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303391 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303392 }
3393
3394 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3395 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3396 WMITLV_SET_HDR(&cmd->tlv_header,
3397 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3398 WMITLV_GET_STRUCT_TLVLEN
3399 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3400 cmd->vdev_id = param->vdevid;
3401 cmd->num_ac = param->num_ac;
3402 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3403
3404 /* TLV indicating array of structures to follow */
3405 buf_ptr += sizeof(*cmd);
3406 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3407
3408 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303409
3410 /*
3411 * Update tag and length for uapsd auto trigger params (this will take
3412 * care of updating tag and length if it is not pre-filled by caller).
3413 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003414 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3415 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303416 for (i = 0; i < param->num_ac; i++) {
3417 WMITLV_SET_HDR((buf_ptr +
3418 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3419 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3420 WMITLV_GET_STRUCT_TLVLEN
3421 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003422 trig_param->wmm_ac = uapsd_param->wmm_ac;
3423 trig_param->user_priority = uapsd_param->user_priority;
3424 trig_param->service_interval = uapsd_param->service_interval;
3425 trig_param->suspend_interval = uapsd_param->suspend_interval;
3426 trig_param->delay_interval = uapsd_param->delay_interval;
3427 trig_param++;
3428 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303429 }
3430
3431 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3432 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303433 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303434 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303435 wmi_buf_free(buf);
3436 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303437
Govind Singh427ee5a2016-02-26 18:09:36 +05303438 return ret;
3439}
3440
Govind Singh2edc80f2016-03-01 15:30:53 +05303441/**
3442 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3443 * @wmi_handle: pointer to the wmi handle
3444 * @utc: pointer to the UTC time struct
3445 *
3446 * Return: 0 on succes
3447 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303448static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303449 struct ocb_utc_param *utc)
3450{
Govind Singh67922e82016-04-01 16:48:57 +05303451 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303452 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3453 uint8_t *buf_ptr;
3454 uint32_t len, i;
3455 wmi_buf_t buf;
3456
3457 len = sizeof(*cmd);
3458 buf = wmi_buf_alloc(wmi_handle, len);
3459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303460 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303461 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303462 }
3463
3464 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3465 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3466 WMITLV_SET_HDR(&cmd->tlv_header,
3467 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3468 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3469 cmd->vdev_id = utc->vdev_id;
3470
3471 for (i = 0; i < SIZE_UTC_TIME; i++)
3472 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3473
3474 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3475 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3476
3477 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3478 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303479 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303480 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303481 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303482 }
3483
Govind Singh67922e82016-04-01 16:48:57 +05303484 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303485}
3486
3487/**
3488 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3489 * frames on a channel
3490 * @wmi_handle: pointer to the wmi handle
3491 * @timing_advert: pointer to the timing advertisement struct
3492 *
3493 * Return: 0 on succes
3494 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303495static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303496 struct ocb_timing_advert_param *timing_advert)
3497{
Govind Singh67922e82016-04-01 16:48:57 +05303498 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303499 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3500 uint8_t *buf_ptr;
3501 uint32_t len, len_template;
3502 wmi_buf_t buf;
3503
3504 len = sizeof(*cmd) +
3505 WMI_TLV_HDR_SIZE;
3506
3507 len_template = timing_advert->template_length;
3508 /* Add padding to the template if needed */
3509 if (len_template % 4 != 0)
3510 len_template += 4 - (len_template % 4);
3511 len += len_template;
3512
3513 buf = wmi_buf_alloc(wmi_handle, len);
3514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303515 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303516 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303517 }
3518
3519 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3520 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3521 WMITLV_SET_HDR(&cmd->tlv_header,
3522 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3523 WMITLV_GET_STRUCT_TLVLEN(
3524 wmi_ocb_start_timing_advert_cmd_fixed_param));
3525 cmd->vdev_id = timing_advert->vdev_id;
3526 cmd->repeat_rate = timing_advert->repeat_rate;
3527 cmd->channel_freq = timing_advert->chan_freq;
3528 cmd->timestamp_offset = timing_advert->timestamp_offset;
3529 cmd->time_value_offset = timing_advert->time_value_offset;
3530 cmd->timing_advert_template_length = timing_advert->template_length;
3531 buf_ptr += sizeof(*cmd);
3532
3533 /* Add the timing advert template */
3534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3535 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303536 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303537 (uint8_t *)timing_advert->template_value,
3538 timing_advert->template_length);
3539
3540 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3541 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303542 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303543 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303544 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303545 }
3546
Govind Singh67922e82016-04-01 16:48:57 +05303547 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303548}
3549
3550/**
3551 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3552 * on a channel
3553 * @wmi_handle: pointer to the wmi handle
3554 * @timing_advert: pointer to the timing advertisement struct
3555 *
3556 * Return: 0 on succes
3557 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303558static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303559 struct ocb_timing_advert_param *timing_advert)
3560{
Govind Singh67922e82016-04-01 16:48:57 +05303561 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303562 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3563 uint8_t *buf_ptr;
3564 uint32_t len;
3565 wmi_buf_t buf;
3566
3567 len = sizeof(*cmd);
3568 buf = wmi_buf_alloc(wmi_handle, len);
3569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303570 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303571 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303572 }
3573
3574 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3575 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3576 WMITLV_SET_HDR(&cmd->tlv_header,
3577 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3578 WMITLV_GET_STRUCT_TLVLEN(
3579 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3580 cmd->vdev_id = timing_advert->vdev_id;
3581 cmd->channel_freq = timing_advert->chan_freq;
3582
3583 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3584 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303585 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303586 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303587 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303588 }
3589
Govind Singh67922e82016-04-01 16:48:57 +05303590 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303591}
3592
3593/**
3594 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3595 * @wmi_handle: pointer to the wmi handle
3596 * @request: pointer to the request
3597 *
3598 * Return: 0 on succes
3599 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303600static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303601 uint8_t vdev_id)
3602{
Govind Singhb53420c2016-03-09 14:32:57 +05303603 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303604 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3605 uint8_t *buf_ptr;
3606 wmi_buf_t buf;
3607 int32_t len;
3608
3609 len = sizeof(*cmd);
3610 buf = wmi_buf_alloc(wmi_handle, len);
3611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303612 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303613 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303614 }
3615 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3616
3617 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303618 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303619 WMITLV_SET_HDR(&cmd->tlv_header,
3620 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3621 WMITLV_GET_STRUCT_TLVLEN(
3622 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3623 cmd->vdev_id = vdev_id;
3624
3625 /* Send the WMI command */
3626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3627 WMI_OCB_GET_TSF_TIMER_CMDID);
3628 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303629 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303630 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303631 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303632 }
3633
Govind Singh67922e82016-04-01 16:48:57 +05303634 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303635}
3636
3637/**
3638 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3639 * @wmi_handle: pointer to the wmi handle
3640 * @get_stats_param: pointer to the dcc stats
3641 *
3642 * Return: 0 on succes
3643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303644static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303645 struct dcc_get_stats_param *get_stats_param)
3646{
Govind Singh67922e82016-04-01 16:48:57 +05303647 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303648 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3649 wmi_dcc_channel_stats_request *channel_stats_array;
3650 wmi_buf_t buf;
3651 uint8_t *buf_ptr;
3652 uint32_t len;
3653 uint32_t i;
3654
3655 /* Validate the input */
3656 if (get_stats_param->request_array_len !=
3657 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303658 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303659 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303660 }
3661
3662 /* Allocate memory for the WMI command */
3663 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3664 get_stats_param->request_array_len;
3665
3666 buf = wmi_buf_alloc(wmi_handle, len);
3667 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303668 WMI_LOGE(FL("wmi_buf_alloc failed"));
3669 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303670 }
3671
3672 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303673 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303674
3675 /* Populate the WMI command */
3676 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3677 buf_ptr += sizeof(*cmd);
3678
3679 WMITLV_SET_HDR(&cmd->tlv_header,
3680 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3681 WMITLV_GET_STRUCT_TLVLEN(
3682 wmi_dcc_get_stats_cmd_fixed_param));
3683 cmd->vdev_id = get_stats_param->vdev_id;
3684 cmd->num_channels = get_stats_param->channel_count;
3685
3686 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3687 get_stats_param->request_array_len);
3688 buf_ptr += WMI_TLV_HDR_SIZE;
3689
3690 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303691 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303692 get_stats_param->request_array_len);
3693 for (i = 0; i < cmd->num_channels; i++)
3694 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3695 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3696 WMITLV_GET_STRUCT_TLVLEN(
3697 wmi_dcc_channel_stats_request));
3698
3699 /* Send the WMI command */
3700 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3701 WMI_DCC_GET_STATS_CMDID);
3702
Govind Singh67922e82016-04-01 16:48:57 +05303703 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303704 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303705 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303706 }
3707
Govind Singh67922e82016-04-01 16:48:57 +05303708 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303709}
3710
3711/**
3712 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3713 * @wmi_handle: pointer to the wmi handle
3714 * @vdev_id: vdev id
3715 * @dcc_stats_bitmap: dcc status bitmap
3716 *
3717 * Return: 0 on succes
3718 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303719static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303720 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3721{
Govind Singh67922e82016-04-01 16:48:57 +05303722 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303723 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3724 wmi_buf_t buf;
3725 uint8_t *buf_ptr;
3726 uint32_t len;
3727
3728 /* Allocate memory for the WMI command */
3729 len = sizeof(*cmd);
3730
3731 buf = wmi_buf_alloc(wmi_handle, len);
3732 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303733 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303734 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303735 }
3736
3737 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303738 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303739
3740 /* Populate the WMI command */
3741 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3742
3743 WMITLV_SET_HDR(&cmd->tlv_header,
3744 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3745 WMITLV_GET_STRUCT_TLVLEN(
3746 wmi_dcc_clear_stats_cmd_fixed_param));
3747 cmd->vdev_id = vdev_id;
3748 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3749
3750 /* Send the WMI command */
3751 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3752 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303753 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303754 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303755 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303756 }
3757
Govind Singh67922e82016-04-01 16:48:57 +05303758 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303759}
3760
3761/**
3762 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3763 * @wmi_handle: pointer to the wmi handle
3764 * @update_ndl_param: pointer to the request parameters
3765 *
3766 * Return: 0 on success
3767 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303768static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303769 struct dcc_update_ndl_param *update_ndl_param)
3770{
Govind Singhb53420c2016-03-09 14:32:57 +05303771 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303772 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3773 wmi_dcc_ndl_chan *ndl_chan_array;
3774 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3775 uint32_t active_state_count;
3776 wmi_buf_t buf;
3777 uint8_t *buf_ptr;
3778 uint32_t len;
3779 uint32_t i;
3780
3781 /* validate the input */
3782 if (update_ndl_param->dcc_ndl_chan_list_len !=
3783 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303784 WMI_LOGE(FL("Invalid parameter"));
3785 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303786 }
3787 active_state_count = 0;
3788 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3789 for (i = 0; i < update_ndl_param->channel_count; i++)
3790 active_state_count +=
3791 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3792 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3793 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303794 WMI_LOGE(FL("Invalid parameter"));
3795 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303796 }
3797
3798 /* Allocate memory for the WMI command */
3799 len = sizeof(*cmd) +
3800 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3801 WMI_TLV_HDR_SIZE +
3802 update_ndl_param->dcc_ndl_active_state_list_len;
3803
3804 buf = wmi_buf_alloc(wmi_handle, len);
3805 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303806 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303807 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303808 }
3809
3810 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303811 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303812
3813 /* Populate the WMI command */
3814 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3815 buf_ptr += sizeof(*cmd);
3816
3817 WMITLV_SET_HDR(&cmd->tlv_header,
3818 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3819 WMITLV_GET_STRUCT_TLVLEN(
3820 wmi_dcc_update_ndl_cmd_fixed_param));
3821 cmd->vdev_id = update_ndl_param->vdev_id;
3822 cmd->num_channel = update_ndl_param->channel_count;
3823
3824 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3825 update_ndl_param->dcc_ndl_chan_list_len);
3826 buf_ptr += WMI_TLV_HDR_SIZE;
3827
3828 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303829 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303830 update_ndl_param->dcc_ndl_chan_list_len);
3831 for (i = 0; i < cmd->num_channel; i++)
3832 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3833 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3834 WMITLV_GET_STRUCT_TLVLEN(
3835 wmi_dcc_ndl_chan));
3836 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3837
3838 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3839 update_ndl_param->dcc_ndl_active_state_list_len);
3840 buf_ptr += WMI_TLV_HDR_SIZE;
3841
3842 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303843 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303844 update_ndl_param->dcc_ndl_active_state_list,
3845 update_ndl_param->dcc_ndl_active_state_list_len);
3846 for (i = 0; i < active_state_count; i++) {
3847 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3848 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3849 WMITLV_GET_STRUCT_TLVLEN(
3850 wmi_dcc_ndl_active_state_config));
3851 }
3852 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3853
3854 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303855 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303856 WMI_DCC_UPDATE_NDL_CMDID);
3857 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303858 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303859 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303860 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303861 }
3862
Govind Singh67922e82016-04-01 16:48:57 +05303863 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303864}
3865
3866/**
3867 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3868 * @wmi_handle: pointer to the wmi handle
3869 * @config: the OCB configuration
3870 *
3871 * Return: 0 on success
3872 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303873static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303874 struct ocb_config_param *config, uint32_t *ch_mhz)
3875{
Govind Singh67922e82016-04-01 16:48:57 +05303876 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303877 wmi_ocb_set_config_cmd_fixed_param *cmd;
3878 wmi_channel *chan;
3879 wmi_ocb_channel *ocb_chan;
3880 wmi_qos_parameter *qos_param;
3881 wmi_dcc_ndl_chan *ndl_chan;
3882 wmi_dcc_ndl_active_state_config *ndl_active_config;
3883 wmi_ocb_schedule_element *sched_elem;
3884 uint8_t *buf_ptr;
3885 wmi_buf_t buf;
3886 int32_t len;
3887 int32_t i, j, active_state_count;
3888
3889 /*
3890 * Validate the dcc_ndl_chan_list_len and count the number of active
3891 * states. Validate dcc_ndl_active_state_list_len.
3892 */
3893 active_state_count = 0;
3894 if (config->dcc_ndl_chan_list_len) {
3895 if (!config->dcc_ndl_chan_list ||
3896 config->dcc_ndl_chan_list_len !=
3897 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303898 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303899 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303900 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303901 }
3902
3903 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3904 i < config->channel_count; ++i, ++ndl_chan)
3905 active_state_count +=
3906 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3907
3908 if (active_state_count) {
3909 if (!config->dcc_ndl_active_state_list ||
3910 config->dcc_ndl_active_state_list_len !=
3911 active_state_count *
3912 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303913 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303914 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303915 }
3916 }
3917 }
3918
3919 len = sizeof(*cmd) +
3920 WMI_TLV_HDR_SIZE + config->channel_count *
3921 sizeof(wmi_channel) +
3922 WMI_TLV_HDR_SIZE + config->channel_count *
3923 sizeof(wmi_ocb_channel) +
3924 WMI_TLV_HDR_SIZE + config->channel_count *
3925 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3926 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3927 WMI_TLV_HDR_SIZE + active_state_count *
3928 sizeof(wmi_dcc_ndl_active_state_config) +
3929 WMI_TLV_HDR_SIZE + config->schedule_size *
3930 sizeof(wmi_ocb_schedule_element);
3931 buf = wmi_buf_alloc(wmi_handle, len);
3932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303933 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303934 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303935 }
3936
3937 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3938 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3939 WMITLV_SET_HDR(&cmd->tlv_header,
3940 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3941 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3942 cmd->vdev_id = config->session_id;
3943 cmd->channel_count = config->channel_count;
3944 cmd->schedule_size = config->schedule_size;
3945 cmd->flags = config->flags;
3946 buf_ptr += sizeof(*cmd);
3947
3948 /* Add the wmi_channel info */
3949 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3950 config->channel_count*sizeof(wmi_channel));
3951 buf_ptr += WMI_TLV_HDR_SIZE;
3952 for (i = 0; i < config->channel_count; i++) {
3953 chan = (wmi_channel *)buf_ptr;
3954 WMITLV_SET_HDR(&chan->tlv_header,
3955 WMITLV_TAG_STRUC_wmi_channel,
3956 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3957 chan->mhz = config->channels[i].chan_freq;
3958 chan->band_center_freq1 = config->channels[i].chan_freq;
3959 chan->band_center_freq2 = 0;
3960 chan->info = 0;
3961
3962 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3963 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3964 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3965 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3966 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3967 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3968 config->channels[i].antenna_max);
3969
3970 if (config->channels[i].bandwidth < 10)
3971 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3972 else if (config->channels[i].bandwidth < 20)
3973 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3974 buf_ptr += sizeof(*chan);
3975 }
3976
3977 /* Add the wmi_ocb_channel info */
3978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3979 config->channel_count*sizeof(wmi_ocb_channel));
3980 buf_ptr += WMI_TLV_HDR_SIZE;
3981 for (i = 0; i < config->channel_count; i++) {
3982 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3983 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3984 WMITLV_TAG_STRUC_wmi_ocb_channel,
3985 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3986 ocb_chan->bandwidth = config->channels[i].bandwidth;
3987 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3988 config->channels[i].mac_address.bytes,
3989 &ocb_chan->mac_address);
3990 buf_ptr += sizeof(*ocb_chan);
3991 }
3992
3993 /* Add the wmi_qos_parameter info */
3994 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3995 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3996 buf_ptr += WMI_TLV_HDR_SIZE;
3997 /* WMI_MAX_NUM_AC parameters for each channel */
3998 for (i = 0; i < config->channel_count; i++) {
3999 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4000 qos_param = (wmi_qos_parameter *)buf_ptr;
4001 WMITLV_SET_HDR(&qos_param->tlv_header,
4002 WMITLV_TAG_STRUC_wmi_qos_parameter,
4003 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4004 qos_param->aifsn =
4005 config->channels[i].qos_params[j].aifsn;
4006 qos_param->cwmin =
4007 config->channels[i].qos_params[j].cwmin;
4008 qos_param->cwmax =
4009 config->channels[i].qos_params[j].cwmax;
4010 buf_ptr += sizeof(*qos_param);
4011 }
4012 }
4013
4014 /* Add the wmi_dcc_ndl_chan (per channel) */
4015 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4016 config->dcc_ndl_chan_list_len);
4017 buf_ptr += WMI_TLV_HDR_SIZE;
4018 if (config->dcc_ndl_chan_list_len) {
4019 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304020 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304021 config->dcc_ndl_chan_list_len);
4022 for (i = 0; i < config->channel_count; i++)
4023 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4024 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4025 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4026 buf_ptr += config->dcc_ndl_chan_list_len;
4027 }
4028
4029 /* Add the wmi_dcc_ndl_active_state_config */
4030 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4031 sizeof(wmi_dcc_ndl_active_state_config));
4032 buf_ptr += WMI_TLV_HDR_SIZE;
4033 if (active_state_count) {
4034 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304035 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304036 config->dcc_ndl_active_state_list,
4037 active_state_count * sizeof(*ndl_active_config));
4038 for (i = 0; i < active_state_count; ++i)
4039 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4040 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4041 WMITLV_GET_STRUCT_TLVLEN(
4042 wmi_dcc_ndl_active_state_config));
4043 buf_ptr += active_state_count *
4044 sizeof(*ndl_active_config);
4045 }
4046
4047 /* Add the wmi_ocb_schedule_element info */
4048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4049 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4050 buf_ptr += WMI_TLV_HDR_SIZE;
4051 for (i = 0; i < config->schedule_size; i++) {
4052 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4053 WMITLV_SET_HDR(&sched_elem->tlv_header,
4054 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4055 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4056 sched_elem->channel_freq = config->schedule[i].chan_freq;
4057 sched_elem->total_duration = config->schedule[i].total_duration;
4058 sched_elem->guard_interval = config->schedule[i].guard_interval;
4059 buf_ptr += sizeof(*sched_elem);
4060 }
4061
4062
4063 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4064 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304065 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304066 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304067 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304068 }
4069
Govind Singh67922e82016-04-01 16:48:57 +05304070 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304071}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304072
4073/**
4074 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4075 * @wmi_handle: wmi handle
4076 * @mcc_adaptive_scheduler: enable/disable
4077 *
4078 * This function enable/disable mcc adaptive scheduler in fw.
4079 *
Govind Singhb53420c2016-03-09 14:32:57 +05304080 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304081 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304082static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004083 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4084 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304085{
Govind Singh67922e82016-04-01 16:48:57 +05304086 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304087 wmi_buf_t buf = 0;
4088 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4089 uint16_t len =
4090 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4091
4092 buf = wmi_buf_alloc(wmi_handle, len);
4093 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304094 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4095 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304096 }
4097 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4098 wmi_buf_data(buf);
4099
4100 WMITLV_SET_HDR(&cmd->tlv_header,
4101 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4102 WMITLV_GET_STRUCT_TLVLEN
4103 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4104 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304105 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304106
4107 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4108 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304109 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304110 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304111 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304112 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304113 }
Govind Singh67922e82016-04-01 16:48:57 +05304114
4115 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304116}
4117
4118/**
4119 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4120 * @wmi: wmi handle
4121 * @mcc_channel: mcc channel
4122 * @mcc_channel_time_latency: MCC channel time latency.
4123 *
4124 * Currently used to set time latency for an MCC vdev/adapter using operating
4125 * channel of it and channel number. The info is provided run time using
4126 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4127 *
4128 * Return: CDF status
4129 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304130static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304131 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4132{
Govind Singh67922e82016-04-01 16:48:57 +05304133 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304134 wmi_buf_t buf = 0;
4135 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4136 uint16_t len = 0;
4137 uint8_t *buf_ptr = NULL;
4138 wmi_resmgr_chan_latency chan_latency;
4139 /* Note: we only support MCC time latency for a single channel */
4140 uint32_t num_channels = 1;
4141 uint32_t chan1_freq = mcc_channel_freq;
4142 uint32_t latency_chan1 = mcc_channel_time_latency;
4143
4144
4145 /* If 0ms latency is provided, then FW will set to a default.
4146 * Otherwise, latency must be at least 30ms.
4147 */
4148 if ((latency_chan1 > 0) &&
4149 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304150 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304151 "Minimum is 30ms (or 0 to use default value by "
4152 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304153 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304154 }
4155
4156 /* Set WMI CMD for channel time latency here */
4157 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4158 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4159 num_channels * sizeof(wmi_resmgr_chan_latency);
4160 buf = wmi_buf_alloc(wmi_handle, len);
4161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304162 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4163 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304164 }
4165 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4166 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4167 wmi_buf_data(buf);
4168 WMITLV_SET_HDR(&cmdTL->tlv_header,
4169 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4170 WMITLV_GET_STRUCT_TLVLEN
4171 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4172 cmdTL->num_chans = num_channels;
4173 /* Update channel time latency information for home channel(s) */
4174 buf_ptr += sizeof(*cmdTL);
4175 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4176 num_channels * sizeof(wmi_resmgr_chan_latency));
4177 buf_ptr += WMI_TLV_HDR_SIZE;
4178 chan_latency.chan_mhz = chan1_freq;
4179 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304180 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304181 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4182 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304183 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304184 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304185 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304186 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304187 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304188 }
Govind Singh67922e82016-04-01 16:48:57 +05304189
4190 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304191}
4192
4193/**
4194 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4195 * @wmi: wmi handle
4196 * @adapter_1_chan_number: adapter 1 channel number
4197 * @adapter_1_quota: adapter 1 quota
4198 * @adapter_2_chan_number: adapter 2 channel number
4199 *
4200 * Return: CDF status
4201 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304202static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304203 uint32_t adapter_1_chan_freq,
4204 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4205{
Govind Singh67922e82016-04-01 16:48:57 +05304206 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304207 wmi_buf_t buf = 0;
4208 uint16_t len = 0;
4209 uint8_t *buf_ptr = NULL;
4210 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4211 wmi_resmgr_chan_time_quota chan_quota;
4212 uint32_t quota_chan1 = adapter_1_quota;
4213 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4214 uint32_t quota_chan2 = 100 - quota_chan1;
4215 /* Note: setting time quota for MCC requires info for 2 channels */
4216 uint32_t num_channels = 2;
4217 uint32_t chan1_freq = adapter_1_chan_freq;
4218 uint32_t chan2_freq = adapter_2_chan_freq;
4219
Govind Singhb53420c2016-03-09 14:32:57 +05304220 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304221 "freq2:%dMHz, Quota2:%dms", __func__,
4222 chan1_freq, quota_chan1, chan2_freq,
4223 quota_chan2);
4224
4225 /*
4226 * Perform sanity check on time quota values provided.
4227 */
4228 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4229 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304230 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304231 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304232 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304233 }
4234 /* Set WMI CMD for channel time quota here */
4235 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4236 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4237 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4238 buf = wmi_buf_alloc(wmi_handle, len);
4239 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304240 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4241 QDF_ASSERT(0);
4242 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304243 }
4244 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4245 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4246 wmi_buf_data(buf);
4247 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4248 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4249 WMITLV_GET_STRUCT_TLVLEN
4250 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4251 cmdTQ->num_chans = num_channels;
4252
4253 /* Update channel time quota information for home channel(s) */
4254 buf_ptr += sizeof(*cmdTQ);
4255 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4256 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4257 buf_ptr += WMI_TLV_HDR_SIZE;
4258 chan_quota.chan_mhz = chan1_freq;
4259 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304260 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304261 /* Construct channel and quota record for the 2nd MCC mode. */
4262 buf_ptr += sizeof(chan_quota);
4263 chan_quota.chan_mhz = chan2_freq;
4264 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304265 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304266
4267 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4268 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304269 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304270 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304271 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304272 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304273 }
Govind Singh67922e82016-04-01 16:48:57 +05304274
4275 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304276}
4277
4278/**
4279 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4280 * @wmi_handle: Pointer to wmi handle
4281 * @thermal_info: Thermal command information
4282 *
4283 * This function sends the thermal management command
4284 * to the firmware
4285 *
Govind Singhb53420c2016-03-09 14:32:57 +05304286 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304287 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304288static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304289 struct thermal_cmd_params *thermal_info)
4290{
4291 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4292 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304293 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304294 uint32_t len = 0;
4295
4296 len = sizeof(*cmd);
4297
4298 buf = wmi_buf_alloc(wmi_handle, len);
4299 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304300 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4301 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304302 }
4303
4304 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4305
4306 WMITLV_SET_HDR(&cmd->tlv_header,
4307 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4308 WMITLV_GET_STRUCT_TLVLEN
4309 (wmi_thermal_mgmt_cmd_fixed_param));
4310
4311 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4312 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4313 cmd->enable = thermal_info->thermal_enable;
4314
Govind Singhb53420c2016-03-09 14:32:57 +05304315 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304316 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4317
4318 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4319 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304320 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304321 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304322 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304323 }
4324
Govind Singh67922e82016-04-01 16:48:57 +05304325 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304326}
4327
4328
4329/**
4330 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304331 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304332 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4333 *
4334 * This function sends down the LRO configuration parameters to
4335 * the firmware to enable LRO, sets the TCP flags and sets the
4336 * seed values for the toeplitz hash generation
4337 *
Govind Singhb53420c2016-03-09 14:32:57 +05304338 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304339 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304340static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304341 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4342{
4343 wmi_lro_info_cmd_fixed_param *cmd;
4344 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304345 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304346
4347
4348 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304350 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4351 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304352 }
4353
4354 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4355
4356 WMITLV_SET_HDR(&cmd->tlv_header,
4357 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4358 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4359
4360 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4361 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4362 wmi_lro_cmd->tcp_flag);
4363 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4364 wmi_lro_cmd->tcp_flag_mask);
4365 cmd->toeplitz_hash_ipv4_0_3 =
4366 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4367 cmd->toeplitz_hash_ipv4_4_7 =
4368 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4369 cmd->toeplitz_hash_ipv4_8_11 =
4370 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4371 cmd->toeplitz_hash_ipv4_12_15 =
4372 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4373 cmd->toeplitz_hash_ipv4_16 =
4374 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4375
4376 cmd->toeplitz_hash_ipv6_0_3 =
4377 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4378 cmd->toeplitz_hash_ipv6_4_7 =
4379 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4380 cmd->toeplitz_hash_ipv6_8_11 =
4381 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4382 cmd->toeplitz_hash_ipv6_12_15 =
4383 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4384 cmd->toeplitz_hash_ipv6_16_19 =
4385 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4386 cmd->toeplitz_hash_ipv6_20_23 =
4387 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4388 cmd->toeplitz_hash_ipv6_24_27 =
4389 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4390 cmd->toeplitz_hash_ipv6_28_31 =
4391 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4392 cmd->toeplitz_hash_ipv6_32_35 =
4393 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4394 cmd->toeplitz_hash_ipv6_36_39 =
4395 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4396 cmd->toeplitz_hash_ipv6_40 =
4397 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4398
Govind Singhb53420c2016-03-09 14:32:57 +05304399 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304400 cmd->lro_enable, cmd->tcp_flag_u32);
4401
4402 status = wmi_unified_cmd_send(wmi_handle, buf,
4403 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304404 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304405 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304406 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304407 }
4408
Govind Singh67922e82016-04-01 16:48:57 +05304409 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304410}
4411
Govind Singh4eacd2b2016-03-07 14:24:22 +05304412/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304413 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4414 * @wmi_handle: Pointer to wmi handle
4415 * @rate_report_params: Pointer to peer rate report parameters
4416 *
4417 *
4418 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4419 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304420static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304421 struct wmi_peer_rate_report_params *rate_report_params)
4422{
4423 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4424 wmi_buf_t buf = NULL;
4425 QDF_STATUS status = 0;
4426 uint32_t len = 0;
4427 uint32_t i, j;
4428
4429 len = sizeof(*cmd);
4430
4431 buf = wmi_buf_alloc(wmi_handle, len);
4432 if (!buf) {
4433 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4434 return QDF_STATUS_E_FAILURE;
4435 }
4436
4437 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4438 wmi_buf_data(buf);
4439
4440 WMITLV_SET_HDR(
4441 &cmd->tlv_header,
4442 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4443 WMITLV_GET_STRUCT_TLVLEN(
4444 wmi_peer_set_rate_report_condition_fixed_param));
4445
4446 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4447 cmd->report_backoff_time = rate_report_params->backoff_time;
4448 cmd->report_timer_period = rate_report_params->timer_period;
4449 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4450 cmd->cond_per_phy[i].val_cond_flags =
4451 rate_report_params->report_per_phy[i].cond_flags;
4452 cmd->cond_per_phy[i].rate_delta.min_delta =
4453 rate_report_params->report_per_phy[i].delta.delta_min;
4454 cmd->cond_per_phy[i].rate_delta.percentage =
4455 rate_report_params->report_per_phy[i].delta.percent;
4456 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4457 cmd->cond_per_phy[i].rate_threshold[j] =
4458 rate_report_params->report_per_phy[i].
4459 report_rate_threshold[j];
4460 }
4461 }
4462
4463 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4464 cmd->enable_rate_report,
4465 cmd->report_backoff_time, cmd->report_timer_period);
4466
4467 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4468 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4469 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304470 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304471 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4472 __func__);
4473 }
4474 return status;
4475}
4476
4477/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304478 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4479 * @wmi_handle: wmi handle
4480 * @param: bcn ll cmd parameter
4481 *
Govind Singhb53420c2016-03-09 14:32:57 +05304482 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304483 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304484static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304485 wmi_bcn_send_from_host_cmd_fixed_param *param)
4486{
4487 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4488 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304489 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304490
4491 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4492 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304493 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4494 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 }
4496
4497 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4498 WMITLV_SET_HDR(&cmd->tlv_header,
4499 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4500 WMITLV_GET_STRUCT_TLVLEN
4501 (wmi_bcn_send_from_host_cmd_fixed_param));
4502 cmd->vdev_id = param->vdev_id;
4503 cmd->data_len = param->data_len;
4504 cmd->frame_ctrl = param->frame_ctrl;
4505 cmd->frag_ptr = param->frag_ptr;
4506 cmd->dtim_flag = param->dtim_flag;
4507
4508 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4509 WMI_PDEV_SEND_BCN_CMDID);
4510
Govind Singh67922e82016-04-01 16:48:57 +05304511 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304512 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304513 wmi_buf_free(wmi_buf);
4514 }
4515
4516 return ret;
4517}
4518
4519/**
4520 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4521 * @wmi_handle: wmi handle
4522 * @vdev_id: vdev id
4523 * @max_retries: max retries
4524 * @retry_interval: retry interval
4525 * This function sets sta query related parameters in fw.
4526 *
Govind Singhb53420c2016-03-09 14:32:57 +05304527 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304528 */
4529
Sathish Kumarfd347372017-02-13 12:29:09 +05304530static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304531 uint8_t vdev_id, uint32_t max_retries,
4532 uint32_t retry_interval)
4533{
4534 wmi_buf_t buf;
4535 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4536 int len;
4537
4538 len = sizeof(*cmd);
4539 buf = wmi_buf_alloc(wmi_handle, len);
4540 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304541 WMI_LOGE(FL("wmi_buf_alloc failed"));
4542 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304543 }
4544
4545 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4546 WMITLV_SET_HDR(&cmd->tlv_header,
4547 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4548 WMITLV_GET_STRUCT_TLVLEN
4549 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4550
4551
4552 cmd->vdev_id = vdev_id;
4553 cmd->sa_query_max_retry_count = max_retries;
4554 cmd->sa_query_retry_interval = retry_interval;
4555
Govind Singhb53420c2016-03-09 14:32:57 +05304556 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304557 vdev_id, retry_interval, max_retries);
4558
4559 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4560 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304561 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304562 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304563 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304564 }
4565
Govind Singhb53420c2016-03-09 14:32:57 +05304566 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304567 return 0;
4568}
4569
4570/**
4571 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4572 * @wmi_handle: wmi handle
4573 * @params: sta keep alive parameter
4574 *
4575 * This function sets keep alive related parameters in fw.
4576 *
4577 * Return: CDF status
4578 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304579static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304580 struct sta_params *params)
4581{
4582 wmi_buf_t buf;
4583 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4584 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4585 uint8_t *buf_ptr;
4586 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304587 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304588
Govind Singhb53420c2016-03-09 14:32:57 +05304589 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304590
Govind Singh4eacd2b2016-03-07 14:24:22 +05304591 len = sizeof(*cmd) + sizeof(*arp_rsp);
4592 buf = wmi_buf_alloc(wmi_handle, len);
4593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304594 WMI_LOGE("wmi_buf_alloc failed");
4595 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596 }
4597
4598 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4599 buf_ptr = (uint8_t *) cmd;
4600 WMITLV_SET_HDR(&cmd->tlv_header,
4601 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4602 WMITLV_GET_STRUCT_TLVLEN
4603 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4604 cmd->interval = params->timeperiod;
4605 cmd->enable = (params->timeperiod) ? 1 : 0;
4606 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304607 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304608 params->timeperiod, params->method);
4609 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4610 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4611 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4612 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4613
4614 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4615 if ((NULL == params->hostv4addr) ||
4616 (NULL == params->destv4addr) ||
4617 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304618 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304619 "destv4addr:%p destmac:%p ", __func__,
4620 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304621 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304622 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304623 }
4624 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304625 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304626 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304627 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304628 WMI_IPV4_ADDR_LEN);
4629 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4630 } else {
4631 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4632 }
4633
Govind Singh67922e82016-04-01 16:48:57 +05304634 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4635 WMI_STA_KEEPALIVE_CMDID);
4636 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304637 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304638 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304639 }
4640
Govind Singhb53420c2016-03-09 14:32:57 +05304641 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304642 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304643}
4644
4645/**
4646 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4647 * @wmi_handle: wmi handle
4648 * @if_id: vdev id
4649 * @gtx_info: GTX config params
4650 *
4651 * This function set GTX related params in firmware.
4652 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304653 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304654 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304655static 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 +05304656 struct wmi_gtx_config *gtx_info)
4657{
4658 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4659 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304660 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304661 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304662
Govind Singh4eacd2b2016-03-07 14:24:22 +05304663 buf = wmi_buf_alloc(wmi_handle, len);
4664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304665 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304666 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304667 }
4668 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4669 WMITLV_SET_HDR(&cmd->tlv_header,
4670 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4671 WMITLV_GET_STRUCT_TLVLEN
4672 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4673 cmd->vdev_id = if_id;
4674
4675 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4676 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4677 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4678 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4679 cmd->gtxPERMargin = gtx_info->gtx_margin;
4680 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4681 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4682 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4683
Govind Singhb53420c2016-03-09 14:32:57 +05304684 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304685 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4686 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4687 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4688 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4689
Abhishek Singh716c46c2016-05-04 16:24:07 +05304690 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304691 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304692 if (QDF_IS_STATUS_ERROR(ret)) {
4693 WMI_LOGE("Failed to set GTX PARAMS");
4694 wmi_buf_free(buf);
4695 }
4696 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304697}
4698
4699/**
4700 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4701 * @wmi_handle: wmi handle
4702 * @edca_params: edca parameters
4703 *
4704 * This function updates EDCA parameters to the target
4705 *
4706 * Return: CDF Status
4707 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304708static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304709 uint8_t vdev_id,
4710 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4711{
4712 uint8_t *buf_ptr;
4713 wmi_buf_t buf;
4714 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4715 wmi_wmm_vparams *wmm_param, *twmm_param;
4716 int len = sizeof(*cmd);
4717 int ac;
4718
4719 buf = wmi_buf_alloc(wmi_handle, len);
4720
4721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304722 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4723 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304724 }
4725
4726 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4727 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4728 WMITLV_SET_HDR(&cmd->tlv_header,
4729 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4730 WMITLV_GET_STRUCT_TLVLEN
4731 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4732 cmd->vdev_id = vdev_id;
4733
4734 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4735 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4736 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4737 WMITLV_SET_HDR(&wmm_param->tlv_header,
4738 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4739 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4740 wmm_param->cwmin = twmm_param->cwmin;
4741 wmm_param->cwmax = twmm_param->cwmax;
4742 wmm_param->aifs = twmm_param->aifs;
4743 wmm_param->txoplimit = twmm_param->txoplimit;
4744 wmm_param->acm = twmm_param->acm;
4745 wmm_param->no_ack = twmm_param->no_ack;
4746 }
4747
4748 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4749 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4750 goto fail;
4751
Govind Singhb53420c2016-03-09 14:32:57 +05304752 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304753
4754fail:
4755 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304756 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4757 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304758}
4759
4760/**
4761 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4762 * @wmi_handle: wmi handle
4763 * @vdev_id: vdev id
4764 * @probe_rsp_info: probe response info
4765 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304766 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304767 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304768static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304769 uint8_t vdev_id,
4770 struct wmi_probe_resp_params *probe_rsp_info,
4771 uint8_t *frm)
4772{
4773 wmi_prb_tmpl_cmd_fixed_param *cmd;
4774 wmi_bcn_prb_info *bcn_prb_info;
4775 wmi_buf_t wmi_buf;
4776 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4777 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304778 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304779
Govind Singhb53420c2016-03-09 14:32:57 +05304780 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304781
4782 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4783 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4784
4785 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4786 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4787 tmpl_len_aligned;
4788
4789 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304790 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304791 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304792 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304793 }
4794
4795 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4796 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304797 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304798 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304799 }
4800
4801 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4802
4803 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4804 WMITLV_SET_HDR(&cmd->tlv_header,
4805 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4806 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4807 cmd->vdev_id = vdev_id;
4808 cmd->buf_len = tmpl_len;
4809 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4810
4811 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4812 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4813 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4814 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4815 bcn_prb_info->caps = 0;
4816 bcn_prb_info->erp = 0;
4817 buf_ptr += sizeof(wmi_bcn_prb_info);
4818
4819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4820 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304821 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304822
4823 ret = wmi_unified_cmd_send(wmi_handle,
4824 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304825 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304826 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304827 wmi_buf_free(wmi_buf);
4828 }
4829
4830 return ret;
4831}
4832
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304833#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304834#define WPI_IV_LEN 16
4835
4836/**
4837 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4838 *
4839 * @dest_tx: destination address of tsc key counter
4840 * @src_tx: source address of tsc key counter
4841 * @dest_rx: destination address of rsc key counter
4842 * @src_rx: source address of rsc key counter
4843 *
4844 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4845 *
4846 * Return: None
4847 *
4848 */
4849static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4850 uint8_t *dest_rx, uint8_t *src_rx)
4851{
4852 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4853 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4854}
4855#else
4856static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4857 uint8_t *dest_rx, uint8_t *src_rx)
4858{
4859 return;
4860}
4861#endif
4862
4863/**
4864 * send_setup_install_key_cmd_tlv() - set key parameters
4865 * @wmi_handle: wmi handle
4866 * @key_params: key parameters
4867 *
4868 * This function fills structure from information
4869 * passed in key_params.
4870 *
4871 * Return: QDF_STATUS_SUCCESS - success
4872 * QDF_STATUS_E_FAILURE - failure
4873 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4874 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304875static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304876 struct set_key_params *key_params)
4877{
4878 wmi_vdev_install_key_cmd_fixed_param *cmd;
4879 wmi_buf_t buf;
4880 uint8_t *buf_ptr;
4881 uint32_t len;
4882 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304883 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304884
4885 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4886 WMI_TLV_HDR_SIZE;
4887
4888 buf = wmi_buf_alloc(wmi_handle, len);
4889 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304890 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304891 return QDF_STATUS_E_NOMEM;
4892 }
4893
4894 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4895 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4896 WMITLV_SET_HDR(&cmd->tlv_header,
4897 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4898 WMITLV_GET_STRUCT_TLVLEN
4899 (wmi_vdev_install_key_cmd_fixed_param));
4900 cmd->vdev_id = key_params->vdev_id;
4901 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304902
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304903
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304904 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4905 cmd->key_flags |= key_params->key_flags;
4906 cmd->key_cipher = key_params->key_cipher;
4907 if ((key_params->key_txmic_len) &&
4908 (key_params->key_rxmic_len)) {
4909 cmd->key_txmic_len = key_params->key_txmic_len;
4910 cmd->key_rxmic_len = key_params->key_rxmic_len;
4911 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304912#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304913 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4914 key_params->tx_iv,
4915 cmd->wpi_key_rsc_counter,
4916 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304917#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304918 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4919 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4920 roundup(key_params->key_len, sizeof(uint32_t)));
4921 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4922 qdf_mem_copy((void *)key_data,
4923 (const void *)key_params->key_data, key_params->key_len);
4924 cmd->key_len = key_params->key_len;
4925
4926 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4927 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304928 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304929 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304930
Govind Singh67922e82016-04-01 16:48:57 +05304931 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304932}
4933
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304934/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004935 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4936 * @wmi_handle: wmi handle
4937 * @params: sar limit params
4938 *
4939 * Return: QDF_STATUS_SUCCESS for success or error code
4940 */
4941static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4942 struct sar_limit_cmd_params *sar_limit_params)
4943{
4944 wmi_buf_t buf;
4945 QDF_STATUS qdf_status;
4946 wmi_sar_limits_cmd_fixed_param *cmd;
4947 int i;
4948 uint8_t *buf_ptr;
4949 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4950 struct sar_limit_cmd_row *sar_rows_list;
4951 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4952
4953 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4954 buf = wmi_buf_alloc(wmi_handle, len);
4955 if (!buf) {
4956 WMI_LOGE("Failed to allocate memory");
4957 qdf_status = QDF_STATUS_E_NOMEM;
4958 goto end;
4959 }
4960
4961 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4962 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4963 WMITLV_SET_HDR(&cmd->tlv_header,
4964 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4965 WMITLV_GET_STRUCT_TLVLEN
4966 (wmi_sar_limits_cmd_fixed_param));
4967 cmd->sar_enable = sar_limit_params->sar_enable;
4968 cmd->commit_limits = sar_limit_params->commit_limits;
4969 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4970
4971 WMI_LOGD("no of sar rows = %d, len = %d",
4972 sar_limit_params->num_limit_rows, len);
4973 buf_ptr += sizeof(*cmd);
4974 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4975 sizeof(wmi_sar_limit_cmd_row) *
4976 sar_limit_params->num_limit_rows);
4977 if (cmd->num_limit_rows == 0)
4978 goto send_sar_limits;
4979
4980 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4981 (buf_ptr + WMI_TLV_HDR_SIZE);
4982 sar_rows_list = sar_limit_params->sar_limit_row_list;
4983
4984 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4985 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4986 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4987 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4988 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4989 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4990 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4991 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4992 wmi_sar_rows_list->validity_bitmap =
4993 sar_rows_list->validity_bitmap;
4994 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4995 i, wmi_sar_rows_list->band_id,
4996 wmi_sar_rows_list->chain_id,
4997 wmi_sar_rows_list->mod_id,
4998 wmi_sar_rows_list->limit_value,
4999 wmi_sar_rows_list->validity_bitmap);
5000 sar_rows_list++;
5001 wmi_sar_rows_list++;
5002 }
5003send_sar_limits:
5004 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5005 WMI_SAR_LIMITS_CMDID);
5006
5007 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5008 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5009 wmi_buf_free(buf);
5010 }
5011
5012end:
5013 return qdf_status;
5014}
5015
5016/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305017 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5018 * @wmi_handle: wmi handle
5019 * @params: encrypt/decrypt params
5020 *
5021 * Return: QDF_STATUS_SUCCESS for success or error code
5022 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005023static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305024QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
5025 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
5026{
5027 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5028 wmi_buf_t wmi_buf;
5029 uint8_t *buf_ptr;
5030 QDF_STATUS ret;
5031 uint32_t len;
5032
5033 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5034
5035 len = sizeof(*cmd) +
5036 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5037 WMI_TLV_HDR_SIZE;
5038 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5039 if (!wmi_buf) {
5040 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5041 __func__);
5042 return QDF_STATUS_E_NOMEM;
5043 }
5044
5045 buf_ptr = wmi_buf_data(wmi_buf);
5046 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5047
5048 WMITLV_SET_HDR(&cmd->tlv_header,
5049 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5050 WMITLV_GET_STRUCT_TLVLEN(
5051 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5052
5053 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5054 cmd->key_flag = encrypt_decrypt_params->key_flag;
5055 cmd->key_idx = encrypt_decrypt_params->key_idx;
5056 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5057 cmd->key_len = encrypt_decrypt_params->key_len;
5058 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5059 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5060
5061 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5062 encrypt_decrypt_params->key_len);
5063
5064 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5065 MAX_MAC_HEADER_LEN);
5066
5067 cmd->data_len = encrypt_decrypt_params->data_len;
5068
5069 if (cmd->data_len) {
5070 buf_ptr += sizeof(*cmd);
5071 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5072 roundup(encrypt_decrypt_params->data_len,
5073 sizeof(A_UINT32)));
5074 buf_ptr += WMI_TLV_HDR_SIZE;
5075 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5076 encrypt_decrypt_params->data_len);
5077 }
5078
5079 /* This conversion is to facilitate data to FW in little endian */
5080 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5081 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5082 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5083 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5084 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5085 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5086
5087 ret = wmi_unified_cmd_send(wmi_handle,
5088 wmi_buf, len,
5089 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5090 if (QDF_IS_STATUS_ERROR(ret)) {
5091 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5092 wmi_buf_free(wmi_buf);
5093 }
5094
5095 return ret;
5096}
5097
5098
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305099
Govind Singh4eacd2b2016-03-07 14:24:22 +05305100/**
5101 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5102 * @wmi_handle: wmi handle
5103 * @vdev_id: vdev id
5104 * @p2p_ie: p2p IE
5105 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305106 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305108static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305109 A_UINT32 vdev_id, uint8_t *p2p_ie)
5110{
Govind Singh67922e82016-04-01 16:48:57 +05305111 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305112 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5113 wmi_buf_t wmi_buf;
5114 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5115 uint8_t *buf_ptr;
5116
5117 ie_len = (uint32_t) (p2p_ie[1] + 2);
5118
5119 /* More than one P2P IE may be included in a single frame.
5120 If multiple P2P IEs are present, the complete P2P attribute
5121 data consists of the concatenation of the P2P Attribute
5122 fields of the P2P IEs. The P2P Attributes field of each
5123 P2P IE may be any length up to the maximum (251 octets).
5124 In this case host sends one P2P IE to firmware so the length
5125 should not exceed more than 251 bytes
5126 */
5127 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305128 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305129 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305130 }
5131
5132 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5133
5134 wmi_buf_len =
5135 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5136 WMI_TLV_HDR_SIZE;
5137
5138 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5139 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305140 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305141 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305142 }
5143
5144 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5145
5146 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5147 WMITLV_SET_HDR(&cmd->tlv_header,
5148 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5149 WMITLV_GET_STRUCT_TLVLEN
5150 (wmi_p2p_go_set_beacon_ie_fixed_param));
5151 cmd->vdev_id = vdev_id;
5152 cmd->ie_buf_len = ie_len;
5153
5154 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5155 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5156 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305157 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305158
Govind Singhb53420c2016-03-09 14:32:57 +05305159 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305160
5161 ret = wmi_unified_cmd_send(wmi_handle,
5162 wmi_buf, wmi_buf_len,
5163 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305164 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305165 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305166 wmi_buf_free(wmi_buf);
5167 }
5168
Govind Singhb53420c2016-03-09 14:32:57 +05305169 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305170 return ret;
5171}
5172
5173/**
5174 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5175 * @wmi_handle: wmi handle
5176 * @req: gateway parameter update request structure
5177 *
5178 * This function reads the incoming @req and fill in the destination
5179 * WMI structure and sends down the gateway configs down to the firmware
5180 *
Govind Singhb53420c2016-03-09 14:32:57 +05305181 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305182 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305183static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305184 struct gateway_update_req_param *req)
5185{
5186 wmi_roam_subnet_change_config_fixed_param *cmd;
5187 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305188 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305189 int len = sizeof(*cmd);
5190
5191 buf = wmi_buf_alloc(wmi_handle, len);
5192 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305193 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5194 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305195 }
5196
5197 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5198 WMITLV_SET_HDR(&cmd->tlv_header,
5199 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5200 WMITLV_GET_STRUCT_TLVLEN(
5201 wmi_roam_subnet_change_config_fixed_param));
5202
5203 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305204 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5205 QDF_IPV4_ADDR_SIZE);
5206 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5207 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305208 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5209 &cmd->inet_gw_mac_addr);
5210 cmd->max_retries = req->max_retries;
5211 cmd->timeout = req->timeout;
5212 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5213 cmd->flag = 0;
5214 if (req->ipv4_addr_type)
5215 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5216
5217 if (req->ipv6_addr_type)
5218 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5219
5220 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5221 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305222 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305223 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305224 ret);
5225 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305226 }
5227
Govind Singh67922e82016-04-01 16:48:57 +05305228 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305229}
5230
5231/**
5232 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5233 * @wmi_handle: wmi handle
5234 * @req: rssi monitoring request structure
5235 *
5236 * This function reads the incoming @req and fill in the destination
5237 * WMI structure and send down the rssi monitoring configs down to the firmware
5238 *
5239 * Return: 0 on success; error number otherwise
5240 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305241static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305242 struct rssi_monitor_param *req)
5243{
5244 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5245 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305246 QDF_STATUS ret;
5247 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305248
5249 buf = wmi_buf_alloc(wmi_handle, len);
5250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305251 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5252 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 }
5254
5255 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5256 WMITLV_SET_HDR(&cmd->tlv_header,
5257 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5258 WMITLV_GET_STRUCT_TLVLEN(
5259 wmi_rssi_breach_monitor_config_fixed_param));
5260
5261 cmd->vdev_id = req->session_id;
5262 cmd->request_id = req->request_id;
5263 cmd->lo_rssi_reenable_hysteresis = 0;
5264 cmd->hi_rssi_reenable_histeresis = 0;
5265 cmd->min_report_interval = 0;
5266 cmd->max_num_report = 1;
5267 if (req->control) {
5268 /* enable one threshold for each min/max */
5269 cmd->enabled_bitmap = 0x09;
5270 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5271 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5272 } else {
5273 cmd->enabled_bitmap = 0;
5274 cmd->low_rssi_breach_threshold[0] = 0;
5275 cmd->hi_rssi_breach_threshold[0] = 0;
5276 }
5277
5278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5279 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305280 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305281 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305282 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305283 }
5284
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005285 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5286
Govind Singh67922e82016-04-01 16:48:57 +05305287 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305288}
5289
5290/**
5291 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5292 * @wmi_handle: wmi handle
5293 * @psetoui: OUI parameters
5294 *
5295 * set scan probe OUI parameters in firmware
5296 *
5297 * Return: CDF status
5298 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305299static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305300 struct scan_mac_oui *psetoui)
5301{
5302 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5303 wmi_buf_t wmi_buf;
5304 uint32_t len;
5305 uint8_t *buf_ptr;
5306 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305307 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305309 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5310 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5311
Govind Singh4eacd2b2016-03-07 14:24:22 +05305312 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5313 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305314 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5315 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305316 }
5317 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5318 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5319 WMITLV_SET_HDR(&cmd->tlv_header,
5320 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5321 WMITLV_GET_STRUCT_TLVLEN
5322 (wmi_scan_prob_req_oui_cmd_fixed_param));
5323
5324 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305325 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305326 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5327 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305328 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305329 cmd->prob_req_oui);
5330
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305331 cmd->vdev_id = psetoui->vdev_id;
5332 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5333 if (psetoui->enb_probe_req_sno_randomization)
5334 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5335
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305336 if (ie_whitelist->white_list) {
5337 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5338 &cmd->num_vendor_oui,
5339 ie_whitelist);
5340 cmd->flags |=
5341 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5342 }
5343
5344 buf_ptr += sizeof(*cmd);
5345 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5346 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5347 buf_ptr += WMI_TLV_HDR_SIZE;
5348
5349 if (cmd->num_vendor_oui != 0) {
5350 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5351 ie_whitelist->voui);
5352 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5353 }
5354
Govind Singh4eacd2b2016-03-07 14:24:22 +05305355 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5356 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305357 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305358 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305359 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305360 }
Govind Singhb53420c2016-03-09 14:32:57 +05305361 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305362}
5363
5364/**
5365 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5366 * @wmi_handle: wmi handle
5367 * @req: passpoint network request structure
5368 *
5369 * This function sends down WMI command with network id set to wildcard id.
5370 * firmware shall clear all the config entries
5371 *
Govind Singhb53420c2016-03-09 14:32:57 +05305372 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305373 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305374static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305375 struct wifi_passpoint_req_param *req)
5376{
5377 wmi_passpoint_config_cmd_fixed_param *cmd;
5378 wmi_buf_t buf;
5379 uint32_t len;
5380 int ret;
5381
5382 len = sizeof(*cmd);
5383 buf = wmi_buf_alloc(wmi_handle, len);
5384 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305385 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5386 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305387 }
5388
5389 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5390
5391 WMITLV_SET_HDR(&cmd->tlv_header,
5392 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5393 WMITLV_GET_STRUCT_TLVLEN(
5394 wmi_passpoint_config_cmd_fixed_param));
5395 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5396
5397 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5398 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5399 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305400 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305401 __func__);
5402 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305403 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305404 }
5405
Govind Singhb53420c2016-03-09 14:32:57 +05305406 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305407}
5408
5409/**
5410 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5411 * @wmi_handle: wmi handle
5412 * @req: passpoint network request structure
5413 *
5414 * This function reads the incoming @req and fill in the destination
5415 * WMI structure and send down the passpoint configs down to the firmware
5416 *
Govind Singhb53420c2016-03-09 14:32:57 +05305417 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305418 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305419static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305420 struct wifi_passpoint_req_param *req)
5421{
5422 wmi_passpoint_config_cmd_fixed_param *cmd;
5423 u_int8_t i, j, *bytes;
5424 wmi_buf_t buf;
5425 uint32_t len;
5426 int ret;
5427
5428 len = sizeof(*cmd);
5429 for (i = 0; i < req->num_networks; i++) {
5430 buf = wmi_buf_alloc(wmi_handle, len);
5431 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305432 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5433 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305434 }
5435
5436 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5437 wmi_buf_data(buf);
5438
5439 WMITLV_SET_HDR(&cmd->tlv_header,
5440 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5441 WMITLV_GET_STRUCT_TLVLEN(
5442 wmi_passpoint_config_cmd_fixed_param));
5443 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305444 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5445 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305446 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305447 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305448 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5449 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305450 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305451 j, bytes[0], bytes[1], bytes[2], bytes[3],
5452 bytes[4], bytes[5], bytes[6], bytes[7]);
5453
Govind Singhb53420c2016-03-09 14:32:57 +05305454 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305455 &req->networks[i].roaming_consortium_ids[j],
5456 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5457 }
Govind Singhb53420c2016-03-09 14:32:57 +05305458 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305459 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305460 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305461 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5462
5463 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5464 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5465 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305466 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305467 __func__);
5468 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305469 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305470 }
5471 }
5472
Govind Singhb53420c2016-03-09 14:32:57 +05305473 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305474}
5475
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305476/**
5477 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5478 * @wmi_handle: wmi handle
5479 * @scan_cmd_fp: start scan command ptr
5480 * @roam_req: roam request param
5481 *
5482 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5483 * of WMI_ROAM_SCAN_MODE.
5484 *
5485 * Return: QDF status
5486 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305487static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305488 wmi_start_scan_cmd_fixed_param *
5489 scan_cmd_fp,
5490 struct roam_offload_scan_params *roam_req)
5491{
5492 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305493 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305494 int len;
5495 uint8_t *buf_ptr;
5496 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305497
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305498#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5499 int auth_mode = roam_req->auth_mode;
5500 wmi_roam_offload_tlv_param *roam_offload_params;
5501 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5502 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5503 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305504 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305505#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5506 /* Need to create a buf with roam_scan command at
5507 * front and piggyback with scan command */
5508 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5509#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5510 (2 * WMI_TLV_HDR_SIZE) +
5511#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5512 sizeof(wmi_start_scan_cmd_fixed_param);
5513#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5514 if (roam_req->is_roam_req_valid &&
5515 roam_req->roam_offload_enabled) {
5516 len += sizeof(wmi_roam_offload_tlv_param);
5517 len += WMI_TLV_HDR_SIZE;
5518 if ((auth_mode != WMI_AUTH_NONE) &&
5519 ((auth_mode != WMI_AUTH_OPEN) ||
5520 (auth_mode == WMI_AUTH_OPEN &&
5521 roam_req->mdid.mdie_present) ||
5522 roam_req->is_ese_assoc)) {
5523 len += WMI_TLV_HDR_SIZE;
5524 if (roam_req->is_ese_assoc)
5525 len +=
5526 sizeof(wmi_roam_ese_offload_tlv_param);
5527 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5528 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5529 (auth_mode == WMI_AUTH_OPEN &&
5530 roam_req->mdid.mdie_present))
5531 len +=
5532 sizeof(wmi_roam_11r_offload_tlv_param);
5533 else
5534 len +=
5535 sizeof(wmi_roam_11i_offload_tlv_param);
5536 } else {
5537 len += WMI_TLV_HDR_SIZE;
5538 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305539
5540 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5541 + roundup(roam_req->assoc_ie_length,
5542 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305543 } else {
5544 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305545 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305546 __func__, roam_req->roam_offload_enabled);
5547 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305548 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305549 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305550 }
5551 if (roam_req->is_roam_req_valid &&
5552 roam_req->roam_offload_enabled) {
5553 roam_req->mode = roam_req->mode |
5554 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5555 }
5556#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5557
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305558 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5559 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5560 len = sizeof(wmi_roam_scan_mode_fixed_param);
5561
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305562 buf = wmi_buf_alloc(wmi_handle, len);
5563 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305564 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305565 return QDF_STATUS_E_NOMEM;
5566 }
5567
5568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305569
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305570 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5571 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5572 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5573 WMITLV_GET_STRUCT_TLVLEN
5574 (wmi_roam_scan_mode_fixed_param));
5575
5576 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5577 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305578 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5579 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5580 roam_scan_mode_fp->flags |=
5581 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305582 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305583 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305584
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305585 /* Fill in scan parameters suitable for roaming scan */
5586 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305587
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305588 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5589 sizeof(wmi_start_scan_cmd_fixed_param));
5590 /* Ensure there is no additional IEs */
5591 scan_cmd_fp->ie_len = 0;
5592 WMITLV_SET_HDR(buf_ptr,
5593 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5594 WMITLV_GET_STRUCT_TLVLEN
5595 (wmi_start_scan_cmd_fixed_param));
5596#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5597 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5598 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5599 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5600 sizeof(wmi_roam_offload_tlv_param));
5601 buf_ptr += WMI_TLV_HDR_SIZE;
5602 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5603 WMITLV_SET_HDR(buf_ptr,
5604 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5605 WMITLV_GET_STRUCT_TLVLEN
5606 (wmi_roam_offload_tlv_param));
5607 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5608 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5609 roam_offload_params->select_5g_margin =
5610 roam_req->select_5ghz_margin;
5611 roam_offload_params->reassoc_failure_timeout =
5612 roam_req->reassoc_failure_timeout;
5613
5614 /* Fill the capabilities */
5615 roam_offload_params->capability =
5616 roam_req->roam_offload_params.capability;
5617 roam_offload_params->ht_caps_info =
5618 roam_req->roam_offload_params.ht_caps_info;
5619 roam_offload_params->ampdu_param =
5620 roam_req->roam_offload_params.ampdu_param;
5621 roam_offload_params->ht_ext_cap =
5622 roam_req->roam_offload_params.ht_ext_cap;
5623 roam_offload_params->ht_txbf =
5624 roam_req->roam_offload_params.ht_txbf;
5625 roam_offload_params->asel_cap =
5626 roam_req->roam_offload_params.asel_cap;
5627 roam_offload_params->qos_caps =
5628 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005629 roam_offload_params->qos_enabled =
5630 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305631 roam_offload_params->wmm_caps =
5632 roam_req->roam_offload_params.wmm_caps;
5633 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5634 (uint8_t *)roam_req->roam_offload_params.mcsset,
5635 ROAM_OFFLOAD_NUM_MCS_SET);
5636
5637 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5638 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5639 * they are filled in the same order.Depending on the
5640 * authentication type, the other mode TLV's are nullified
5641 * and only headers are filled.*/
5642 if ((auth_mode != WMI_AUTH_NONE) &&
5643 ((auth_mode != WMI_AUTH_OPEN) ||
5644 (auth_mode == WMI_AUTH_OPEN
5645 && roam_req->mdid.mdie_present) ||
5646 roam_req->is_ese_assoc)) {
5647 if (roam_req->is_ese_assoc) {
5648 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5649 WMITLV_GET_STRUCT_TLVLEN(0));
5650 buf_ptr += WMI_TLV_HDR_SIZE;
5651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5652 WMITLV_GET_STRUCT_TLVLEN(0));
5653 buf_ptr += WMI_TLV_HDR_SIZE;
5654 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5655 sizeof(wmi_roam_ese_offload_tlv_param));
5656 buf_ptr += WMI_TLV_HDR_SIZE;
5657 roam_offload_ese =
5658 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5659 qdf_mem_copy(roam_offload_ese->krk,
5660 roam_req->krk,
5661 sizeof(roam_req->krk));
5662 qdf_mem_copy(roam_offload_ese->btk,
5663 roam_req->btk,
5664 sizeof(roam_req->btk));
5665 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5666 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5667 WMITLV_GET_STRUCT_TLVLEN
5668 (wmi_roam_ese_offload_tlv_param));
5669 buf_ptr +=
5670 sizeof(wmi_roam_ese_offload_tlv_param);
5671 } else if (auth_mode == WMI_AUTH_FT_RSNA
5672 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5673 || (auth_mode == WMI_AUTH_OPEN
5674 && roam_req->mdid.mdie_present)) {
5675 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5676 0);
5677 buf_ptr += WMI_TLV_HDR_SIZE;
5678 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5679 sizeof(wmi_roam_11r_offload_tlv_param));
5680 buf_ptr += WMI_TLV_HDR_SIZE;
5681 roam_offload_11r =
5682 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5683 roam_offload_11r->r0kh_id_len =
5684 roam_req->rokh_id_length;
5685 qdf_mem_copy(roam_offload_11r->r0kh_id,
5686 roam_req->rokh_id,
5687 roam_offload_11r->r0kh_id_len);
5688 qdf_mem_copy(roam_offload_11r->psk_msk,
5689 roam_req->psk_pmk,
5690 sizeof(roam_req->psk_pmk));
5691 roam_offload_11r->psk_msk_len =
5692 roam_req->pmk_len;
5693 roam_offload_11r->mdie_present =
5694 roam_req->mdid.mdie_present;
5695 roam_offload_11r->mdid =
5696 roam_req->mdid.mobility_domain;
5697 if (auth_mode == WMI_AUTH_OPEN) {
5698 /* If FT-Open ensure pmk length
5699 and r0khid len are zero */
5700 roam_offload_11r->r0kh_id_len = 0;
5701 roam_offload_11r->psk_msk_len = 0;
5702 }
5703 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5704 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5705 WMITLV_GET_STRUCT_TLVLEN
5706 (wmi_roam_11r_offload_tlv_param));
5707 buf_ptr +=
5708 sizeof(wmi_roam_11r_offload_tlv_param);
5709 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5710 WMITLV_GET_STRUCT_TLVLEN(0));
5711 buf_ptr += WMI_TLV_HDR_SIZE;
5712 } else {
5713 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5714 sizeof(wmi_roam_11i_offload_tlv_param));
5715 buf_ptr += WMI_TLV_HDR_SIZE;
5716 roam_offload_11i =
5717 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005718
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005719 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005720 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305721 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5722 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005723 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305724 } else {
5725 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5726 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005727 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005728 }
5729 if (roam_req->roam_key_mgmt_offload_enabled &&
5730 roam_req->fw_pmksa_cache) {
5731 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5732 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005733 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005734 } else {
5735 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5736 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005737 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305738 }
5739
5740 qdf_mem_copy(roam_offload_11i->pmk,
5741 roam_req->psk_pmk,
5742 sizeof(roam_req->psk_pmk));
5743 roam_offload_11i->pmk_len = roam_req->pmk_len;
5744 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5745 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5746 WMITLV_GET_STRUCT_TLVLEN
5747 (wmi_roam_11i_offload_tlv_param));
5748 buf_ptr +=
5749 sizeof(wmi_roam_11i_offload_tlv_param);
5750 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5751 0);
5752 buf_ptr += WMI_TLV_HDR_SIZE;
5753 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5754 0);
5755 buf_ptr += WMI_TLV_HDR_SIZE;
5756 }
5757 } else {
5758 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5759 WMITLV_GET_STRUCT_TLVLEN(0));
5760 buf_ptr += WMI_TLV_HDR_SIZE;
5761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5762 WMITLV_GET_STRUCT_TLVLEN(0));
5763 buf_ptr += WMI_TLV_HDR_SIZE;
5764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5765 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305766 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305767 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305768
5769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5770 sizeof(*assoc_ies));
5771 buf_ptr += WMI_TLV_HDR_SIZE;
5772
5773 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5774 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5775 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5776 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5777 assoc_ies->buf_len = roam_req->assoc_ie_length;
5778
5779 buf_ptr += sizeof(*assoc_ies);
5780
5781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5782 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5783 buf_ptr += WMI_TLV_HDR_SIZE;
5784
5785 if (assoc_ies->buf_len != 0) {
5786 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5787 assoc_ies->buf_len);
5788 }
5789
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305790 } else {
5791 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5792 WMITLV_GET_STRUCT_TLVLEN(0));
5793 buf_ptr += WMI_TLV_HDR_SIZE;
5794 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5795 WMITLV_GET_STRUCT_TLVLEN(0));
5796 buf_ptr += WMI_TLV_HDR_SIZE;
5797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5798 WMITLV_GET_STRUCT_TLVLEN(0));
5799 buf_ptr += WMI_TLV_HDR_SIZE;
5800 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5801 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305802 buf_ptr += WMI_TLV_HDR_SIZE;
5803 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5804 WMITLV_GET_STRUCT_TLVLEN(0));
5805 buf_ptr += WMI_TLV_HDR_SIZE;
5806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5807 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305808 }
5809#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305810
5811send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305812 status = wmi_unified_cmd_send(wmi_handle, buf,
5813 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305814 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305815 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305816 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5817 status);
5818 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305819 }
5820
Govind Singh67922e82016-04-01 16:48:57 +05305821 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305822}
5823
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07005824static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
5825 struct wmi_mawc_roam_params *params)
5826{
5827 wmi_buf_t buf = NULL;
5828 QDF_STATUS status;
5829 int len;
5830 uint8_t *buf_ptr;
5831 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
5832
5833 len = sizeof(*wmi_roam_mawc_params);
5834 buf = wmi_buf_alloc(wmi_handle, len);
5835 if (!buf) {
5836 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
5837 return QDF_STATUS_E_NOMEM;
5838 }
5839
5840 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5841 wmi_roam_mawc_params =
5842 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
5843 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
5844 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
5845 WMITLV_GET_STRUCT_TLVLEN
5846 (wmi_roam_configure_mawc_cmd_fixed_param));
5847 wmi_roam_mawc_params->vdev_id = params->vdev_id;
5848 if (params->enable)
5849 wmi_roam_mawc_params->enable = 1;
5850 else
5851 wmi_roam_mawc_params->enable = 0;
5852 wmi_roam_mawc_params->traffic_load_threshold =
5853 params->traffic_load_threshold;
5854 wmi_roam_mawc_params->best_ap_rssi_threshold =
5855 params->best_ap_rssi_threshold;
5856 wmi_roam_mawc_params->rssi_stationary_high_adjust =
5857 params->rssi_stationary_high_adjust;
5858 wmi_roam_mawc_params->rssi_stationary_low_adjust =
5859 params->rssi_stationary_low_adjust;
5860
5861 status = wmi_unified_cmd_send(wmi_handle, buf,
5862 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
5863 if (QDF_IS_STATUS_ERROR(status)) {
5864 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
5865 status);
5866 wmi_buf_free(buf);
5867 return status;
5868 }
5869 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
5870 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
5871 wmi_roam_mawc_params->traffic_load_threshold,
5872 wmi_roam_mawc_params->best_ap_rssi_threshold,
5873 wmi_roam_mawc_params->rssi_stationary_high_adjust,
5874 wmi_roam_mawc_params->rssi_stationary_low_adjust);
5875
5876 return QDF_STATUS_SUCCESS;
5877}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305878
5879/**
5880 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5881 * rssi threashold
5882 * @wmi_handle: wmi handle
5883 * @roam_req: Roaming request buffer
5884 *
5885 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5886 *
5887 * Return: QDF status
5888 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305889static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305890 struct roam_offload_scan_rssi_params *roam_req)
5891{
5892 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305893 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305894 int len;
5895 uint8_t *buf_ptr;
5896 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5897 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5898 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305899 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305900
5901 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5902 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5903 len += sizeof(wmi_roam_scan_extended_threshold_param);
5904 len += WMI_TLV_HDR_SIZE;
5905 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305906 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5907 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305908 buf = wmi_buf_alloc(wmi_handle, len);
5909 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305910 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305911 return QDF_STATUS_E_NOMEM;
5912 }
5913
5914 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5915 rssi_threshold_fp =
5916 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5917 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5918 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5919 WMITLV_GET_STRUCT_TLVLEN
5920 (wmi_roam_scan_rssi_threshold_fixed_param));
5921 /* fill in threshold values */
5922 rssi_threshold_fp->vdev_id = roam_req->session_id;
5923 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5924 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5925 rssi_threshold_fp->hirssi_scan_max_count =
5926 roam_req->hi_rssi_scan_max_count;
5927 rssi_threshold_fp->hirssi_scan_delta =
5928 roam_req->hi_rssi_scan_rssi_delta;
5929 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07005930 rssi_threshold_fp->rssi_thresh_offset_5g =
5931 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305932
5933 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5934 WMITLV_SET_HDR(buf_ptr,
5935 WMITLV_TAG_ARRAY_STRUC,
5936 sizeof(wmi_roam_scan_extended_threshold_param));
5937 buf_ptr += WMI_TLV_HDR_SIZE;
5938 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5939
5940 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5941 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5942 ext_thresholds->boost_threshold_5g =
5943 roam_req->boost_threshold_5g;
5944
5945 ext_thresholds->boost_algorithm_5g =
5946 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5947 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5948 ext_thresholds->penalty_algorithm_5g =
5949 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5950 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5951 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5952 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5953 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5954
5955 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5956 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5957 WMITLV_GET_STRUCT_TLVLEN
5958 (wmi_roam_scan_extended_threshold_param));
5959 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5960 WMITLV_SET_HDR(buf_ptr,
5961 WMITLV_TAG_ARRAY_STRUC,
5962 sizeof(wmi_roam_earlystop_rssi_thres_param));
5963 buf_ptr += WMI_TLV_HDR_SIZE;
5964 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5965 early_stop_thresholds->roam_earlystop_thres_min =
5966 roam_req->roam_earlystop_thres_min;
5967 early_stop_thresholds->roam_earlystop_thres_max =
5968 roam_req->roam_earlystop_thres_max;
5969 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5970 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5971 WMITLV_GET_STRUCT_TLVLEN
5972 (wmi_roam_earlystop_rssi_thres_param));
5973
Gupta, Kapil7e652922016-04-12 15:02:00 +05305974 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5975 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5976 sizeof(wmi_roam_dense_thres_param));
5977 buf_ptr += WMI_TLV_HDR_SIZE;
5978 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5979 dense_thresholds->roam_dense_rssi_thres_offset =
5980 roam_req->dense_rssi_thresh_offset;
5981 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5982 dense_thresholds->roam_dense_traffic_thres =
5983 roam_req->traffic_threshold;
5984 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5985 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5986 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5987 WMITLV_GET_STRUCT_TLVLEN
5988 (wmi_roam_dense_thres_param));
5989
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305990 status = wmi_unified_cmd_send(wmi_handle, buf,
5991 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305992 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305993 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305994 status);
5995 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305996 }
5997
Govind Singh67922e82016-04-01 16:48:57 +05305998 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305999}
6000
6001/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306002 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6003 * configuration params
6004 * @wma_handle: wma handler
6005 * @dwelltime_params: pointer to dwelltime_params
6006 *
6007 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6008 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006009static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306010QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6011 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6012{
6013 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6014 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6015 wmi_buf_t buf;
6016 uint8_t *buf_ptr;
6017 int32_t err;
6018 int len;
6019
6020 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6021 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6022 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6023 buf = wmi_buf_alloc(wmi_handle, len);
6024 if (!buf) {
6025 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6026 __func__);
6027 return QDF_STATUS_E_NOMEM;
6028 }
6029 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6030 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6031 WMITLV_SET_HDR(&dwell_param->tlv_header,
6032 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6033 WMITLV_GET_STRUCT_TLVLEN
6034 (wmi_scan_adaptive_dwell_config_fixed_param));
6035
6036 dwell_param->enable = dwelltime_params->is_enabled;
6037 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6038 WMITLV_SET_HDR(buf_ptr,
6039 WMITLV_TAG_ARRAY_STRUC,
6040 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6041 buf_ptr += WMI_TLV_HDR_SIZE;
6042
6043 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6044 WMITLV_SET_HDR(&cmd->tlv_header,
6045 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6046 WMITLV_GET_STRUCT_TLVLEN(
6047 wmi_scan_adaptive_dwell_parameters_tlv));
6048
6049 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6050 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6051 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6052 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6053 err = wmi_unified_cmd_send(wmi_handle, buf,
6054 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6055 if (err) {
6056 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6057 wmi_buf_free(buf);
6058 return QDF_STATUS_E_FAILURE;
6059 }
6060
6061 return QDF_STATUS_SUCCESS;
6062}
6063
Nitesh Shah52323d02017-05-22 15:49:00 +05306064/**
6065 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6066 * configuration params
6067 * @wmi_handle: wmi handler
6068 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6069 *
6070 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6071 */
6072static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6073 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6074{
6075 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6076 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6077 wmi_buf_t buf;
6078 uint8_t *buf_ptr;
6079 QDF_STATUS err;
6080 uint32_t i;
6081 int len;
6082
6083 len = sizeof(*dbs_scan_param);
6084 len += WMI_TLV_HDR_SIZE;
6085 len += dbs_scan_params->num_clients * sizeof(*cmd);
6086
6087 buf = wmi_buf_alloc(wmi_handle, len);
6088 if (!buf) {
6089 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6090 return QDF_STATUS_E_NOMEM;
6091 }
6092
6093 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6094 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6095 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6096 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6097 WMITLV_GET_STRUCT_TLVLEN
6098 (wmi_scan_dbs_duty_cycle_fixed_param));
6099
6100 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6101 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6102 buf_ptr += sizeof(*dbs_scan_param);
6103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6104 (sizeof(*cmd) * dbs_scan_params->num_clients));
6105 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6106
6107 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6108 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6109 WMITLV_SET_HDR(&cmd->tlv_header,
6110 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6111 WMITLV_GET_STRUCT_TLVLEN(
6112 wmi_scan_dbs_duty_cycle_tlv_param));
6113 cmd->module_id = dbs_scan_params->module_id[i];
6114 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6115 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6116 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6117 }
6118
6119 err = wmi_unified_cmd_send(wmi_handle, buf,
6120 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6121 if (QDF_IS_STATUS_ERROR(err)) {
6122 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6123 wmi_buf_free(buf);
6124 return QDF_STATUS_E_FAILURE;
6125 }
6126
6127 return QDF_STATUS_SUCCESS;
6128}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306129
6130/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306131 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6132 * @wmi_handle: wmi handle
6133 * @roam_req: Request which contains the filters
6134 *
6135 * There are filters such as whitelist, blacklist and preferred
6136 * list that need to be applied to the scan results to form the
6137 * probable candidates for roaming.
6138 *
6139 * Return: Return success upon succesfully passing the
6140 * parameters to the firmware, otherwise failure.
6141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306142static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306143 struct roam_scan_filter_params *roam_req)
6144{
6145 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306146 QDF_STATUS status;
6147 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306148 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306149 uint8_t *buf_ptr;
6150 wmi_roam_filter_fixed_param *roam_filter;
6151 uint8_t *bssid_src_ptr = NULL;
6152 wmi_mac_addr *bssid_dst_ptr = NULL;
6153 wmi_ssid *ssid_ptr = NULL;
6154 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306155 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306156 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306157
6158 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306159
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306160 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306161 if (roam_req->num_bssid_black_list)
6162 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6163 len += WMI_TLV_HDR_SIZE;
6164 if (roam_req->num_ssid_white_list)
6165 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6166 len += 2 * WMI_TLV_HDR_SIZE;
6167 if (roam_req->num_bssid_preferred_list) {
6168 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6169 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6170 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306171 len += WMI_TLV_HDR_SIZE;
6172 if (roam_req->lca_disallow_config_present) {
6173 len += sizeof(*blist_param);
6174 blist_len = sizeof(*blist_param);
6175 }
6176
6177 len += WMI_TLV_HDR_SIZE;
6178 if (roam_req->num_rssi_rejection_ap)
6179 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306180
6181 buf = wmi_buf_alloc(wmi_handle, len);
6182 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306183 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306184 return QDF_STATUS_E_NOMEM;
6185 }
6186
6187 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6188 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6189 WMITLV_SET_HDR(&roam_filter->tlv_header,
6190 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6191 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6192 /* fill in fixed values */
6193 roam_filter->vdev_id = roam_req->session_id;
6194 roam_filter->flags = 0;
6195 roam_filter->op_bitmap = roam_req->op_bitmap;
6196 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6197 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6198 roam_filter->num_bssid_preferred_list =
6199 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306200 roam_filter->num_rssi_rejection_ap =
6201 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306202 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6203
6204 WMITLV_SET_HDR((buf_ptr),
6205 WMITLV_TAG_ARRAY_FIXED_STRUC,
6206 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6207 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6208 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6209 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6210 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6211 bssid_src_ptr += ATH_MAC_LEN;
6212 bssid_dst_ptr++;
6213 }
6214 buf_ptr += WMI_TLV_HDR_SIZE +
6215 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6216 WMITLV_SET_HDR((buf_ptr),
6217 WMITLV_TAG_ARRAY_FIXED_STRUC,
6218 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6219 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6220 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6221 qdf_mem_copy(&ssid_ptr->ssid,
6222 &roam_req->ssid_allowed_list[i].mac_ssid,
6223 roam_req->ssid_allowed_list[i].length);
6224 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6225 ssid_ptr++;
6226 }
6227 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6228 sizeof(wmi_ssid));
6229 WMITLV_SET_HDR((buf_ptr),
6230 WMITLV_TAG_ARRAY_FIXED_STRUC,
6231 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6232 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6233 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6234 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6235 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6236 (wmi_mac_addr *)bssid_dst_ptr);
6237 bssid_src_ptr += ATH_MAC_LEN;
6238 bssid_dst_ptr++;
6239 }
6240 buf_ptr += WMI_TLV_HDR_SIZE +
6241 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6242 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6243 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6244 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6245 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6246 *bssid_preferred_factor_ptr =
6247 roam_req->bssid_favored_factor[i];
6248 bssid_preferred_factor_ptr++;
6249 }
6250 buf_ptr += WMI_TLV_HDR_SIZE +
6251 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6252
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306253 WMITLV_SET_HDR(buf_ptr,
6254 WMITLV_TAG_ARRAY_STRUC, blist_len);
6255 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306256 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306257 blist_param =
6258 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6259 WMITLV_SET_HDR(&blist_param->tlv_header,
6260 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6261 WMITLV_GET_STRUCT_TLVLEN(
6262 wmi_roam_lca_disallow_config_tlv_param));
6263
6264 blist_param->disallow_duration = roam_req->disallow_duration;
6265 blist_param->rssi_channel_penalization =
6266 roam_req->rssi_channel_penalization;
6267 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
6268 blist_param->disallow_lca_enable_source_bitmap = 0x1;
6269 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6270 }
6271
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306272 WMITLV_SET_HDR(buf_ptr,
6273 WMITLV_TAG_ARRAY_STRUC,
6274 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6275 buf_ptr += WMI_TLV_HDR_SIZE;
6276 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6277 rssi_rej =
6278 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6279 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6280 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6281 WMITLV_GET_STRUCT_TLVLEN(
6282 wmi_roam_rssi_rejection_oce_config_param));
6283 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6284 roam_req->rssi_rejection_ap[i].bssid.bytes,
6285 &rssi_rej->bssid);
6286 rssi_rej->remaining_disallow_duration =
6287 roam_req->rssi_rejection_ap[i].remaining_duration;
6288 rssi_rej->requested_rssi =
6289 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6290 buf_ptr +=
6291 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6292 }
6293
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306294 status = wmi_unified_cmd_send(wmi_handle, buf,
6295 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306296 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306297 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306298 status);
6299 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306300 }
Govind Singh67922e82016-04-01 16:48:57 +05306301
6302 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306303}
6304
Govind Singh4eacd2b2016-03-07 14:24:22 +05306305/** send_set_epno_network_list_cmd_tlv() - set epno network list
6306 * @wmi_handle: wmi handle
6307 * @req: epno config params request structure
6308 *
6309 * This function reads the incoming epno config request structure
6310 * and constructs the WMI message to the firmware.
6311 *
6312 * Returns: 0 on success, error number otherwise
6313 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306314static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306315 struct wifi_enhanched_pno_params *req)
6316{
6317 wmi_nlo_config_cmd_fixed_param *cmd;
6318 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306319 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306320 u_int8_t i, *buf_ptr;
6321 wmi_buf_t buf;
6322 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306323 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306324
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306325 /* Fixed Params */
6326 len = sizeof(*cmd);
6327 if (req->num_networks) {
6328 /* TLV place holder for array of structures
6329 * then each nlo_configured_parameters(nlo_list) TLV.
6330 */
6331 len += WMI_TLV_HDR_SIZE;
6332 len += (sizeof(nlo_configured_parameters)
6333 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6334 /* TLV for array of uint32 channel_list */
6335 len += WMI_TLV_HDR_SIZE;
6336 /* TLV for nlo_channel_prediction_cfg */
6337 len += WMI_TLV_HDR_SIZE;
6338 /* TLV for candidate score params */
6339 len += sizeof(enlo_candidate_score_params);
6340 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341
6342 buf = wmi_buf_alloc(wmi_handle, len);
6343 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306344 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6345 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306346 }
6347
6348 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6349
6350 buf_ptr = (u_int8_t *) cmd;
6351 WMITLV_SET_HDR(&cmd->tlv_header,
6352 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6353 WMITLV_GET_STRUCT_TLVLEN(
6354 wmi_nlo_config_cmd_fixed_param));
6355 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306356
6357 /* set flag to reset if num of networks are 0 */
6358 cmd->flags = (req->num_networks == 0 ?
6359 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306360
6361 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6362
Govind Singhb53420c2016-03-09 14:32:57 +05306363 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306364 WMI_LOGD("SSID count: %d flags: %d",
6365 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306366
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306367 /* Fill nlo_config only when num_networks are non zero */
6368 if (cmd->no_of_ssids) {
6369 /* Fill networks */
6370 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6371 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6372 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306373
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306374 nlo_list = (nlo_configured_parameters *) buf_ptr;
6375 for (i = 0; i < cmd->no_of_ssids; i++) {
6376 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6377 WMITLV_TAG_ARRAY_BYTE,
6378 WMITLV_GET_STRUCT_TLVLEN(
6379 nlo_configured_parameters));
6380 /* Copy ssid and it's length */
6381 nlo_list[i].ssid.valid = true;
6382 nlo_list[i].ssid.ssid.ssid_len =
6383 req->networks[i].ssid.length;
6384 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6385 req->networks[i].ssid.mac_ssid,
6386 nlo_list[i].ssid.ssid.ssid_len);
6387 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6388 nlo_list[i].ssid.ssid.ssid_len,
6389 (char *) nlo_list[i].ssid.ssid.ssid,
6390 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306391
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306392 /* Copy pno flags */
6393 nlo_list[i].bcast_nw_type.valid = true;
6394 nlo_list[i].bcast_nw_type.bcast_nw_type =
6395 req->networks[i].flags;
6396 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306397 nlo_list[i].bcast_nw_type.bcast_nw_type);
6398
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306399 /* Copy auth bit field */
6400 nlo_list[i].auth_type.valid = true;
6401 nlo_list[i].auth_type.auth_type =
6402 req->networks[i].auth_bit_field;
6403 WMI_LOGD("Auth bit field (%u)",
6404 nlo_list[i].auth_type.auth_type);
6405 }
6406
6407 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6408 /* Fill the channel list */
6409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6410 buf_ptr += WMI_TLV_HDR_SIZE;
6411
6412 /* Fill prediction_param */
6413 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6414 buf_ptr += WMI_TLV_HDR_SIZE;
6415
6416 /* Fill epno candidate score params */
6417 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6418 WMITLV_SET_HDR(buf_ptr,
6419 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6420 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6421 cand_score_params->min5GHz_rssi =
6422 req->min_5ghz_rssi;
6423 cand_score_params->min24GHz_rssi =
6424 req->min_24ghz_rssi;
6425 cand_score_params->initial_score_max =
6426 req->initial_score_max;
6427 cand_score_params->current_connection_bonus =
6428 req->current_connection_bonus;
6429 cand_score_params->same_network_bonus =
6430 req->same_network_bonus;
6431 cand_score_params->secure_bonus =
6432 req->secure_bonus;
6433 cand_score_params->band5GHz_bonus =
6434 req->band_5ghz_bonus;
6435 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306436 }
6437
Govind Singh4eacd2b2016-03-07 14:24:22 +05306438 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306439 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306440 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306441 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306442 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306443 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 }
6445
Govind Singhb53420c2016-03-09 14:32:57 +05306446 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306447 req->session_id);
6448
Govind Singh67922e82016-04-01 16:48:57 +05306449 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306450}
6451
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306452
Govind Singh4eacd2b2016-03-07 14:24:22 +05306453/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6454 * @wmi_handle: wmi handle
6455 * @ipa_offload: ipa offload control parameter
6456 *
6457 * Returns: 0 on success, error number otherwise
6458 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306459static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306460 struct ipa_offload_control_params *ipa_offload)
6461{
6462 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6463 wmi_buf_t wmi_buf;
6464 uint32_t len;
6465 u_int8_t *buf_ptr;
6466
6467 len = sizeof(*cmd);
6468 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6469 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306470 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6471 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306472 }
6473
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08006474 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306475 ipa_offload->offload_type, ipa_offload->enable);
6476
6477 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6478
6479 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6480 WMITLV_SET_HDR(&cmd->tlv_header,
6481 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6482 WMITLV_GET_STRUCT_TLVLEN(
6483 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6484
6485 cmd->offload_type = ipa_offload->offload_type;
6486 cmd->vdev_id = ipa_offload->vdev_id;
6487 cmd->enable = ipa_offload->enable;
6488
6489 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6490 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306491 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306492 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306493 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306494 }
6495
Govind Singhb53420c2016-03-09 14:32:57 +05306496 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306497}
6498
6499/**
6500 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6501 * @wmi_handle: wmi handle
6502 * @pgetcapab: get capabilities params
6503 *
6504 * This function send request to fw to get extscan capabilities.
6505 *
6506 * Return: CDF status
6507 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306508static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306509 struct extscan_capabilities_params *pgetcapab)
6510{
6511 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6512 wmi_buf_t wmi_buf;
6513 uint32_t len;
6514 uint8_t *buf_ptr;
6515
6516 len = sizeof(*cmd);
6517 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6518 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306519 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6520 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306521 }
6522 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6523
6524 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6525 WMITLV_SET_HDR(&cmd->tlv_header,
6526 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6527 WMITLV_GET_STRUCT_TLVLEN
6528 (wmi_extscan_get_capabilities_cmd_fixed_param));
6529
6530 cmd->request_id = pgetcapab->request_id;
6531
6532 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6533 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306534 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306535 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306536 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306537 }
Govind Singhb53420c2016-03-09 14:32:57 +05306538 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306539}
6540
6541/**
6542 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6543 * @wmi_handle: wmi handle
6544 * @pcached_results: cached results parameters
6545 *
6546 * This function send request to fw to get cached results.
6547 *
6548 * Return: CDF status
6549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306550static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306551 struct extscan_cached_result_params *pcached_results)
6552{
6553 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6554 wmi_buf_t wmi_buf;
6555 uint32_t len;
6556 uint8_t *buf_ptr;
6557
6558 len = sizeof(*cmd);
6559 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6560 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306561 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6562 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306563 }
6564 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6565
6566 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6567 WMITLV_SET_HDR(&cmd->tlv_header,
6568 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6569 WMITLV_GET_STRUCT_TLVLEN
6570 (wmi_extscan_get_cached_results_cmd_fixed_param));
6571
6572 cmd->request_id = pcached_results->request_id;
6573 cmd->vdev_id = pcached_results->session_id;
6574 cmd->control_flags = pcached_results->flush;
6575
6576 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6577 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306578 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306579 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306580 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306581 }
Govind Singhb53420c2016-03-09 14:32:57 +05306582 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306583}
6584
6585/**
6586 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6587 * @wmi_handle: wmi handle
6588 * @reset_req: Reset change request params
6589 *
6590 * This function sends stop change monitor request to fw.
6591 *
6592 * Return: CDF status
6593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306594static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306595 struct extscan_capabilities_reset_params *reset_req)
6596{
6597 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6598 wmi_buf_t wmi_buf;
6599 uint32_t len;
6600 uint8_t *buf_ptr;
6601 int change_list = 0;
6602
6603 len = sizeof(*cmd);
6604
6605 /* reset significant change tlv is set to 0 */
6606 len += WMI_TLV_HDR_SIZE;
6607 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6608 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6609 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306610 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6611 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306612 }
6613 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6614
6615 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6616 buf_ptr;
6617 WMITLV_SET_HDR(&cmd->tlv_header,
6618 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6619 WMITLV_GET_STRUCT_TLVLEN
6620 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6621
6622 cmd->request_id = reset_req->request_id;
6623 cmd->vdev_id = reset_req->session_id;
6624 cmd->mode = 0;
6625
6626 buf_ptr += sizeof(*cmd);
6627 WMITLV_SET_HDR(buf_ptr,
6628 WMITLV_TAG_ARRAY_STRUC,
6629 change_list *
6630 sizeof(wmi_extscan_wlan_change_bssid_param));
6631 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6632 sizeof
6633 (wmi_extscan_wlan_change_bssid_param));
6634
6635 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6636 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306637 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306638 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306639 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306640 }
Govind Singhb53420c2016-03-09 14:32:57 +05306641 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306642}
6643
6644/**
6645 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6646 * @wmi_handle: wmi handle
6647 * @psigchange: change monitor request params
6648 * @buf: wmi buffer
6649 * @buf_len: buffer length
6650 *
6651 * This function fills elements of change monitor request buffer.
6652 *
6653 * Return: CDF status
6654 */
Govind Singhb53420c2016-03-09 14:32:57 +05306655static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306656 struct extscan_set_sig_changereq_params
6657 *psigchange, wmi_buf_t *buf, int *buf_len)
6658{
6659 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6660 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6661 uint8_t *buf_ptr;
6662 int j;
6663 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006664 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306665 struct ap_threshold_params *src_ap = psigchange->ap;
6666
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006667 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306668 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6669 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306670 }
6671 len += WMI_TLV_HDR_SIZE;
6672 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6673
6674 *buf = wmi_buf_alloc(wmi_handle, len);
6675 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306676 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306677 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306678 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306679 }
6680 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6681 cmd =
6682 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6683 buf_ptr;
6684 WMITLV_SET_HDR(&cmd->tlv_header,
6685 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6686 WMITLV_GET_STRUCT_TLVLEN
6687 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6688
6689 cmd->request_id = psigchange->request_id;
6690 cmd->vdev_id = psigchange->session_id;
6691 cmd->total_entries = numap;
6692 cmd->mode = 1;
6693 cmd->num_entries_in_page = numap;
6694 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6695 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6696 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6697 cmd->max_out_of_range_count = psigchange->min_breaching;
6698
6699 buf_ptr += sizeof(*cmd);
6700 WMITLV_SET_HDR(buf_ptr,
6701 WMITLV_TAG_ARRAY_STRUC,
6702 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6703 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6704 (buf_ptr + WMI_TLV_HDR_SIZE);
6705
6706 for (j = 0; j < numap; j++) {
6707 WMITLV_SET_HDR(dest_chglist,
6708 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6709 WMITLV_GET_STRUCT_TLVLEN
6710 (wmi_extscan_wlan_change_bssid_param));
6711
6712 dest_chglist->lower_rssi_limit = src_ap->low;
6713 dest_chglist->upper_rssi_limit = src_ap->high;
6714 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6715 &dest_chglist->bssid);
6716
Govind Singhb53420c2016-03-09 14:32:57 +05306717 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306718 dest_chglist->lower_rssi_limit);
6719 dest_chglist++;
6720 src_ap++;
6721 }
6722 buf_ptr += WMI_TLV_HDR_SIZE +
6723 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6724 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306725 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726}
6727
6728/**
6729 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6730 * @wmi_handle: wmi handle
6731 * @psigchange: change monitor request params
6732 *
6733 * This function sends start change monitor request to fw.
6734 *
6735 * Return: CDF status
6736 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306737static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306738 struct extscan_set_sig_changereq_params *
6739 psigchange)
6740{
Govind Singhb53420c2016-03-09 14:32:57 +05306741 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306742 wmi_buf_t buf;
6743 int len;
6744
6745
Govind Singhb53420c2016-03-09 14:32:57 +05306746 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306747 psigchange, &buf,
6748 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306749 if (qdf_status != QDF_STATUS_SUCCESS) {
6750 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306751 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306752 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306753 }
6754 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306755 WMI_LOGE("%s: Failed to get buffer", __func__);
6756 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306757 }
6758 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6759 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306760 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306761 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306762 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306763 }
Govind Singhb53420c2016-03-09 14:32:57 +05306764 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306765}
6766
6767/**
6768 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6769 * @wmi_handle: wmi handle
6770 * @photlist_reset: hotlist reset params
6771 *
6772 * This function configures hotlist monitor to stop in fw.
6773 *
6774 * Return: CDF status
6775 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306776static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306777 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6778{
6779 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6780 wmi_buf_t wmi_buf;
6781 uint32_t len;
6782 uint8_t *buf_ptr;
6783 int hotlist_entries = 0;
6784
6785 len = sizeof(*cmd);
6786
6787 /* reset bssid hotlist with tlv set to 0 */
6788 len += WMI_TLV_HDR_SIZE;
6789 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6790
6791 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6792 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306793 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6794 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306795 }
6796
6797 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6798 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6799 buf_ptr;
6800 WMITLV_SET_HDR(&cmd->tlv_header,
6801 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6802 WMITLV_GET_STRUCT_TLVLEN
6803 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6804
6805 cmd->request_id = photlist_reset->request_id;
6806 cmd->vdev_id = photlist_reset->session_id;
6807 cmd->mode = 0;
6808
6809 buf_ptr += sizeof(*cmd);
6810 WMITLV_SET_HDR(buf_ptr,
6811 WMITLV_TAG_ARRAY_STRUC,
6812 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6813 buf_ptr += WMI_TLV_HDR_SIZE +
6814 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6815
6816 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6817 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_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_stop_extscan_cmd_tlv() - stop extscan command to fw.
6827 * @wmi_handle: wmi handle
6828 * @pstopcmd: stop scan command request params
6829 *
6830 * This function sends stop extscan request to fw.
6831 *
6832 * Return: CDF Status.
6833 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306834static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306835 struct extscan_stop_req_params *pstopcmd)
6836{
6837 wmi_extscan_stop_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 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6850 WMITLV_SET_HDR(&cmd->tlv_header,
6851 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6852 WMITLV_GET_STRUCT_TLVLEN
6853 (wmi_extscan_stop_cmd_fixed_param));
6854
6855 cmd->request_id = pstopcmd->request_id;
6856 cmd->vdev_id = pstopcmd->session_id;
6857
6858 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6859 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306860 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306861 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306862 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863 }
6864
Govind Singhb53420c2016-03-09 14:32:57 +05306865 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306866}
6867
6868/**
6869 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6870 * @wmi_handle: wmi handle
6871 * @pstart: scan command request params
6872 * @buf: event buffer
6873 * @buf_len: length of buffer
6874 *
6875 * This function fills individual elements of extscan request and
6876 * TLV for buckets, channel list.
6877 *
6878 * Return: CDF Status.
6879 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006880static
Govind Singhb53420c2016-03-09 14:32:57 +05306881QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306882 struct wifi_scan_cmd_req_params *pstart,
6883 wmi_buf_t *buf, int *buf_len)
6884{
6885 wmi_extscan_start_cmd_fixed_param *cmd;
6886 wmi_extscan_bucket *dest_blist;
6887 wmi_extscan_bucket_channel *dest_clist;
6888 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6889 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6890 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6891
6892 uint8_t *buf_ptr;
6893 int i, k, count = 0;
6894 int len = sizeof(*cmd);
6895 int nbuckets = pstart->numBuckets;
6896 int nchannels = 0;
6897
6898 /* These TLV's are are NULL by default */
6899 uint32_t ie_len_with_pad = 0;
6900 int num_ssid = 0;
6901 int num_bssid = 0;
6902 int ie_len = 0;
6903
6904 uint32_t base_period = pstart->basePeriod;
6905
6906 /* TLV placeholder for ssid_list (NULL) */
6907 len += WMI_TLV_HDR_SIZE;
6908 len += num_ssid * sizeof(wmi_ssid);
6909
6910 /* TLV placeholder for bssid_list (NULL) */
6911 len += WMI_TLV_HDR_SIZE;
6912 len += num_bssid * sizeof(wmi_mac_addr);
6913
6914 /* TLV placeholder for ie_data (NULL) */
6915 len += WMI_TLV_HDR_SIZE;
6916 len += ie_len * sizeof(uint32_t);
6917
6918 /* TLV placeholder for bucket */
6919 len += WMI_TLV_HDR_SIZE;
6920 len += nbuckets * sizeof(wmi_extscan_bucket);
6921
6922 /* TLV channel placeholder */
6923 len += WMI_TLV_HDR_SIZE;
6924 for (i = 0; i < nbuckets; i++) {
6925 nchannels += src_bucket->numChannels;
6926 src_bucket++;
6927 }
6928
Govind Singhb53420c2016-03-09 14:32:57 +05306929 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306930 __func__, nbuckets, nchannels);
6931 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6932 /* Allocate the memory */
6933 *buf = wmi_buf_alloc(wmi_handle, len);
6934 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306935 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306936 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306937 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306938 }
6939 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6940 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6941 WMITLV_SET_HDR(&cmd->tlv_header,
6942 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6943 WMITLV_GET_STRUCT_TLVLEN
6944 (wmi_extscan_start_cmd_fixed_param));
6945
6946 cmd->request_id = pstart->requestId;
6947 cmd->vdev_id = pstart->sessionId;
6948 cmd->base_period = pstart->basePeriod;
6949 cmd->num_buckets = nbuckets;
6950 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306951 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306952 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306953 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306954 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306955#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306956 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6957 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306958 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6959 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6960#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6962
6963 /* The max dwell time is retrieved from the first channel
6964 * of the first bucket and kept common for all channels.
6965 */
6966 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6967 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6968 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6969 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6970 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6971 cmd->max_table_usage = pstart->report_threshold_percent;
6972 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6973
6974 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306975 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306976 cmd->probe_delay = 0;
6977 cmd->probe_spacing_time = 0;
6978 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306979 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6980 WMI_SCAN_ADD_CCK_RATES |
6981 WMI_SCAN_ADD_OFDM_RATES |
6982 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6983 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306984 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6985 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306986 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306987 cmd->num_ssids = 0;
6988 cmd->num_bssid = 0;
6989 cmd->ie_len = 0;
6990 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6991 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6992
6993 buf_ptr += sizeof(*cmd);
6994 WMITLV_SET_HDR(buf_ptr,
6995 WMITLV_TAG_ARRAY_FIXED_STRUC,
6996 num_ssid * sizeof(wmi_ssid));
6997 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6998
6999 WMITLV_SET_HDR(buf_ptr,
7000 WMITLV_TAG_ARRAY_FIXED_STRUC,
7001 num_bssid * sizeof(wmi_mac_addr));
7002 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7003
7004 ie_len_with_pad = 0;
7005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7006 ie_len_with_pad);
7007 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7008
7009 WMITLV_SET_HDR(buf_ptr,
7010 WMITLV_TAG_ARRAY_STRUC,
7011 nbuckets * sizeof(wmi_extscan_bucket));
7012 dest_blist = (wmi_extscan_bucket *)
7013 (buf_ptr + WMI_TLV_HDR_SIZE);
7014 src_bucket = pstart->buckets;
7015
7016 /* Retrieve scanning information from each bucket and
7017 * channels and send it to the target
7018 */
7019 for (i = 0; i < nbuckets; i++) {
7020 WMITLV_SET_HDR(dest_blist,
7021 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7022 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7023
7024 dest_blist->bucket_id = src_bucket->bucket;
7025 dest_blist->base_period_multiplier =
7026 src_bucket->period / base_period;
7027 dest_blist->min_period = src_bucket->period;
7028 dest_blist->max_period = src_bucket->max_period;
7029 dest_blist->exp_backoff = src_bucket->exponent;
7030 dest_blist->exp_max_step_count = src_bucket->step_count;
7031 dest_blist->channel_band = src_bucket->band;
7032 dest_blist->num_channels = src_bucket->numChannels;
7033 dest_blist->notify_extscan_events = 0;
7034
7035 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7036 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007037 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7038 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307039
7040 if (src_bucket->reportEvents &
7041 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7042 dest_blist->forwarding_flags =
7043 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7044 dest_blist->notify_extscan_events |=
7045 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7046 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7047 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7048 } else {
7049 dest_blist->forwarding_flags =
7050 WMI_EXTSCAN_NO_FORWARDING;
7051 }
7052
7053 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7054 dest_blist->configuration_flags = 0;
7055 else
7056 dest_blist->configuration_flags =
7057 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7058
Govind Singhb53420c2016-03-09 14:32:57 +05307059 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307060 __func__, dest_blist->notify_extscan_events,
7061 dest_blist->configuration_flags,
7062 dest_blist->forwarding_flags);
7063
7064 dest_blist->min_dwell_time_active =
7065 src_bucket->min_dwell_time_active;
7066 dest_blist->max_dwell_time_active =
7067 src_bucket->max_dwell_time_active;
7068 dest_blist->min_dwell_time_passive =
7069 src_bucket->min_dwell_time_passive;
7070 dest_blist->max_dwell_time_passive =
7071 src_bucket->max_dwell_time_passive;
7072 src_channel = src_bucket->channels;
7073
7074 /* save the channel info to later populate
7075 * the channel TLV
7076 */
7077 for (k = 0; k < src_bucket->numChannels; k++) {
7078 save_channel[count++].channel = src_channel->channel;
7079 src_channel++;
7080 }
7081 dest_blist++;
7082 src_bucket++;
7083 }
7084 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7085 WMITLV_SET_HDR(buf_ptr,
7086 WMITLV_TAG_ARRAY_STRUC,
7087 nchannels * sizeof(wmi_extscan_bucket_channel));
7088 dest_clist = (wmi_extscan_bucket_channel *)
7089 (buf_ptr + WMI_TLV_HDR_SIZE);
7090
7091 /* Active or passive scan is based on the bucket dwell time
7092 * and channel specific active,passive scans are not
7093 * supported yet
7094 */
7095 for (i = 0; i < nchannels; i++) {
7096 WMITLV_SET_HDR(dest_clist,
7097 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7098 WMITLV_GET_STRUCT_TLVLEN
7099 (wmi_extscan_bucket_channel));
7100 dest_clist->channel = save_channel[i].channel;
7101 dest_clist++;
7102 }
7103 buf_ptr += WMI_TLV_HDR_SIZE +
7104 (nchannels * sizeof(wmi_extscan_bucket_channel));
7105 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307106 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307107}
7108
7109/**
7110 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7111 * @wmi_handle: wmi handle
7112 * @pstart: scan command request params
7113 *
7114 * This function sends start extscan request to fw.
7115 *
7116 * Return: CDF Status.
7117 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307118static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119 struct wifi_scan_cmd_req_params *pstart)
7120{
Govind Singhb53420c2016-03-09 14:32:57 +05307121 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307122 wmi_buf_t buf;
7123 int len;
7124
7125 /* Fill individual elements of extscan request and
7126 * TLV for buckets, channel list.
7127 */
Govind Singhb53420c2016-03-09 14:32:57 +05307128 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307129 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307130 if (qdf_status != QDF_STATUS_SUCCESS) {
7131 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7132 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307133 }
7134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307135 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307136 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307137 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307138 }
7139 if (wmi_unified_cmd_send(wmi_handle, buf,
7140 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307141 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307142 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307143 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307144 }
7145
Govind Singhb53420c2016-03-09 14:32:57 +05307146 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307147}
7148
7149/**
7150 * send_plm_stop_cmd_tlv() - plm stop request
7151 * @wmi_handle: wmi handle
7152 * @plm: plm request parameters
7153 *
7154 * This function request FW to stop PLM.
7155 *
7156 * Return: CDF status
7157 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307158static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307159 const struct plm_req_params *plm)
7160{
7161 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7162 int32_t len;
7163 wmi_buf_t buf;
7164 uint8_t *buf_ptr;
7165 int ret;
7166
7167 len = sizeof(*cmd);
7168 buf = wmi_buf_alloc(wmi_handle, len);
7169 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307170 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7171 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307172 }
7173
7174 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7175
7176 buf_ptr = (uint8_t *) cmd;
7177
7178 WMITLV_SET_HDR(&cmd->tlv_header,
7179 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7180 WMITLV_GET_STRUCT_TLVLEN
7181 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7182
7183 cmd->vdev_id = plm->session_id;
7184
7185 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307186 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307187
7188 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7189 WMI_VDEV_PLMREQ_STOP_CMDID);
7190 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307191 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307192 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307193 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307194 }
7195
Govind Singhb53420c2016-03-09 14:32:57 +05307196 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307197}
7198
7199/**
7200 * send_plm_start_cmd_tlv() - plm start request
7201 * @wmi_handle: wmi handle
7202 * @plm: plm request parameters
7203 *
7204 * This function request FW to start PLM.
7205 *
7206 * Return: CDF status
7207 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307208static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209 const struct plm_req_params *plm,
7210 uint32_t *gchannel_list)
7211{
7212 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7213 uint32_t *channel_list;
7214 int32_t len;
7215 wmi_buf_t buf;
7216 uint8_t *buf_ptr;
7217 uint8_t count;
7218 int ret;
7219
7220 /* TLV place holder for channel_list */
7221 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7222 len += sizeof(uint32_t) * plm->plm_num_ch;
7223
7224 buf = wmi_buf_alloc(wmi_handle, len);
7225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307226 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7227 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307228 }
7229 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7230
7231 buf_ptr = (uint8_t *) cmd;
7232
7233 WMITLV_SET_HDR(&cmd->tlv_header,
7234 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7235 WMITLV_GET_STRUCT_TLVLEN
7236 (wmi_vdev_plmreq_start_cmd_fixed_param));
7237
7238 cmd->vdev_id = plm->session_id;
7239
7240 cmd->meas_token = plm->meas_token;
7241 cmd->dialog_token = plm->diag_token;
7242 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307243 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307244 cmd->off_duration = plm->meas_duration;
7245 cmd->burst_cycle = plm->burst_len;
7246 cmd->tx_power = plm->desired_tx_pwr;
7247 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7248 cmd->num_chans = plm->plm_num_ch;
7249
7250 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7251
Govind Singhb53420c2016-03-09 14:32:57 +05307252 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7253 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7254 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7255 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7256 WMI_LOGD("off_duration: %d", cmd->off_duration);
7257 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7258 WMI_LOGD("tx_power: %d", cmd->tx_power);
7259 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307260
7261 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7262 (cmd->num_chans * sizeof(uint32_t)));
7263
7264 buf_ptr += WMI_TLV_HDR_SIZE;
7265 if (cmd->num_chans) {
7266 channel_list = (uint32_t *) buf_ptr;
7267 for (count = 0; count < cmd->num_chans; count++) {
7268 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307269 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270 channel_list[count] =
7271 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307272 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307273 }
7274 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7275 }
7276
7277 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7278 WMI_VDEV_PLMREQ_START_CMDID);
7279 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307280 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307282 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307283 }
7284
Govind Singhb53420c2016-03-09 14:32:57 +05307285 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307286}
7287
7288/**
7289 * send_pno_stop_cmd_tlv() - PNO stop request
7290 * @wmi_handle: wmi handle
7291 * @vdev_id: vdev id
7292 *
7293 * This function request FW to stop ongoing PNO operation.
7294 *
7295 * Return: CDF status
7296 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307297static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307298{
7299 wmi_nlo_config_cmd_fixed_param *cmd;
7300 int32_t len = sizeof(*cmd);
7301 wmi_buf_t buf;
7302 uint8_t *buf_ptr;
7303 int ret;
7304
7305 /*
7306 * TLV place holder for array of structures nlo_configured_parameters
7307 * TLV place holder for array of uint32_t channel_list
7308 * TLV place holder for chnl prediction cfg
7309 */
7310 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7311 buf = wmi_buf_alloc(wmi_handle, len);
7312 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307313 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7314 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307315 }
7316
7317 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7318 buf_ptr = (uint8_t *) cmd;
7319
7320 WMITLV_SET_HDR(&cmd->tlv_header,
7321 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7322 WMITLV_GET_STRUCT_TLVLEN
7323 (wmi_nlo_config_cmd_fixed_param));
7324
7325 cmd->vdev_id = vdev_id;
7326 cmd->flags = WMI_NLO_CONFIG_STOP;
7327 buf_ptr += sizeof(*cmd);
7328
7329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7330 buf_ptr += WMI_TLV_HDR_SIZE;
7331
7332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7333 buf_ptr += WMI_TLV_HDR_SIZE;
7334
7335 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7336 buf_ptr += WMI_TLV_HDR_SIZE;
7337
7338
7339 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7340 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7341 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307342 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307343 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307344 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307345 }
7346
Govind Singhb53420c2016-03-09 14:32:57 +05307347 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307348}
7349
7350/**
Govind Singhccb0c272016-04-01 16:30:08 +05307351 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7352 * @buf_ptr: Buffer passed by upper layers
7353 * @pno: Buffer to be sent to the firmware
7354 *
7355 * Copy the PNO Channel prediction configuration parameters
7356 * passed by the upper layers to a WMI format TLV and send it
7357 * down to the firmware.
7358 *
7359 * Return: None
7360 */
7361static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7362 struct pno_scan_req_params *pno)
7363{
7364 nlo_channel_prediction_cfg *channel_prediction_cfg =
7365 (nlo_channel_prediction_cfg *) buf_ptr;
7366 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7367 WMITLV_TAG_ARRAY_BYTE,
7368 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307369#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307370 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7371 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7372 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7373 channel_prediction_cfg->full_scan_period_ms =
7374 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307375#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307376 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7377 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7378 channel_prediction_cfg->enable,
7379 channel_prediction_cfg->top_k_num,
7380 channel_prediction_cfg->stationary_threshold,
7381 channel_prediction_cfg->full_scan_period_ms);
7382}
7383
7384/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007385 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7386 * @wmi_handle: wmi handle
7387 * @params: configuration parameters
7388 *
7389 * Return: QDF_STATUS
7390 */
7391static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7392 struct nlo_mawc_params *params)
7393{
7394 wmi_buf_t buf = NULL;
7395 QDF_STATUS status;
7396 int len;
7397 uint8_t *buf_ptr;
7398 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7399
7400 len = sizeof(*wmi_nlo_mawc_params);
7401 buf = wmi_buf_alloc(wmi_handle, len);
7402 if (!buf) {
7403 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7404 return QDF_STATUS_E_NOMEM;
7405 }
7406
7407 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7408 wmi_nlo_mawc_params =
7409 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7410 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7411 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7412 WMITLV_GET_STRUCT_TLVLEN
7413 (wmi_nlo_configure_mawc_cmd_fixed_param));
7414 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7415 if (params->enable)
7416 wmi_nlo_mawc_params->enable = 1;
7417 else
7418 wmi_nlo_mawc_params->enable = 0;
7419 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7420 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7421 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
7422
7423 status = wmi_unified_cmd_send(wmi_handle, buf,
7424 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7425 if (QDF_IS_STATUS_ERROR(status)) {
7426 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7427 status);
7428 wmi_buf_free(buf);
7429 return QDF_STATUS_E_FAILURE;
7430 }
7431 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7432 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7433 wmi_nlo_mawc_params->exp_backoff_ratio,
7434 wmi_nlo_mawc_params->init_scan_interval,
7435 wmi_nlo_mawc_params->max_scan_interval);
7436
7437 return QDF_STATUS_SUCCESS;
7438}
7439
7440/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307441 * send_pno_start_cmd_tlv() - PNO start request
7442 * @wmi_handle: wmi handle
7443 * @pno: PNO request
7444 *
7445 * This function request FW to start PNO request.
7446 * Request: CDF status
7447 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307448static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307449 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307450{
7451 wmi_nlo_config_cmd_fixed_param *cmd;
7452 nlo_configured_parameters *nlo_list;
7453 uint32_t *channel_list;
7454 int32_t len;
7455 wmi_buf_t buf;
7456 uint8_t *buf_ptr;
7457 uint8_t i;
7458 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307459 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307460
7461 /*
7462 * TLV place holder for array nlo_configured_parameters(nlo_list)
7463 * TLV place holder for array of uint32_t channel_list
7464 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307465 * TLV place holder for array of wmi_vendor_oui
Govind Singh4eacd2b2016-03-07 14:24:22 +05307466 */
7467 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307468 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
7469 WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307470
Abhishek Singh5987b632017-03-03 22:09:07 +05307471 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307472 WMI_NLO_MAX_CHAN);
7473 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307474 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307475 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307476 len += sizeof(enlo_candidate_score_params);
7477 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307478
7479 buf = wmi_buf_alloc(wmi_handle, len);
7480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307481 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7482 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307483 }
7484
7485 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7486
7487 buf_ptr = (uint8_t *) cmd;
7488 WMITLV_SET_HDR(&cmd->tlv_header,
7489 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7490 WMITLV_GET_STRUCT_TLVLEN
7491 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307492 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307493 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7494
Govind Singh87542482016-06-08 19:40:11 +05307495#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307496 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307497 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307498#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307499 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307500 cmd->active_dwell_time = pno->active_dwell_time;
7501 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307502
7503 /* Copy scan interval */
7504 cmd->fast_scan_period = pno->fast_scan_period;
7505 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007506 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307507 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007508 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307509 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307510 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307511 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307512
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307513 /* mac randomization attributes */
7514 if (pno->scan_random.randomize) {
7515 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7516 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7517 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7518 pno->scan_random.mac_mask,
7519 &cmd->mac_addr,
7520 &cmd->mac_mask);
7521 }
7522
Govind Singh4eacd2b2016-03-07 14:24:22 +05307523 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7524
Abhishek Singh5987b632017-03-03 22:09:07 +05307525 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307526 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7528 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7529 buf_ptr += WMI_TLV_HDR_SIZE;
7530
7531 nlo_list = (nlo_configured_parameters *) buf_ptr;
7532 for (i = 0; i < cmd->no_of_ssids; i++) {
7533 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7534 WMITLV_TAG_ARRAY_BYTE,
7535 WMITLV_GET_STRUCT_TLVLEN
7536 (nlo_configured_parameters));
7537 /* Copy ssid and it's length */
7538 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307539 nlo_list[i].ssid.ssid.ssid_len =
7540 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307541 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307542 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307543 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307544 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307545 nlo_list[i].ssid.ssid.ssid_len,
7546 (char *)nlo_list[i].ssid.ssid.ssid,
7547 nlo_list[i].ssid.ssid.ssid_len);
7548
7549 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307550 if (pno->networks_list[i].rssi_thresh &&
7551 pno->networks_list[i].rssi_thresh >
7552 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307553 nlo_list[i].rssi_cond.valid = true;
7554 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307555 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307556 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307557 nlo_list[i].rssi_cond.rssi);
7558 }
7559 nlo_list[i].bcast_nw_type.valid = true;
7560 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307561 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007562 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307563 nlo_list[i].bcast_nw_type.bcast_nw_type);
7564 }
7565 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7566
7567 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307568 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307569 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307570 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307571 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7572 (cmd->num_of_channels * sizeof(uint32_t)));
7573 buf_ptr += WMI_TLV_HDR_SIZE;
7574
7575 channel_list = (uint32_t *) buf_ptr;
7576 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307577 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307578
7579 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307580 channel_list[i] =
7581 wlan_chan_to_freq(pno->
7582 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307583
Govind Singhb53420c2016-03-09 14:32:57 +05307584 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307585 }
7586 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7588 sizeof(nlo_channel_prediction_cfg));
7589 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307590 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307591 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307592 /** TODO: Discrete firmware doesn't have command/option to configure
7593 * App IE which comes from wpa_supplicant as of part PNO start request.
7594 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7596 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7597 buf_ptr += sizeof(enlo_candidate_score_params);
7598
7599 if (ie_whitelist->white_list) {
7600 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7601 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7602 &cmd->num_vendor_oui,
7603 ie_whitelist);
7604 }
7605
7606 /* ie white list */
7607 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7608 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7609 buf_ptr += WMI_TLV_HDR_SIZE;
7610 if (cmd->num_vendor_oui != 0) {
7611 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7612 ie_whitelist->voui);
7613 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7614 }
7615
Govind Singh4eacd2b2016-03-07 14:24:22 +05307616 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7617 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7618 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307619 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307620 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307621 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307622 }
7623
Govind Singhb53420c2016-03-09 14:32:57 +05307624 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307625}
7626
7627/* send_set_ric_req_cmd_tlv() - set ric request element
7628 * @wmi_handle: wmi handle
7629 * @msg: message
7630 * @is_add_ts: is addts required
7631 *
7632 * This function sets ric request element for 11r roaming.
7633 *
7634 * Return: CDF status
7635 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307636static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307637 void *msg, uint8_t is_add_ts)
7638{
7639 wmi_ric_request_fixed_param *cmd;
7640 wmi_ric_tspec *tspec_param;
7641 wmi_buf_t buf;
7642 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307643 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307644 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7645 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7646
7647 buf = wmi_buf_alloc(wmi_handle, len);
7648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307649 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7650 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307651 }
7652
7653 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7654
7655 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7656 WMITLV_SET_HDR(&cmd->tlv_header,
7657 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7658 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7659 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007660 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307661 else
7662 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7663 cmd->num_ric_request = 1;
7664 cmd->is_add_ric = is_add_ts;
7665
7666 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7668
7669 buf_ptr += WMI_TLV_HDR_SIZE;
7670 tspec_param = (wmi_ric_tspec *) buf_ptr;
7671 WMITLV_SET_HDR(&tspec_param->tlv_header,
7672 WMITLV_TAG_STRUC_wmi_ric_tspec,
7673 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7674
7675 if (is_add_ts)
7676 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307677#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307678 else
7679 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307680#endif
7681 if (ptspecIE) {
7682 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307683#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307684 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7685 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307686#else
Govind Singh87542482016-06-08 19:40:11 +05307687 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7688 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307689#endif /* ANI_LITTLE_BIT_ENDIAN */
7690
Govind Singh87542482016-06-08 19:40:11 +05307691 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7692 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7693 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7694 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7695 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7696 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7697 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7698 tspec_param->min_data_rate = ptspecIE->minDataRate;
7699 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7700 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7701 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7702 tspec_param->delay_bound = ptspecIE->delayBound;
7703 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7704 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7705 tspec_param->medium_time = 0;
7706 }
Govind Singhb53420c2016-03-09 14:32:57 +05307707 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307708
7709 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7710 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307711 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307712 __func__);
7713 if (is_add_ts)
7714 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307715 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307716 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307717 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307718 }
7719
Govind Singhb53420c2016-03-09 14:32:57 +05307720 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307721}
7722
7723/**
7724 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7725 * @wmi_handle: wmi handle
7726 * @clear_req: ll stats clear request command params
7727 *
Govind Singhb53420c2016-03-09 14:32:57 +05307728 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307729 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307730static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307731 const struct ll_stats_clear_params *clear_req,
7732 uint8_t addr[IEEE80211_ADDR_LEN])
7733{
7734 wmi_clear_link_stats_cmd_fixed_param *cmd;
7735 int32_t len;
7736 wmi_buf_t buf;
7737 uint8_t *buf_ptr;
7738 int ret;
7739
7740 len = sizeof(*cmd);
7741 buf = wmi_buf_alloc(wmi_handle, len);
7742
7743 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307744 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7745 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307746 }
7747
7748 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307749 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307750 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7751
7752 WMITLV_SET_HDR(&cmd->tlv_header,
7753 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7754 WMITLV_GET_STRUCT_TLVLEN
7755 (wmi_clear_link_stats_cmd_fixed_param));
7756
7757 cmd->stop_stats_collection_req = clear_req->stop_req;
7758 cmd->vdev_id = clear_req->sta_id;
7759 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7760
7761 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7762 &cmd->peer_macaddr);
7763
Govind Singhb53420c2016-03-09 14:32:57 +05307764 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7765 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7766 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7767 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7768 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307769 cmd->peer_macaddr); */
7770
7771 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7772 WMI_CLEAR_LINK_STATS_CMDID);
7773 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307774 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307775 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307776 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307777 }
7778
Govind Singhb53420c2016-03-09 14:32:57 +05307779 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7780 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307781}
7782
7783/**
7784 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7785 * @wmi_handle: wmi handle
7786 * @setReq: ll stats set request command params
7787 *
Govind Singhb53420c2016-03-09 14:32:57 +05307788 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307789 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307790static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307791 const struct ll_stats_set_params *set_req)
7792{
7793 wmi_start_link_stats_cmd_fixed_param *cmd;
7794 int32_t len;
7795 wmi_buf_t buf;
7796 uint8_t *buf_ptr;
7797 int ret;
7798
7799 len = sizeof(*cmd);
7800 buf = wmi_buf_alloc(wmi_handle, len);
7801
7802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307803 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7804 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307805 }
7806
7807 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307808 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307809 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7810
7811 WMITLV_SET_HDR(&cmd->tlv_header,
7812 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7813 WMITLV_GET_STRUCT_TLVLEN
7814 (wmi_start_link_stats_cmd_fixed_param));
7815
7816 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7817 cmd->aggressive_statistics_gathering =
7818 set_req->aggressive_statistics_gathering;
7819
Govind Singhb53420c2016-03-09 14:32:57 +05307820 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7821 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7822 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307823
7824 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7825 WMI_START_LINK_STATS_CMDID);
7826 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307827 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307828 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307829 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307830 }
7831
Govind Singhb53420c2016-03-09 14:32:57 +05307832 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307833}
7834
7835/**
7836 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7837 * @wmi_handle:wmi handle
7838 * @get_req:ll stats get request command params
7839 * @addr: mac address
7840 *
Govind Singhb53420c2016-03-09 14:32:57 +05307841 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307842 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307843static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307844 const struct ll_stats_get_params *get_req,
7845 uint8_t addr[IEEE80211_ADDR_LEN])
7846{
7847 wmi_request_link_stats_cmd_fixed_param *cmd;
7848 int32_t len;
7849 wmi_buf_t buf;
7850 uint8_t *buf_ptr;
7851 int ret;
7852
7853 len = sizeof(*cmd);
7854 buf = wmi_buf_alloc(wmi_handle, len);
7855
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307856 if (!buf) {
7857 WMI_LOGE("%s: buf allocation failed", __func__);
7858 return QDF_STATUS_E_NOMEM;
7859 }
7860
Govind Singh4eacd2b2016-03-07 14:24:22 +05307861 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307862 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307863 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7864
7865 WMITLV_SET_HDR(&cmd->tlv_header,
7866 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7867 WMITLV_GET_STRUCT_TLVLEN
7868 (wmi_request_link_stats_cmd_fixed_param));
7869
7870 cmd->request_id = get_req->req_id;
7871 cmd->stats_type = get_req->param_id_mask;
7872 cmd->vdev_id = get_req->sta_id;
7873
7874 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7875 &cmd->peer_macaddr);
7876
Govind Singhb53420c2016-03-09 14:32:57 +05307877 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007878 WMI_LOGD("Request ID : %u", cmd->request_id);
7879 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307880 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7881 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307882
7883 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7884 WMI_REQUEST_LINK_STATS_CMDID);
7885 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307886 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307887 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307888 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307889 }
7890
Govind Singhb53420c2016-03-09 14:32:57 +05307891 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307892}
7893
7894/**
7895 * send_get_stats_cmd_tlv() - get stats request
7896 * @wmi_handle: wmi handle
7897 * @get_stats_param: stats params
7898 * @addr: mac address
7899 *
7900 * Return: CDF status
7901 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307902static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307903 struct pe_stats_req *get_stats_param,
7904 uint8_t addr[IEEE80211_ADDR_LEN])
7905{
7906 wmi_buf_t buf;
7907 wmi_request_stats_cmd_fixed_param *cmd;
7908 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7909
7910 buf = wmi_buf_alloc(wmi_handle, len);
7911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307912 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7913 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307914 }
7915
7916
7917 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7918 WMITLV_SET_HDR(&cmd->tlv_header,
7919 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7920 WMITLV_GET_STRUCT_TLVLEN
7921 (wmi_request_stats_cmd_fixed_param));
Gurumoorthi Gnanasambandhan4aec3672017-07-10 11:55:23 +05307922 cmd->stats_id = get_stats_param->stats_mask;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307923 cmd->vdev_id = get_stats_param->session_id;
7924 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307925 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307926 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7927 WMI_REQUEST_STATS_CMDID)) {
7928
Govind Singhb53420c2016-03-09 14:32:57 +05307929 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307930 __func__);
7931 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307932 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307933 }
7934
Govind Singhb53420c2016-03-09 14:32:57 +05307935 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307936
7937}
7938
Govind Singh20c5dac2016-03-07 15:33:31 +05307939/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307940 * send_congestion_cmd_tlv() - send request to fw to get CCA
7941 * @wmi_handle: wmi handle
7942 * @vdev_id: vdev id
7943 *
7944 * Return: CDF status
7945 */
7946static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7947 A_UINT8 vdev_id)
7948{
7949 wmi_buf_t buf;
7950 wmi_request_stats_cmd_fixed_param *cmd;
7951 uint8_t len;
7952 uint8_t *buf_ptr;
7953
7954 len = sizeof(*cmd);
7955 buf = wmi_buf_alloc(wmi_handle, len);
7956 if (!buf) {
7957 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7958 return QDF_STATUS_E_FAILURE;
7959 }
7960
7961 buf_ptr = wmi_buf_data(buf);
7962 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7963 WMITLV_SET_HDR(&cmd->tlv_header,
7964 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7965 WMITLV_GET_STRUCT_TLVLEN
7966 (wmi_request_stats_cmd_fixed_param));
7967
7968 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7969 cmd->vdev_id = vdev_id;
7970 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7971 cmd->vdev_id, cmd->stats_id);
7972
7973 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7974 WMI_REQUEST_STATS_CMDID)) {
7975 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7976 __func__);
7977 wmi_buf_free(buf);
7978 return QDF_STATUS_E_FAILURE;
7979 }
7980
7981 return QDF_STATUS_SUCCESS;
7982}
7983
7984/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307985 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7986 * @wmi_handle: wmi handle
7987 * @rssi_req: get RSSI request
7988 *
7989 * Return: CDF status
7990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307991static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307992{
7993 wmi_buf_t buf;
7994 wmi_request_stats_cmd_fixed_param *cmd;
7995 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7996
7997 buf = wmi_buf_alloc(wmi_handle, len);
7998 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307999 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8000 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308001 }
8002
8003 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8004 WMITLV_SET_HDR(&cmd->tlv_header,
8005 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8006 WMITLV_GET_STRUCT_TLVLEN
8007 (wmi_request_stats_cmd_fixed_param));
8008 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8009 if (wmi_unified_cmd_send
8010 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308011 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308012 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308013 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308014 }
8015
Govind Singhb53420c2016-03-09 14:32:57 +05308016 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308017}
8018
8019/**
8020 * send_snr_cmd_tlv() - get RSSI from fw
8021 * @wmi_handle: wmi handle
8022 * @vdev_id: vdev id
8023 *
8024 * Return: CDF status
8025 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308026static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308027{
8028 wmi_buf_t buf;
8029 wmi_request_stats_cmd_fixed_param *cmd;
8030 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8031
8032 buf = wmi_buf_alloc(wmi_handle, len);
8033 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308034 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8035 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308036 }
8037
8038 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8039 cmd->vdev_id = vdev_id;
8040
8041 WMITLV_SET_HDR(&cmd->tlv_header,
8042 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8043 WMITLV_GET_STRUCT_TLVLEN
8044 (wmi_request_stats_cmd_fixed_param));
8045 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8046 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8047 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308048 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308049 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308050 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308051 }
8052
Govind Singhb53420c2016-03-09 14:32:57 +05308053 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308054}
8055
8056/**
8057 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8058 * @wmi_handle: wmi handle
8059 * @link_status: get link params
8060 *
8061 * Return: CDF status
8062 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308063static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308064 struct link_status_params *link_status)
8065{
8066 wmi_buf_t buf;
8067 wmi_request_stats_cmd_fixed_param *cmd;
8068 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8069
8070 buf = wmi_buf_alloc(wmi_handle, len);
8071 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308072 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8073 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308074 }
8075
8076 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8077 WMITLV_SET_HDR(&cmd->tlv_header,
8078 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8079 WMITLV_GET_STRUCT_TLVLEN
8080 (wmi_request_stats_cmd_fixed_param));
8081 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8082 cmd->vdev_id = link_status->session_id;
8083 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8084 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308085 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308086 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308087 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308088 }
8089
Govind Singhb53420c2016-03-09 14:32:57 +05308090 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308091}
8092
Govind Singh20c5dac2016-03-07 15:33:31 +05308093/**
8094 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8095 * @wmi_handle: wmi handle
8096 * @ta_dhcp_ind: DHCP indication parameter
8097 *
8098 * Return: CDF Status
8099 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308100static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8102{
Govind Singh67922e82016-04-01 16:48:57 +05308103 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308104 wmi_buf_t buf = NULL;
8105 uint8_t *buf_ptr;
8106 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8107 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8108
8109
8110 buf = wmi_buf_alloc(wmi_handle, len);
8111 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308112 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8113 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308114 }
8115
8116 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8117 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8118 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8119 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8120 WMITLV_GET_STRUCT_TLVLEN
8121 (wmi_peer_set_param_cmd_fixed_param));
8122
8123 /* fill in values */
8124 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8125 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8126 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308127 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308128 &ta_dhcp_ind->peer_macaddr,
8129 sizeof(ta_dhcp_ind->peer_macaddr));
8130
8131 status = wmi_unified_cmd_send(wmi_handle, buf,
8132 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308133 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308134 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308135 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308136 wmi_buf_free(buf);
8137 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308138
Govind Singh67922e82016-04-01 16:48:57 +05308139 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308140}
8141
8142/**
8143 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8144 * @wmi_handle: wmi handle
8145 * @pLinkSpeed: link speed info
8146 *
8147 * Return: CDF status
8148 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308149static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308150 wmi_mac_addr peer_macaddr)
8151{
8152 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8153 wmi_buf_t wmi_buf;
8154 uint32_t len;
8155 uint8_t *buf_ptr;
8156
8157 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8158 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8159 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308160 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8161 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308162 }
8163 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8164
8165 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8166 WMITLV_SET_HDR(&cmd->tlv_header,
8167 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8168 WMITLV_GET_STRUCT_TLVLEN
8169 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8170
8171 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308172 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308173 &peer_macaddr,
8174 sizeof(peer_macaddr));
8175
8176
8177 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8178 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308179 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308180 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308181 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308182 }
Govind Singhb53420c2016-03-09 14:32:57 +05308183 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308184}
8185
8186/**
8187 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8188 * @wmi_handle: wmi handler
8189 * @egap_params: pointer to egap_params
8190 *
8191 * Return: 0 for success, otherwise appropriate error code
8192 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308193static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308194 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
8195{
8196 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8197 wmi_buf_t buf;
8198 int32_t err;
8199
8200 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308202 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8203 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308204 }
8205 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8206 WMITLV_SET_HDR(&cmd->tlv_header,
8207 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8208 WMITLV_GET_STRUCT_TLVLEN(
8209 wmi_ap_ps_egap_param_cmd_fixed_param));
8210
8211 cmd->enable = egap_params->enable;
8212 cmd->inactivity_time = egap_params->inactivity_time;
8213 cmd->wait_time = egap_params->wait_time;
8214 cmd->flags = egap_params->flags;
8215 err = wmi_unified_cmd_send(wmi_handle, buf,
8216 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8217 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308218 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308219 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308220 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308221 }
8222
Govind Singhb53420c2016-03-09 14:32:57 +05308223 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308224}
8225
8226/**
8227 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8228 * @wmi_handl: wmi handle
8229 * @cmd: Profiling command index
8230 * @value1: parameter1 value
8231 * @value2: parameter2 value
8232 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308233 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308234 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308235static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308236 uint32_t cmd, uint32_t value1, uint32_t value2)
8237{
8238 wmi_buf_t buf;
8239 int32_t len = 0;
8240 int ret;
8241 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8242 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8243 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8244 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8245
8246 switch (cmd) {
8247 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8248 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8249 buf = wmi_buf_alloc(wmi_handle, len);
8250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308251 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308252 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308253 }
8254 prof_trig_cmd =
8255 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8256 wmi_buf_data(buf);
8257 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8258 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8259 WMITLV_GET_STRUCT_TLVLEN
8260 (wmi_wlan_profile_trigger_cmd_fixed_param));
8261 prof_trig_cmd->enable = value1;
8262 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8263 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8264 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308265 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308266 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308267 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308268 return ret;
8269 }
8270 break;
8271
8272 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8273 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8274 buf = wmi_buf_alloc(wmi_handle, len);
8275 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308276 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308277 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308278 }
8279 profile_getdata_cmd =
8280 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8281 wmi_buf_data(buf);
8282 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8283 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8284 WMITLV_GET_STRUCT_TLVLEN
8285 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8286 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8287 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8288 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308289 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308290 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308291 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 return ret;
8293 }
8294 break;
8295
8296 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8297 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8298 buf = wmi_buf_alloc(wmi_handle, len);
8299 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308300 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308301 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308302 }
8303 hist_intvl_cmd =
8304 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8305 wmi_buf_data(buf);
8306 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8307 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8308 WMITLV_GET_STRUCT_TLVLEN
8309 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8310 hist_intvl_cmd->profile_id = value1;
8311 hist_intvl_cmd->value = value2;
8312 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8313 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8314 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308315 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308316 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308317 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308318 return ret;
8319 }
8320 break;
8321
8322 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8323 len =
8324 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8325 buf = wmi_buf_alloc(wmi_handle, len);
8326 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308327 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308328 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308329 }
8330 profile_enable_cmd =
8331 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8332 wmi_buf_data(buf);
8333 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8334 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8335 WMITLV_GET_STRUCT_TLVLEN
8336 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8337 profile_enable_cmd->profile_id = value1;
8338 profile_enable_cmd->enable = value2;
8339 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8340 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8341 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308342 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308343 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308344 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308345 return ret;
8346 }
8347 break;
8348
8349 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308350 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308351 break;
8352 }
8353
8354 return 0;
8355}
8356
Govind Singh20c5dac2016-03-07 15:33:31 +05308357/**
8358 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8359 * @wmi_handle: wmi handle
8360 * @vdev_id: vdev id
8361 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308362 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308363 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308364static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308365{
8366 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8367 wmi_buf_t buf;
8368 int32_t len = sizeof(*cmd);
8369
Govind Singhb53420c2016-03-09 14:32:57 +05308370 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308371 buf = wmi_buf_alloc(wmi_handle, len);
8372 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308373 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308374 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308375 }
8376 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8377 wmi_buf_data(buf);
8378 WMITLV_SET_HDR(&cmd->tlv_header,
8379 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8380 WMITLV_GET_STRUCT_TLVLEN
8381 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8382 cmd->vdev_id = vdev_id;
8383 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8384 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8385 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308386 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308387 __func__);
8388 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308389 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 }
8391
8392 return 0;
8393}
8394
8395/**
8396 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8397 * @wmi_handle: wmi handle
8398 * @vdev_id: vdev id
8399 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308400 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308401 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308402static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308403 uint8_t vdev_id)
8404{
8405 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8406 wmi_buf_t buf;
8407 int32_t len = sizeof(*cmd);
8408
Govind Singhb53420c2016-03-09 14:32:57 +05308409 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308410 buf = wmi_buf_alloc(wmi_handle, len);
8411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308412 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308413 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308414 }
8415 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8416 WMITLV_SET_HDR(&cmd->tlv_header,
8417 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8418 WMITLV_GET_STRUCT_TLVLEN
8419 (wmi_csa_offload_enable_cmd_fixed_param));
8420 cmd->vdev_id = vdev_id;
8421 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8422 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8423 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308424 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 __func__);
8426 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308427 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308428 }
8429
8430 return 0;
8431}
8432
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008433#ifdef WLAN_FEATURE_CIF_CFR
8434/**
8435 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8436 * @wmi_handle: wmi handle
8437 * @data_len: len of dma cfg req
8438 * @data: dma cfg req
8439 *
8440 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8441 */
8442static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8443 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8444{
8445 wmi_buf_t buf;
8446 uint8_t *cmd;
8447 QDF_STATUS ret;
8448
8449 WMITLV_SET_HDR(cfg,
8450 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8451 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8452
8453 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8454 if (!buf) {
8455 WMI_LOGE(FL("wmi_buf_alloc failed"));
8456 return QDF_STATUS_E_FAILURE;
8457 }
8458
8459 cmd = (uint8_t *) wmi_buf_data(buf);
8460 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8461 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8462 sizeof(*cfg));
8463 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8464 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8465 if (QDF_IS_STATUS_ERROR(ret)) {
8466 WMI_LOGE(FL(":wmi cmd send failed"));
8467 wmi_buf_free(buf);
8468 }
8469
8470 return ret;
8471}
8472#endif
8473
Govind Singh20c5dac2016-03-07 15:33:31 +05308474/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008475 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8476 * @wmi_handle: wmi handle
8477 * @start_11d_scan: 11d scan start request parameters
8478 *
8479 * This function request FW to start 11d scan.
8480 *
8481 * Return: QDF status
8482 */
8483static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8484 struct reg_start_11d_scan_req *start_11d_scan)
8485{
8486 wmi_11d_scan_start_cmd_fixed_param *cmd;
8487 int32_t len;
8488 wmi_buf_t buf;
8489 int ret;
8490
8491 len = sizeof(*cmd);
8492 buf = wmi_buf_alloc(wmi_handle, len);
8493 if (!buf) {
8494 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8495 return QDF_STATUS_E_NOMEM;
8496 }
8497
8498 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8499
8500 WMITLV_SET_HDR(&cmd->tlv_header,
8501 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8502 WMITLV_GET_STRUCT_TLVLEN
8503 (wmi_11d_scan_start_cmd_fixed_param));
8504
8505 cmd->vdev_id = start_11d_scan->vdev_id;
8506 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8507 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8508
8509 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8510
8511 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8512 WMI_11D_SCAN_START_CMDID);
8513 if (ret) {
8514 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8515 wmi_buf_free(buf);
8516 return QDF_STATUS_E_FAILURE;
8517 }
8518
8519 return QDF_STATUS_SUCCESS;
8520}
8521
8522/**
8523 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8524 * @wmi_handle: wmi handle
8525 * @start_11d_scan: 11d scan stop request parameters
8526 *
8527 * This function request FW to stop 11d scan.
8528 *
8529 * Return: QDF status
8530 */
8531static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8532 struct reg_stop_11d_scan_req *stop_11d_scan)
8533{
8534 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8535 int32_t len;
8536 wmi_buf_t buf;
8537 int ret;
8538
8539 len = sizeof(*cmd);
8540 buf = wmi_buf_alloc(wmi_handle, len);
8541 if (!buf) {
8542 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8543 return QDF_STATUS_E_NOMEM;
8544 }
8545
8546 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8547
8548 WMITLV_SET_HDR(&cmd->tlv_header,
8549 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8550 WMITLV_GET_STRUCT_TLVLEN
8551 (wmi_11d_scan_stop_cmd_fixed_param));
8552
8553 cmd->vdev_id = stop_11d_scan->vdev_id;
8554
8555 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8556
8557 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8558 WMI_11D_SCAN_STOP_CMDID);
8559 if (ret) {
8560 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8561 wmi_buf_free(buf);
8562 return QDF_STATUS_E_FAILURE;
8563 }
8564
8565 return QDF_STATUS_SUCCESS;
8566}
8567
8568/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308569 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8570 * @wmi_handle: wmi handle
8571 * @startOemDataReq: start request params
8572 *
8573 * Return: CDF status
8574 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308575static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008576 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308577 uint8_t *data)
8578{
8579 wmi_buf_t buf;
8580 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308581 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308582
8583 buf = wmi_buf_alloc(wmi_handle,
8584 (data_len + WMI_TLV_HDR_SIZE));
8585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308586 WMI_LOGE(FL("wmi_buf_alloc failed"));
8587 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308588 }
8589
8590 cmd = (uint8_t *) wmi_buf_data(buf);
8591
8592 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8593 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308594 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 data_len);
8596
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008597 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308598 data_len);
8599
8600 ret = wmi_unified_cmd_send(wmi_handle, buf,
8601 (data_len +
8602 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8603
Govind Singh67922e82016-04-01 16:48:57 +05308604 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308605 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308606 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308607 }
8608
Govind Singh67922e82016-04-01 16:48:57 +05308609 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308610}
8611
8612/**
8613 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8614 * @wmi_handle: wmi handle
8615 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8616 *
8617 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8618 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8619 * to firmware based on phyerr filtering
8620 * offload status.
8621 *
8622 * Return: 1 success, 0 failure
8623 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308624static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308625send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8626 bool dfs_phyerr_filter_offload)
8627{
8628 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8629 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8630 wmi_buf_t buf;
8631 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308632 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308633
8634
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008635 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308636 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308637 __func__);
8638 len = sizeof(*disable_phyerr_offload_cmd);
8639 buf = wmi_buf_alloc(wmi_handle, len);
8640 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308641 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308642 return 0;
8643 }
8644 disable_phyerr_offload_cmd =
8645 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8646 wmi_buf_data(buf);
8647
8648 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8649 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8650 WMITLV_GET_STRUCT_TLVLEN
8651 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8652
8653 /*
8654 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8655 * to the firmware to disable the phyerror
8656 * filtering offload.
8657 */
8658 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8659 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308660 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308661 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308662 __func__, ret);
8663 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308664 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308665 }
Govind Singhb53420c2016-03-09 14:32:57 +05308666 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308667 __func__);
8668 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308669 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308670 __func__);
8671
8672 len = sizeof(*enable_phyerr_offload_cmd);
8673 buf = wmi_buf_alloc(wmi_handle, len);
8674 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308675 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8676 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308677 }
8678
8679 enable_phyerr_offload_cmd =
8680 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8681 wmi_buf_data(buf);
8682
8683 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8684 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8685 WMITLV_GET_STRUCT_TLVLEN
8686 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8687
8688 /*
8689 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8690 * to the firmware to enable the phyerror
8691 * filtering offload.
8692 */
8693 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8694 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8695
Govind Singh67922e82016-04-01 16:48:57 +05308696 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308697 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308698 __func__, ret);
8699 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308700 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308701 }
Govind Singhb53420c2016-03-09 14:32:57 +05308702 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308703 __func__);
8704 }
8705
Govind Singhb53420c2016-03-09 14:32:57 +05308706 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308707}
8708
8709#if !defined(REMOVE_PKT_LOG)
8710/**
8711 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8712 * @wmi_handle: wmi handle
8713 * @pktlog_event: pktlog event
8714 * @cmd_id: pktlog cmd id
8715 *
8716 * Return: CDF status
8717 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308718static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308719 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308720 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308721{
8722 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8723 WMI_CMD_ID CMD_ID;
8724 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8725 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8726 int len = 0;
8727 wmi_buf_t buf;
8728
8729 PKTLOG_EVENT = pktlog_event;
8730 CMD_ID = cmd_id;
8731
8732 switch (CMD_ID) {
8733 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8734 len = sizeof(*cmd);
8735 buf = wmi_buf_alloc(wmi_handle, len);
8736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308737 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8738 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308739 }
8740 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8741 wmi_buf_data(buf);
8742 WMITLV_SET_HDR(&cmd->tlv_header,
8743 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8744 WMITLV_GET_STRUCT_TLVLEN
8745 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8746 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308747 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8748 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308749 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8750 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308751 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8752 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308753 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308754 goto wmi_send_failed;
8755 }
8756 break;
8757 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8758 len = sizeof(*disable_cmd);
8759 buf = wmi_buf_alloc(wmi_handle, len);
8760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308761 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8762 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308763 }
8764 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8765 wmi_buf_data(buf);
8766 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8767 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8768 WMITLV_GET_STRUCT_TLVLEN
8769 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308770 disable_cmd->pdev_id =
8771 wmi_handle->ops->convert_pdev_id_host_to_target(
8772 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308773 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8774 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308775 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308776 goto wmi_send_failed;
8777 }
8778 break;
8779 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308780 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308781 break;
8782 }
8783
Govind Singhb53420c2016-03-09 14:32:57 +05308784 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308785
8786wmi_send_failed:
8787 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308788 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308789}
8790#endif /* REMOVE_PKT_LOG */
8791
8792/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308793 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8794 * @wmi_handle: wmi handle
8795 * @ptrn_id: pattern id
8796 * @vdev_id: vdev id
8797 *
8798 * Return: CDF status
8799 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308800static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8801 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308802{
8803 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8804 wmi_buf_t buf;
8805 int32_t len;
8806 int ret;
8807
8808 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8809
8810
8811 buf = wmi_buf_alloc(wmi_handle, len);
8812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308813 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8814 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 }
8816
8817 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8818
8819 WMITLV_SET_HDR(&cmd->tlv_header,
8820 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8821 WMITLV_GET_STRUCT_TLVLEN(
8822 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8823 cmd->vdev_id = vdev_id;
8824 cmd->pattern_id = ptrn_id;
8825 cmd->pattern_type = WOW_BITMAP_PATTERN;
8826
Govind Singhb53420c2016-03-09 14:32:57 +05308827 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308828 cmd->pattern_id, vdev_id);
8829
8830 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8831 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8832 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308833 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308835 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 }
8837
Govind Singhb53420c2016-03-09 14:32:57 +05308838 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308839}
8840
8841/**
8842 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8843 * @wmi_handle: wmi handle
8844 *
8845 * Sends host wakeup indication to FW. On receiving this indication,
8846 * FW will come out of WOW.
8847 *
8848 * Return: CDF status
8849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308850static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308851{
8852 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8853 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308854 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 int32_t len;
8856 int ret;
8857
8858 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8859
8860 buf = wmi_buf_alloc(wmi_handle, len);
8861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308862 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8863 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308864 }
8865
8866 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8867 wmi_buf_data(buf);
8868 WMITLV_SET_HDR(&cmd->tlv_header,
8869 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8870 WMITLV_GET_STRUCT_TLVLEN
8871 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8872
8873
8874 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8875 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8876 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308879 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308880 }
8881
Govind Singhb53420c2016-03-09 14:32:57 +05308882 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308883}
8884
8885/**
8886 * send_del_ts_cmd_tlv() - send DELTS request to fw
8887 * @wmi_handle: wmi handle
8888 * @msg: delts params
8889 *
8890 * Return: CDF status
8891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308892static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308893 uint8_t ac)
8894{
8895 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8896 wmi_buf_t buf;
8897 int32_t len = sizeof(*cmd);
8898
8899 buf = wmi_buf_alloc(wmi_handle, len);
8900 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308901 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8902 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308903 }
8904 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8905 WMITLV_SET_HDR(&cmd->tlv_header,
8906 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8907 WMITLV_GET_STRUCT_TLVLEN
8908 (wmi_vdev_wmm_delts_cmd_fixed_param));
8909 cmd->vdev_id = vdev_id;
8910 cmd->ac = ac;
8911
Govind Singhb53420c2016-03-09 14:32:57 +05308912 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308913 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8914 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8915 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308916 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308917 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308918 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308919 }
8920
Govind Singhb53420c2016-03-09 14:32:57 +05308921 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308922}
8923
8924/**
8925 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8926 * @wmi_handle: handle to wmi
8927 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8928 *
Govind Singhb53420c2016-03-09 14:32:57 +05308929 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308930 * ADD_TS requestes to firmware in loop for all the ACs with
8931 * active flow.
8932 *
8933 * Return: CDF status
8934 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308935static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308936 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8937{
8938 int i = 0;
8939 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8940 wmi_buf_t buf;
8941 int32_t len = sizeof(*cmd);
8942
8943 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8944 /* if flow in this AC is active */
8945 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8946 /*
8947 * as per implementation of wma_add_ts_req() we
8948 * are not waiting any response from firmware so
8949 * apart from sending ADDTS to firmware just send
8950 * success to upper layers
8951 */
Govind Singhb53420c2016-03-09 14:32:57 +05308952 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308953
8954 buf = wmi_buf_alloc(wmi_handle, len);
8955 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308956 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8957 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308958 }
8959 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8960 wmi_buf_data(buf);
8961 WMITLV_SET_HDR(&cmd->tlv_header,
8962 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8963 WMITLV_GET_STRUCT_TLVLEN
8964 (wmi_vdev_wmm_addts_cmd_fixed_param));
8965 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8966 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308967 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308968 traffic.userPrio);
8969 cmd->medium_time_us =
8970 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8971 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308972 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8974 cmd->medium_time_us, cmd->downgrade_type);
8975 if (wmi_unified_cmd_send
8976 (wmi_handle, buf, len,
8977 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308978 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308979 __func__);
8980 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308981 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308982 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308983 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308984 }
8985 }
8986 }
8987
Govind Singhb53420c2016-03-09 14:32:57 +05308988 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308989}
8990
8991/**
8992 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8993 * @wmi_handle: wmi handle
8994 * @msg: ADDTS params
8995 *
8996 * Return: CDF status
8997 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308998static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308999 struct add_ts_param *msg)
9000{
9001 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9002 wmi_buf_t buf;
9003 int32_t len = sizeof(*cmd);
9004
Govind Singhb53420c2016-03-09 14:32:57 +05309005 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309006
9007 buf = wmi_buf_alloc(wmi_handle, len);
9008 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309009 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9010 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309011 }
9012 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9013 WMITLV_SET_HDR(&cmd->tlv_header,
9014 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9015 WMITLV_GET_STRUCT_TLVLEN
9016 (wmi_vdev_wmm_addts_cmd_fixed_param));
9017 cmd->vdev_id = msg->sme_session_id;
9018 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9019 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9020 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309021 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309022 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9023 cmd->downgrade_type, __func__, __LINE__);
9024 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9025 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309026 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9027 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309028 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309029 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309030 }
9031
Govind Singhb53420c2016-03-09 14:32:57 +05309032 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309033}
9034
9035/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9037 * @wmi_handle: wmi handle
9038 * @pAddPeriodicTxPtrnParams: tx ptrn params
9039 *
9040 * Retrun: CDF status
9041 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309042static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309043 struct periodic_tx_pattern *
9044 pAddPeriodicTxPtrnParams,
9045 uint8_t vdev_id)
9046{
9047 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9048 wmi_buf_t wmi_buf;
9049 uint32_t len;
9050 uint8_t *buf_ptr;
9051 uint32_t ptrn_len, ptrn_len_aligned;
9052 int j;
9053
9054 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9055 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9056 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9057 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9058
9059 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9060 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309061 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9062 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309063 }
9064
9065 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9066
9067 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9068 WMITLV_SET_HDR(&cmd->tlv_header,
9069 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9070 WMITLV_GET_STRUCT_TLVLEN
9071 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9072
9073 /* Pass the pattern id to delete for the corresponding vdev id */
9074 cmd->vdev_id = vdev_id;
9075 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9076 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9077 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9078
9079 /* Pattern info */
9080 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9081 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9082 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309083 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309085 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309086
Govind Singhb53420c2016-03-09 14:32:57 +05309087 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309088 __func__, cmd->pattern_id, cmd->vdev_id);
9089
9090 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9091 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309092 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309093 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309094 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309095 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309096 }
Govind Singhb53420c2016-03-09 14:32:57 +05309097 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309098}
9099
9100/**
9101 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9102 * @wmi_handle: wmi handle
9103 * @vdev_id: vdev id
9104 * @pattern_id: pattern id
9105 *
9106 * Retrun: CDF status
9107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309108static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309109 uint8_t vdev_id,
9110 uint8_t pattern_id)
9111{
9112 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9113 wmi_buf_t wmi_buf;
9114 uint32_t len =
9115 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9116
9117 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9118 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309119 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9120 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309121 }
9122
9123 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9124 wmi_buf_data(wmi_buf);
9125 WMITLV_SET_HDR(&cmd->tlv_header,
9126 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9127 WMITLV_GET_STRUCT_TLVLEN
9128 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9129
9130 /* Pass the pattern id to delete for the corresponding vdev id */
9131 cmd->vdev_id = vdev_id;
9132 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309133 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309134 __func__, cmd->pattern_id, cmd->vdev_id);
9135
9136 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9137 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309138 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309139 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309140 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309141 }
Govind Singhb53420c2016-03-09 14:32:57 +05309142 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309143}
9144
9145/**
9146 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9147 * @wmi_handle: wmi handle
9148 * @preq: stats ext params
9149 *
9150 * Return: CDF status
9151 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309152static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309153 struct stats_ext_params *preq)
9154{
Govind Singh67922e82016-04-01 16:48:57 +05309155 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309156 wmi_req_stats_ext_cmd_fixed_param *cmd;
9157 wmi_buf_t buf;
9158 uint16_t len;
9159 uint8_t *buf_ptr;
9160
9161 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9162
9163 buf = wmi_buf_alloc(wmi_handle, len);
9164 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309165 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309166 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309167 }
9168
9169 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9170 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9171
9172 WMITLV_SET_HDR(&cmd->tlv_header,
9173 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9174 WMITLV_GET_STRUCT_TLVLEN
9175 (wmi_req_stats_ext_cmd_fixed_param));
9176 cmd->vdev_id = preq->vdev_id;
9177 cmd->data_len = preq->request_data_len;
9178
Govind Singhb53420c2016-03-09 14:32:57 +05309179 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309180 __func__, preq->request_data_len, preq->vdev_id);
9181
9182 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9184
9185 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309186 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309187
9188 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9189 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309190 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309191 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309192 ret);
9193 wmi_buf_free(buf);
9194 }
9195
9196 return ret;
9197}
9198
9199/**
9200 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9201 * @wmi_handle: wmi handle
9202 * @params: ext wow params
9203 *
9204 * Return:0 for success or error code
9205 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309206static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309207 struct ext_wow_params *params)
9208{
9209 wmi_extwow_enable_cmd_fixed_param *cmd;
9210 wmi_buf_t buf;
9211 int32_t len;
9212 int ret;
9213
9214 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9215 buf = wmi_buf_alloc(wmi_handle, len);
9216 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309217 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9218 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309219 }
9220
9221 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9222
9223 WMITLV_SET_HDR(&cmd->tlv_header,
9224 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9225 WMITLV_GET_STRUCT_TLVLEN
9226 (wmi_extwow_enable_cmd_fixed_param));
9227
9228 cmd->vdev_id = params->vdev_id;
9229 cmd->type = params->type;
9230 cmd->wakeup_pin_num = params->wakeup_pin_num;
9231
Govind Singhb53420c2016-03-09 14:32:57 +05309232 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309233 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9234
9235 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9236 WMI_EXTWOW_ENABLE_CMDID);
9237 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309238 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309239 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309240 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309241 }
9242
Govind Singhb53420c2016-03-09 14:32:57 +05309243 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309244
9245}
9246
9247/**
9248 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9249 * @wmi_handle: wmi handle
9250 * @app_type1_params: app type1 params
9251 *
9252 * Return: CDF status
9253 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309254static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309255 struct app_type1_params *app_type1_params)
9256{
9257 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9258 wmi_buf_t buf;
9259 int32_t len;
9260 int ret;
9261
9262 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9263 buf = wmi_buf_alloc(wmi_handle, len);
9264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9266 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 }
9268
9269 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9270 wmi_buf_data(buf);
9271
9272 WMITLV_SET_HDR(&cmd->tlv_header,
9273 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9274 WMITLV_GET_STRUCT_TLVLEN
9275 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9276
9277 cmd->vdev_id = app_type1_params->vdev_id;
9278 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9279 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309280 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309281 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309282 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309283 cmd->passwd_len = app_type1_params->pass_length;
9284
Govind Singhb53420c2016-03-09 14:32:57 +05309285 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309286 "identification_id %.8s id_length %u "
9287 "password %.16s pass_length %u",
9288 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9289 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9290
9291 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9292 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9293 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309294 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309295 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309296 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309297 }
9298
Govind Singhb53420c2016-03-09 14:32:57 +05309299 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309300}
9301
9302/**
9303 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9304 * @wmi_handle: wmi handle
9305 * @appType2Params: app type2 params
9306 *
9307 * Return: CDF status
9308 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309309static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309310 struct app_type2_params *appType2Params)
9311{
9312 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9313 wmi_buf_t buf;
9314 int32_t len;
9315 int ret;
9316
9317 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9318 buf = wmi_buf_alloc(wmi_handle, len);
9319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309320 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9321 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309322 }
9323
9324 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9325 wmi_buf_data(buf);
9326
9327 WMITLV_SET_HDR(&cmd->tlv_header,
9328 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9329 WMITLV_GET_STRUCT_TLVLEN
9330 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9331
9332 cmd->vdev_id = appType2Params->vdev_id;
9333
Govind Singhb53420c2016-03-09 14:32:57 +05309334 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309335 cmd->rc4_key_len = appType2Params->rc4_key_len;
9336
9337 cmd->ip_id = appType2Params->ip_id;
9338 cmd->ip_device_ip = appType2Params->ip_device_ip;
9339 cmd->ip_server_ip = appType2Params->ip_server_ip;
9340
9341 cmd->tcp_src_port = appType2Params->tcp_src_port;
9342 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9343 cmd->tcp_seq = appType2Params->tcp_seq;
9344 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9345
9346 cmd->keepalive_init = appType2Params->keepalive_init;
9347 cmd->keepalive_min = appType2Params->keepalive_min;
9348 cmd->keepalive_max = appType2Params->keepalive_max;
9349 cmd->keepalive_inc = appType2Params->keepalive_inc;
9350
9351 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9352 &cmd->gateway_mac);
9353 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9354 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9355
Govind Singhb53420c2016-03-09 14:32:57 +05309356 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309357 "rc4_key %.16s rc4_key_len %u "
9358 "ip_id %x ip_device_ip %x ip_server_ip %x "
9359 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9360 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9361 "keepalive_max %u keepalive_inc %u "
9362 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9363 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9364 cmd->rc4_key, cmd->rc4_key_len,
9365 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9366 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9367 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9368 cmd->keepalive_max, cmd->keepalive_inc,
9369 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9370
9371 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9372 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9373 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309374 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309376 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309377 }
9378
Govind Singhb53420c2016-03-09 14:32:57 +05309379 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309380
9381}
9382
9383/**
9384 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9385 * @wmi_handle: wmi handle
9386 * @timer_val: auto shutdown timer value
9387 *
9388 * Return: CDF status
9389 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309390static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 uint32_t timer_val)
9392{
Govind Singh67922e82016-04-01 16:48:57 +05309393 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 wmi_buf_t buf = NULL;
9395 uint8_t *buf_ptr;
9396 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9397 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9398
Govind Singhb53420c2016-03-09 14:32:57 +05309399 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309400 __func__, timer_val);
9401
9402 buf = wmi_buf_alloc(wmi_handle, len);
9403 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309404 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9405 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309406 }
9407
9408 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9409 wmi_auto_sh_cmd =
9410 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9411 wmi_auto_sh_cmd->timer_value = timer_val;
9412
9413 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9414 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9415 WMITLV_GET_STRUCT_TLVLEN
9416 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9417
9418 status = wmi_unified_cmd_send(wmi_handle, buf,
9419 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309420 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309421 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309422 __func__, status);
9423 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309424 }
9425
Govind Singh67922e82016-04-01 16:48:57 +05309426 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309427}
9428
9429/**
9430 * send_nan_req_cmd_tlv() - to send nan request to target
9431 * @wmi_handle: wmi handle
9432 * @nan_req: request data which will be non-null
9433 *
9434 * Return: CDF status
9435 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309436static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309437 struct nan_req_params *nan_req)
9438{
Govind Singh67922e82016-04-01 16:48:57 +05309439 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309440 wmi_nan_cmd_param *cmd;
9441 wmi_buf_t buf;
9442 uint16_t len = sizeof(*cmd);
9443 uint16_t nan_data_len, nan_data_len_aligned;
9444 uint8_t *buf_ptr;
9445
9446 /*
9447 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9448 * +------------+----------+-----------------------+--------------+
9449 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9450 * +------------+----------+-----------------------+--------------+
9451 */
9452 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309453 WMI_LOGE("%s:nan req is not valid", __func__);
9454 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309455 }
9456 nan_data_len = nan_req->request_data_len;
9457 nan_data_len_aligned = roundup(nan_req->request_data_len,
9458 sizeof(uint32_t));
9459 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9460 buf = wmi_buf_alloc(wmi_handle, len);
9461 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309462 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9463 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309464 }
9465 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9466 cmd = (wmi_nan_cmd_param *) buf_ptr;
9467 WMITLV_SET_HDR(&cmd->tlv_header,
9468 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9469 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9470 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309471 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 __func__, nan_req->request_data_len);
9473 buf_ptr += sizeof(wmi_nan_cmd_param);
9474 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9475 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309476 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309477
9478 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9479 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309480 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309481 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309482 __func__, ret);
9483 wmi_buf_free(buf);
9484 }
9485
9486 return ret;
9487}
9488
9489/**
9490 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9491 * @wmi_handle: wmi handle
9492 * @pDhcpSrvOffloadInfo: DHCP server offload info
9493 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309494 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309495 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309496static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309497 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9498{
9499 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9500 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309501 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309502
9503 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9504 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309505 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309506 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309507 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309508 }
9509
9510 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309511 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309512
9513 WMITLV_SET_HDR(&cmd->tlv_header,
9514 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9515 WMITLV_GET_STRUCT_TLVLEN
9516 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9517 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9518 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9519 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9520 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9521 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309522 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309523 sizeof(*cmd),
9524 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309525 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309526 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309527 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309528 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309529 }
Govind Singhb53420c2016-03-09 14:32:57 +05309530 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309531 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309532
9533 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309534}
9535
9536/**
9537 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9538 * @wmi_handle: wmi handle
9539 * @flashing: flashing request
9540 *
9541 * Return: CDF status
9542 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309543static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309544 struct flashing_req_params *flashing)
9545{
9546 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309547 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309548 wmi_buf_t buf;
9549 uint8_t *buf_ptr;
9550 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9551
9552 buf = wmi_buf_alloc(wmi_handle, len);
9553 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309554 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309555 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309556 }
9557 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9558 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9559 WMITLV_SET_HDR(&cmd->tlv_header,
9560 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9561 WMITLV_GET_STRUCT_TLVLEN
9562 (wmi_set_led_flashing_cmd_fixed_param));
9563 cmd->pattern_id = flashing->pattern_id;
9564 cmd->led_x0 = flashing->led_x0;
9565 cmd->led_x1 = flashing->led_x1;
9566
9567 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9568 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309569 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309570 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309571 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309572 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309573 }
Govind Singh67922e82016-04-01 16:48:57 +05309574
9575 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309576}
9577
9578/**
9579 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9580 * @wmi_handle: wmi handle
9581 * @ch_avoid_update_req: channel avoid update params
9582 *
9583 * Return: CDF status
9584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309585static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309586{
Govind Singh67922e82016-04-01 16:48:57 +05309587 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309588 wmi_buf_t buf = NULL;
9589 uint8_t *buf_ptr;
9590 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9591 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9592
9593
9594 buf = wmi_buf_alloc(wmi_handle, len);
9595 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309596 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9597 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309598 }
9599
9600 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9601 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9602 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9603 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9604 WMITLV_GET_STRUCT_TLVLEN
9605 (wmi_chan_avoid_update_cmd_param));
9606
9607 status = wmi_unified_cmd_send(wmi_handle, buf,
9608 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309609 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309610 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309611 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9612 " returned Error %d", status);
9613 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309614 }
9615
Govind Singh67922e82016-04-01 16:48:57 +05309616 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309617}
9618
9619/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309620 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9621 * @wmi_handle: wmi handle
9622 * @param: pointer to pdev regdomain params
9623 *
9624 * Return: 0 for success or error code
9625 */
9626static QDF_STATUS
9627send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9628 struct pdev_set_regdomain_params *param)
9629{
9630 wmi_buf_t buf;
9631 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9632 int32_t len = sizeof(*cmd);
9633
9634
9635 buf = wmi_buf_alloc(wmi_handle, len);
9636 if (!buf) {
9637 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9638 return QDF_STATUS_E_NOMEM;
9639 }
9640 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9641 WMITLV_SET_HDR(&cmd->tlv_header,
9642 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9643 WMITLV_GET_STRUCT_TLVLEN
9644 (wmi_pdev_set_regdomain_cmd_fixed_param));
9645
9646 cmd->reg_domain = param->currentRDinuse;
9647 cmd->reg_domain_2G = param->currentRD2G;
9648 cmd->reg_domain_5G = param->currentRD5G;
9649 cmd->conformance_test_limit_2G = param->ctl_2G;
9650 cmd->conformance_test_limit_5G = param->ctl_5G;
9651 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309652 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9653 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309654
9655 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9656 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9657 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9658 __func__);
9659 wmi_buf_free(buf);
9660 return QDF_STATUS_E_FAILURE;
9661 }
9662
9663 return QDF_STATUS_SUCCESS;
9664}
9665
9666/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309667 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9668 * @wmi_handle: wmi handle
9669 * @reg_dmn: reg domain
9670 * @regdmn2G: 2G reg domain
9671 * @regdmn5G: 5G reg domain
9672 * @ctl2G: 2G test limit
9673 * @ctl5G: 5G test limit
9674 *
9675 * Return: none
9676 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309677static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309678 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309679 uint16_t regdmn5G, uint8_t ctl2G,
9680 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309681{
9682 wmi_buf_t buf;
9683 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9684 int32_t len = sizeof(*cmd);
9685
9686
9687 buf = wmi_buf_alloc(wmi_handle, len);
9688 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309689 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9690 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309691 }
9692 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9693 WMITLV_SET_HDR(&cmd->tlv_header,
9694 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9695 WMITLV_GET_STRUCT_TLVLEN
9696 (wmi_pdev_set_regdomain_cmd_fixed_param));
9697 cmd->reg_domain = reg_dmn;
9698 cmd->reg_domain_2G = regdmn2G;
9699 cmd->reg_domain_5G = regdmn5G;
9700 cmd->conformance_test_limit_2G = ctl2G;
9701 cmd->conformance_test_limit_5G = ctl5G;
9702
9703 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9704 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309705 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309706 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309707 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309708 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309709 }
9710
Govind Singhb53420c2016-03-09 14:32:57 +05309711 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309712}
9713
9714
9715/**
9716 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9717 * @wmi_handle: wmi handle
9718 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9719 *
9720 * This function sets tdls off channel mode
9721 *
9722 * Return: 0 on success; Negative errno otherwise
9723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309724static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309725 struct tdls_channel_switch_params *chan_switch_params)
9726{
9727 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9728 wmi_buf_t wmi_buf;
9729 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9730
9731 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9732 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309733 WMI_LOGE(FL("wmi_buf_alloc failed"));
9734 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309735 }
9736 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9737 wmi_buf_data(wmi_buf);
9738 WMITLV_SET_HDR(&cmd->tlv_header,
9739 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9740 WMITLV_GET_STRUCT_TLVLEN(
9741 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9742
9743 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9744 &cmd->peer_macaddr);
9745 cmd->vdev_id = chan_switch_params->vdev_id;
9746 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9747 cmd->is_peer_responder = chan_switch_params->is_responder;
9748 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9749 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9750 cmd->offchan_oper_class = chan_switch_params->oper_class;
9751
Govind Singhb53420c2016-03-09 14:32:57 +05309752 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309753 cmd->peer_macaddr.mac_addr31to0,
9754 cmd->peer_macaddr.mac_addr47to32);
9755
Govind Singhb53420c2016-03-09 14:32:57 +05309756 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309757 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9758 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9759 ),
9760 cmd->vdev_id,
9761 cmd->offchan_mode,
9762 cmd->offchan_num,
9763 cmd->offchan_bw_bitmap,
9764 cmd->is_peer_responder,
9765 cmd->offchan_oper_class);
9766
9767 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9768 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309769 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309770 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309771 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309772 }
9773
9774
Govind Singhb53420c2016-03-09 14:32:57 +05309775 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309776}
9777
9778/**
9779 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9780 * @wmi_handle: wmi handle
9781 * @pwmaTdlsparams: TDLS params
9782 *
9783 * Return: 0 for sucess or error code
9784 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309785static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309786 void *tdls_param, uint8_t tdls_state)
9787{
9788 wmi_tdls_set_state_cmd_fixed_param *cmd;
9789 wmi_buf_t wmi_buf;
9790
9791 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9792 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9793
9794 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9795 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309796 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9797 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309798 }
9799 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9800 WMITLV_SET_HDR(&cmd->tlv_header,
9801 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9802 WMITLV_GET_STRUCT_TLVLEN
9803 (wmi_tdls_set_state_cmd_fixed_param));
9804 cmd->vdev_id = wmi_tdls->vdev_id;
9805 cmd->state = tdls_state;
9806 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9807 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9808 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9809 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9810 cmd->rssi_delta = wmi_tdls->rssi_delta;
9811 cmd->tdls_options = wmi_tdls->tdls_options;
9812 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9813 cmd->tdls_peer_traffic_response_timeout_ms =
9814 wmi_tdls->peer_traffic_response_timeout;
9815 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9816 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9817 cmd->tdls_puapsd_rx_frame_threshold =
9818 wmi_tdls->puapsd_rx_frame_threshold;
9819 cmd->teardown_notification_ms =
9820 wmi_tdls->teardown_notification_ms;
9821 cmd->tdls_peer_kickout_threshold =
9822 wmi_tdls->tdls_peer_kickout_threshold;
9823
Govind Singhb53420c2016-03-09 14:32:57 +05309824 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309825 "notification_interval_ms: %d, "
9826 "tx_discovery_threshold: %d, "
9827 "tx_teardown_threshold: %d, "
9828 "rssi_teardown_threshold: %d, "
9829 "rssi_delta: %d, "
9830 "tdls_options: 0x%x, "
9831 "tdls_peer_traffic_ind_window: %d, "
9832 "tdls_peer_traffic_response_timeout: %d, "
9833 "tdls_puapsd_mask: 0x%x, "
9834 "tdls_puapsd_inactivity_time: %d, "
9835 "tdls_puapsd_rx_frame_threshold: %d, "
9836 "teardown_notification_ms: %d, "
9837 "tdls_peer_kickout_threshold: %d",
9838 __func__, tdls_state, cmd->state,
9839 cmd->notification_interval_ms,
9840 cmd->tx_discovery_threshold,
9841 cmd->tx_teardown_threshold,
9842 cmd->rssi_teardown_threshold,
9843 cmd->rssi_delta,
9844 cmd->tdls_options,
9845 cmd->tdls_peer_traffic_ind_window,
9846 cmd->tdls_peer_traffic_response_timeout_ms,
9847 cmd->tdls_puapsd_mask,
9848 cmd->tdls_puapsd_inactivity_time_ms,
9849 cmd->tdls_puapsd_rx_frame_threshold,
9850 cmd->teardown_notification_ms,
9851 cmd->tdls_peer_kickout_threshold);
9852
9853 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9854 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309855 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309856 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309857 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309858 }
Govind Singhb53420c2016-03-09 14:32:57 +05309859 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309860
Govind Singhb53420c2016-03-09 14:32:57 +05309861 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309862}
9863
9864/**
9865 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9866 * @wmi_handle: wmi handle
9867 * @peerStateParams: TDLS peer state params
9868 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309869 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309870 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309871static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309872 struct tdls_peer_state_params *peerStateParams,
9873 uint32_t *ch_mhz)
9874{
9875 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9876 wmi_tdls_peer_capabilities *peer_cap;
9877 wmi_channel *chan_info;
9878 wmi_buf_t wmi_buf;
9879 uint8_t *buf_ptr;
9880 uint32_t i;
9881 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9882 sizeof(wmi_tdls_peer_capabilities);
9883
9884
9885 len += WMI_TLV_HDR_SIZE +
9886 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9887
9888 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9889 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309890 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9891 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309892 }
9893
9894 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9895 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9896 WMITLV_SET_HDR(&cmd->tlv_header,
9897 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9898 WMITLV_GET_STRUCT_TLVLEN
9899 (wmi_tdls_peer_update_cmd_fixed_param));
9900
9901 cmd->vdev_id = peerStateParams->vdevId;
9902 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9903 &cmd->peer_macaddr);
9904
9905
9906 cmd->peer_state = peerStateParams->peerState;
9907
Govind Singhb53420c2016-03-09 14:32:57 +05309908 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309909 "peer_macaddr.mac_addr31to0: 0x%x, "
9910 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9911 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9912 cmd->peer_macaddr.mac_addr31to0,
9913 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9914
9915 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9916 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9917 WMITLV_SET_HDR(&peer_cap->tlv_header,
9918 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9919 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9920
9921 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9922 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9923 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9924 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9925 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9926 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9927 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9928 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9929
9930 /* Ack and More Data Ack are sent as 0, so no need to set
9931 * but fill SP
9932 */
9933 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9934 peerStateParams->peerCap.peerMaxSp);
9935
9936 peer_cap->buff_sta_support =
9937 peerStateParams->peerCap.peerBuffStaSupport;
9938 peer_cap->off_chan_support =
9939 peerStateParams->peerCap.peerOffChanSupport;
9940 peer_cap->peer_curr_operclass =
9941 peerStateParams->peerCap.peerCurrOperClass;
9942 /* self curr operclass is not being used and so pass op class for
9943 * preferred off chan in it.
9944 */
9945 peer_cap->self_curr_operclass =
9946 peerStateParams->peerCap.opClassForPrefOffChan;
9947 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9948 peer_cap->peer_operclass_len =
9949 peerStateParams->peerCap.peerOperClassLen;
9950
Govind Singhb53420c2016-03-09 14:32:57 +05309951 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309952 __func__, peer_cap->peer_operclass_len);
9953 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9954 peer_cap->peer_operclass[i] =
9955 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309956 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309957 __func__, i, peer_cap->peer_operclass[i]);
9958 }
9959
9960 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9961 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9962 peer_cap->pref_offchan_bw =
9963 peerStateParams->peerCap.prefOffChanBandwidth;
9964
Govind Singhb53420c2016-03-09 14:32:57 +05309965 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309966 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9967 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9968 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9969 " %d, pref_offchan_bw: %d",
9970 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9971 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9972 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9973 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9974 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9975
9976 /* next fill variable size array of peer chan info */
9977 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9978 WMITLV_SET_HDR(buf_ptr,
9979 WMITLV_TAG_ARRAY_STRUC,
9980 sizeof(wmi_channel) *
9981 peerStateParams->peerCap.peerChanLen);
9982 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9983
9984 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9985 WMITLV_SET_HDR(&chan_info->tlv_header,
9986 WMITLV_TAG_STRUC_wmi_channel,
9987 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9988 chan_info->mhz = ch_mhz[i];
9989 chan_info->band_center_freq1 = chan_info->mhz;
9990 chan_info->band_center_freq2 = 0;
9991
Govind Singhb53420c2016-03-09 14:32:57 +05309992 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309993
9994 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9995 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309996 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309997 peerStateParams->peerCap.peerChan[i].chanId,
9998 peerStateParams->peerCap.peerChan[i].dfsSet);
9999 }
10000
10001 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10002 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10003 else
10004 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10005
10006 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10007 peerStateParams->peerCap.
10008 peerChan[i].pwr);
10009
10010 WMI_SET_CHANNEL_REG_POWER(chan_info,
10011 peerStateParams->peerCap.peerChan[i].
10012 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010013 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010014 peerStateParams->peerCap.peerChan[i].pwr);
10015
10016 chan_info++;
10017 }
10018
10019 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10020 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010021 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010022 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010023 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010024 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010025 }
10026
10027
Govind Singhb53420c2016-03-09 14:32:57 +053010028 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010029}
10030
10031/*
10032 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
10033 * firmware
10034 * @wmi_handle: Pointer to wmi handle
10035 * @mem_dump_req: Pointer for mem_dump_req
10036 *
10037 * This function sends memory dump request to firmware
10038 *
Govind Singhb53420c2016-03-09 14:32:57 +053010039 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010040 *
10041 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010042static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010043 struct fw_dump_req_param *mem_dump_req)
10044{
10045 wmi_get_fw_mem_dump_fixed_param *cmd;
10046 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +053010047 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +053010048 int32_t len;
10049 wmi_buf_t buf;
10050 u_int8_t *buf_ptr;
10051 int ret, loop;
10052
10053 /*
10054 * len = sizeof(fixed param) that includes tlv header +
10055 * tlv header for array of struc +
10056 * sizeof (each struct)
10057 */
10058 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10059 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
10060 buf = wmi_buf_alloc(wmi_handle, len);
10061
10062 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010063 WMI_LOGE(FL("Failed allocate wmi buffer"));
10064 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010065 }
10066
10067 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010068 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010069 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
10070
10071 WMITLV_SET_HDR(&cmd->tlv_header,
10072 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
10073 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
10074
10075 cmd->request_id = mem_dump_req->request_id;
10076 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
10077
10078 /* TLV indicating array of structures to follow */
10079 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
10080 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10081 sizeof(wmi_fw_mem_dump) *
10082 cmd->num_fw_mem_dump_segs);
10083
10084 buf_ptr += WMI_TLV_HDR_SIZE;
10085 dump_params = (wmi_fw_mem_dump *) buf_ptr;
10086
Govind Singhb53420c2016-03-09 14:32:57 +053010087 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010088 mem_dump_req->request_id, mem_dump_req->num_seg);
10089 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +053010090 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +053010091 ((uint8_t *)(mem_dump_req->segment) +
10092 loop * sizeof(*seg_req));
10093 WMITLV_SET_HDR(&dump_params->tlv_header,
10094 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
10095 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
10096 dump_params->seg_id = seg_req->seg_id;
10097 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
10098 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
10099 dump_params->seg_length = seg_req->seg_length;
10100 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
10101 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +053010102 WMI_LOGI(FL("seg_number:%d"), loop);
10103 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 dump_params->seg_id, dump_params->seg_start_addr_lo,
10105 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +053010106 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010107 dump_params->seg_length, dump_params->dest_addr_lo,
10108 dump_params->dest_addr_hi);
10109 dump_params++;
10110 }
10111
10112 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10113 WMI_GET_FW_MEM_DUMP_CMDID);
10114 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010115 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +053010116 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010117 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010118 }
10119
Govind Singhb53420c2016-03-09 14:32:57 +053010120 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
10121 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010122}
10123
10124/*
10125 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10126 * @wmi_handle: Pointer to WMi handle
10127 * @ie_data: Pointer for ie data
10128 *
10129 * This function sends IE information to firmware
10130 *
Govind Singhb53420c2016-03-09 14:32:57 +053010131 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010132 *
10133 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010134static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010135 struct vdev_ie_info_param *ie_info)
10136{
10137 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10138 wmi_buf_t buf;
10139 uint8_t *buf_ptr;
10140 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010141 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010142
10143
10144 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10145 /* Allocate memory for the WMI command */
10146 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10147
10148 buf = wmi_buf_alloc(wmi_handle, len);
10149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010150 WMI_LOGE(FL("wmi_buf_alloc failed"));
10151 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010152 }
10153
10154 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010155 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010156
10157 /* Populate the WMI command */
10158 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10159
10160 WMITLV_SET_HDR(&cmd->tlv_header,
10161 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10162 WMITLV_GET_STRUCT_TLVLEN(
10163 wmi_vdev_set_ie_cmd_fixed_param));
10164 cmd->vdev_id = ie_info->vdev_id;
10165 cmd->ie_id = ie_info->ie_id;
10166 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010167 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010168
Govind Singhb53420c2016-03-09 14:32:57 +053010169 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010170 ie_info->length, ie_info->vdev_id);
10171
10172 buf_ptr += sizeof(*cmd);
10173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10174 buf_ptr += WMI_TLV_HDR_SIZE;
10175
Govind Singhb53420c2016-03-09 14:32:57 +053010176 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010177
10178 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10179 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010180 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010181 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010182 wmi_buf_free(buf);
10183 }
10184
10185 return ret;
10186}
10187
Sathish Kumar497bef42017-03-01 14:02:36 +053010188/**
10189 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10190 *
10191 * @param wmi_handle : handle to WMI.
10192 * @param param : pointer to antenna param
10193 *
10194 * This function sends smart antenna enable command to FW
10195 *
10196 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10197 */
10198static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10199 struct smart_ant_enable_params *param)
10200{
10201 /* Send WMI COMMAND to Enable */
10202 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10203 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10204 wmi_buf_t buf;
10205 uint8_t *buf_ptr;
10206 int len = 0;
10207 QDF_STATUS ret;
10208 int loop = 0;
10209
10210 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10211 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10212 buf = wmi_buf_alloc(wmi_handle, len);
10213
10214 if (!buf) {
10215 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10216 return QDF_STATUS_E_NOMEM;
10217 }
10218
10219 buf_ptr = wmi_buf_data(buf);
10220 qdf_mem_zero(buf_ptr, len);
10221 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10222
10223 WMITLV_SET_HDR(&cmd->tlv_header,
10224 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10225 WMITLV_GET_STRUCT_TLVLEN(
10226 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10227
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010228 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10229 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010230 cmd->enable = param->enable;
10231 cmd->mode = param->mode;
10232 cmd->rx_antenna = param->rx_antenna;
10233 cmd->tx_default_antenna = param->rx_antenna;
10234
10235 /* TLV indicating array of structures to follow */
10236 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10237 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10238 WMI_HAL_MAX_SANTENNA *
10239 sizeof(wmi_pdev_smart_ant_gpio_handle));
10240
10241 buf_ptr += WMI_TLV_HDR_SIZE;
10242 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10243
10244 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10245 WMITLV_SET_HDR(&gpio_param->tlv_header,
10246 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10247 WMITLV_GET_STRUCT_TLVLEN(
10248 wmi_pdev_smart_ant_gpio_handle));
10249 if (param->mode == SMART_ANT_MODE_SERIAL) {
10250 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10251 gpio_param->gpio_pin = param->gpio_pin[loop];
10252 gpio_param->gpio_func = param->gpio_func[loop];
10253 } else {
10254 gpio_param->gpio_pin = 0;
10255 gpio_param->gpio_func = 0;
10256 }
10257 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10258 gpio_param->gpio_pin = param->gpio_pin[loop];
10259 gpio_param->gpio_func = param->gpio_func[loop];
10260 }
10261 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010262 gpio_param->pdev_id =
10263 wmi_handle->ops->convert_pdev_id_host_to_target(
10264 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010265 gpio_param++;
10266 }
10267
10268 ret = wmi_unified_cmd_send(wmi_handle,
10269 buf,
10270 len,
10271 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10272
10273 if (ret != 0) {
10274 WMI_LOGE(" %s :WMI Failed\n", __func__);
10275 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10276 cmd->enable,
10277 cmd->mode,
10278 cmd->rx_antenna,
10279 param->gpio_pin[0], param->gpio_pin[1],
10280 param->gpio_pin[2], param->gpio_pin[3],
10281 param->gpio_func[0], param->gpio_func[1],
10282 param->gpio_func[2], param->gpio_func[3],
10283 ret);
10284 wmi_buf_free(buf);
10285 }
10286
10287 return ret;
10288}
10289
10290/**
10291 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10292 *
10293 * @param wmi_handle : handle to WMI.
10294 * @param param : pointer to rx antenna param
10295 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10296 */
10297static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10298 struct smart_ant_rx_ant_params *param)
10299{
10300 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10301 wmi_buf_t buf;
10302 uint8_t *buf_ptr;
10303 uint32_t len;
10304 QDF_STATUS ret;
10305
10306 len = sizeof(*cmd);
10307 buf = wmi_buf_alloc(wmi_handle, len);
10308 WMI_LOGD("%s:\n", __func__);
10309 if (!buf) {
10310 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10311 return QDF_STATUS_E_NOMEM;
10312 }
10313
10314 buf_ptr = wmi_buf_data(buf);
10315 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10316 WMITLV_SET_HDR(&cmd->tlv_header,
10317 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10318 WMITLV_GET_STRUCT_TLVLEN(
10319 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10320 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010321 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10322 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010323
10324 ret = wmi_unified_cmd_send(wmi_handle,
10325 buf,
10326 len,
10327 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10328
10329 if (ret != 0) {
10330 WMI_LOGE(" %s :WMI Failed\n", __func__);
10331 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10332 __func__,
10333 cmd->rx_antenna,
10334 ret);
10335 wmi_buf_free(buf);
10336 }
10337
10338 return ret;
10339}
10340
10341/**
10342 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10343 * @wmi_handle: wmi handle
10344 * @param: pointer to hold ctl table param
10345 *
10346 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10347 */
10348static QDF_STATUS
10349send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10350 struct ctl_table_params *param)
10351{
10352 uint16_t len, ctl_tlv_len;
10353 uint8_t *buf_ptr;
10354 wmi_buf_t buf;
10355 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10356 uint32_t *ctl_array;
10357
10358 if (!param->ctl_array)
10359 return QDF_STATUS_E_FAILURE;
10360
10361 if (param->ctl_cmd_len !=
10362 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10363 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
10364 qdf_print("CTL array len not correct\n");
10365 return QDF_STATUS_E_FAILURE;
10366 }
10367
10368 ctl_tlv_len = WMI_TLV_HDR_SIZE +
10369 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
10370 len = sizeof(*cmd) + ctl_tlv_len;
10371
10372 buf = wmi_buf_alloc(wmi_handle, len);
10373 if (!buf) {
10374 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10375 return QDF_STATUS_E_FAILURE;
10376 }
10377
10378 buf_ptr = wmi_buf_data(buf);
10379 qdf_mem_zero(buf_ptr, len);
10380
10381 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10382
10383 WMITLV_SET_HDR(&cmd->tlv_header,
10384 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10385 WMITLV_GET_STRUCT_TLVLEN(
10386 wmi_pdev_set_ctl_table_cmd_fixed_param));
10387 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010388 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10389 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010390
10391 buf_ptr += sizeof(*cmd);
10392 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10393 (cmd->ctl_len));
10394 buf_ptr += WMI_TLV_HDR_SIZE;
10395 ctl_array = (uint32_t *)buf_ptr;
10396
10397 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10398 sizeof(param->ctl_band));
10399 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10400 param->ctl_cmd_len -
10401 sizeof(param->ctl_band));
10402
10403 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10404 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10405 WMI_LOGE("%s:Failed to send command\n", __func__);
10406 wmi_buf_free(buf);
10407 return QDF_STATUS_E_FAILURE;
10408 }
10409
10410 return QDF_STATUS_SUCCESS;
10411}
10412
10413/**
10414 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10415 * @wmi_handle: wmi handle
10416 * @param: pointer to hold mimogain table param
10417 *
10418 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10419 */
10420static QDF_STATUS
10421send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10422 struct mimogain_table_params *param)
10423{
10424 uint16_t len, table_tlv_len;
10425 wmi_buf_t buf;
10426 uint8_t *buf_ptr;
10427 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10428 uint32_t *gain_table;
10429
10430 if (!param->array_gain)
10431 return QDF_STATUS_E_FAILURE;
10432
10433 /* len must be multiple of a single array gain table */
10434 if (param->tbl_len %
10435 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10436 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10437 WMI_LOGE("Array gain table len not correct\n");
10438 return QDF_STATUS_E_FAILURE;
10439 }
10440
10441 table_tlv_len = WMI_TLV_HDR_SIZE +
10442 roundup(param->tbl_len, sizeof(uint32_t));
10443 len = sizeof(*cmd) + table_tlv_len;
10444
10445 buf = wmi_buf_alloc(wmi_handle, len);
10446 if (!buf) {
10447 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10448 return QDF_STATUS_E_FAILURE;
10449 }
10450
10451 buf_ptr = wmi_buf_data(buf);
10452 qdf_mem_zero(buf_ptr, len);
10453
10454 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10455
10456 WMITLV_SET_HDR(&cmd->tlv_header,
10457 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10458 WMITLV_GET_STRUCT_TLVLEN(
10459 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10460
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010461 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10462 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010463 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10464 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10465 param->multichain_gain_bypass);
10466
10467 buf_ptr += sizeof(*cmd);
10468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10469 (param->tbl_len));
10470 buf_ptr += WMI_TLV_HDR_SIZE;
10471 gain_table = (uint32_t *)buf_ptr;
10472
10473 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10474 param->array_gain,
10475 param->tbl_len);
10476
10477 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10478 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10479 return QDF_STATUS_E_FAILURE;
10480 }
10481
10482 return QDF_STATUS_SUCCESS;
10483}
10484
10485/**
10486 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10487 * info to fw
10488 * @wmi_handle: wmi handle
10489 * @param: pointer to hold packet power info param
10490 *
10491 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10492 */
10493static QDF_STATUS
10494send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10495 struct packet_power_info_params *param)
10496{
10497 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10498 wmi_buf_t wmibuf;
10499 uint8_t *buf_ptr;
10500 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10501
10502 wmibuf = wmi_buf_alloc(wmi_handle, len);
10503 if (wmibuf == NULL)
10504 return QDF_STATUS_E_NOMEM;
10505
10506 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10507
10508 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10509 WMITLV_SET_HDR(&cmd->tlv_header,
10510 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10511 WMITLV_GET_STRUCT_TLVLEN(
10512 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010513 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10514 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010515 cmd->rate_flags = param->rate_flags;
10516 cmd->nss = param->nss;
10517 cmd->preamble = param->preamble;
10518 cmd->hw_rate = param->hw_rate;
10519 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10520 __func__,
10521 __LINE__,
10522 WMI_PDEV_GET_TPC_CMDID,
10523 *((u_int32_t *)cmd));
10524 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10525 WMI_PDEV_GET_TPC_CMDID)) {
10526 WMI_LOGE(FL("Failed to get tpc command\n"));
10527 wmi_buf_free(wmibuf);
10528 return QDF_STATUS_E_FAILURE;
10529 }
10530
10531 return QDF_STATUS_SUCCESS;
10532}
10533
10534/**
10535 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10536 * @wmi_handle: wmi handle
10537 * @param: pointer to hold config ratemask params
10538 *
10539 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10540 */
10541static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10542 struct config_ratemask_params *param)
10543{
10544 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10545 wmi_buf_t buf;
10546 int32_t len = sizeof(*cmd);
10547
10548 buf = wmi_buf_alloc(wmi_handle, len);
10549 if (!buf) {
10550 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10551 return QDF_STATUS_E_FAILURE;
10552 }
10553 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10554 WMITLV_SET_HDR(&cmd->tlv_header,
10555 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10556 WMITLV_GET_STRUCT_TLVLEN(
10557 wmi_vdev_config_ratemask_cmd_fixed_param));
10558 cmd->vdev_id = param->vdev_id;
10559 cmd->type = param->type;
10560 cmd->mask_lower32 = param->lower32;
10561 cmd->mask_higher32 = param->higher32;
10562 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10563 param->vdev_id, param->type, param->lower32, param->higher32);
10564
10565 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10566 WMI_VDEV_RATEMASK_CMDID)) {
10567 WMI_LOGE("Seting vdev ratemask failed\n");
10568 wmi_buf_free(buf);
10569 return QDF_STATUS_E_FAILURE;
10570 }
10571
10572 return QDF_STATUS_SUCCESS;
10573}
10574
10575/**
10576 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10577 * @wmi_handle: wmi handle
10578 * @param: pointer to hold vap dscp tid map param
10579 *
10580 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10581 */
10582static QDF_STATUS
10583send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10584 struct vap_dscp_tid_map_params *param)
10585{
10586 wmi_buf_t buf;
10587 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10588 int32_t len = sizeof(*cmd);
10589
10590 buf = wmi_buf_alloc(wmi_handle, len);
10591 if (!buf) {
10592 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10593 return QDF_STATUS_E_FAILURE;
10594 }
10595
10596 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10597 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10598 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10599
10600 cmd->vdev_id = param->vdev_id;
10601 cmd->enable_override = 0;
10602
10603 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10604 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10605 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10606 WMI_LOGE("Failed to set dscp cmd\n");
10607 wmi_buf_free(buf);
10608 return QDF_STATUS_E_FAILURE;
10609 }
10610
10611 return QDF_STATUS_SUCCESS;
10612}
10613
10614/**
10615 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10616 * @wmi_handle: wmi handle
10617 * @macaddr: vdev mac address
10618 * @param: pointer to hold neigbour rx param
10619 *
10620 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10621 */
10622static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10623 uint8_t macaddr[IEEE80211_ADDR_LEN],
10624 struct set_neighbour_rx_params *param)
10625{
10626 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10627 wmi_buf_t buf;
10628 int32_t len = sizeof(*cmd);
10629
10630 buf = wmi_buf_alloc(wmi_handle, len);
10631 if (!buf) {
10632 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10633 return QDF_STATUS_E_FAILURE;
10634 }
10635 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10636 WMITLV_SET_HDR(&cmd->tlv_header,
10637 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10638 WMITLV_GET_STRUCT_TLVLEN(
10639 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10640 cmd->vdev_id = param->vdev_id;
10641 cmd->bssid_idx = param->idx;
10642 cmd->action = param->action;
10643 cmd->type = param->type;
10644 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10645 cmd->flag = 0;
10646
10647 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10648 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10649 WMI_LOGE("Failed to set neighbour rx param\n");
10650 wmi_buf_free(buf);
10651 return QDF_STATUS_E_FAILURE;
10652 }
10653
10654 return QDF_STATUS_SUCCESS;
10655}
10656
10657/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010658 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010659 * @param wmi_handle : handle to WMI.
10660 * @param macaddr : vdev mac address
10661 * @param param : pointer to tx antenna param
10662 *
10663 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10664 */
10665static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10666 uint8_t macaddr[IEEE80211_ADDR_LEN],
10667 struct smart_ant_tx_ant_params *param)
10668{
10669 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10670 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10671 wmi_buf_t buf;
10672 int32_t len = 0;
10673 int i;
10674 uint8_t *buf_ptr;
10675 QDF_STATUS ret;
10676
10677 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10678 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10679 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10680 buf = wmi_buf_alloc(wmi_handle, len);
10681
10682 if (!buf) {
10683 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10684 return QDF_STATUS_E_NOMEM;
10685 }
10686
10687 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10688 qdf_mem_zero(buf_ptr, len);
10689 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10690
10691 WMITLV_SET_HDR(&cmd->tlv_header,
10692 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10693 WMITLV_GET_STRUCT_TLVLEN(
10694 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10695
10696 cmd->vdev_id = param->vdev_id;
10697 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10698
10699 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10700 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10701 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10702 buf_ptr += WMI_TLV_HDR_SIZE;
10703 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10704
10705 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10706 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10707 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10708 WMITLV_GET_STRUCT_TLVLEN(
10709 wmi_peer_smart_ant_set_tx_antenna_series));
10710 ant_tx_series->antenna_series = param->antenna_array[i];
10711 ant_tx_series++;
10712 }
10713
10714 ret = wmi_unified_cmd_send(wmi_handle,
10715 buf,
10716 len,
10717 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10718
10719 if (ret != 0) {
10720 WMI_LOGE(" %s :WMI Failed\n", __func__);
10721 wmi_buf_free(buf);
10722 }
10723
10724 return ret;
10725}
10726
Sathish Kumar02c3b542017-02-22 17:24:45 +053010727/**
10728 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10729 * @wmi_handle: wmi handle
10730 * @param: pointer to hold ant switch tbl param
10731 *
10732 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10733 */
10734static QDF_STATUS
10735send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10736 struct ant_switch_tbl_params *param)
10737{
10738 uint8_t len;
10739 wmi_buf_t buf;
10740 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10741 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10742 uint8_t *buf_ptr;
10743
10744 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10745 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10746 buf = wmi_buf_alloc(wmi_handle, len);
10747
10748 if (!buf) {
10749 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10750 return QDF_STATUS_E_NOMEM;
10751 }
10752
10753 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10754 qdf_mem_zero(buf_ptr, len);
10755 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10756
10757 WMITLV_SET_HDR(&cmd->tlv_header,
10758 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10759 WMITLV_GET_STRUCT_TLVLEN(
10760 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10761
10762 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10763 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010764 cmd->mac_id =
10765 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010766
10767 /* TLV indicating array of structures to follow */
10768 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10770 sizeof(wmi_pdev_set_ant_ctrl_chain));
10771 buf_ptr += WMI_TLV_HDR_SIZE;
10772 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10773
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010774 ctrl_chain->pdev_id =
10775 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010776 ctrl_chain->antCtrlChain = param->antCtrlChain;
10777
10778 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10779 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10780 wmi_buf_free(buf);
10781 return QDF_STATUS_E_FAILURE;
10782 }
10783
10784 return QDF_STATUS_SUCCESS;
10785}
10786
10787/**
10788 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10789 * training information function
10790 * @param wmi_handle : handle to WMI.
10791 * @macaddr : vdev mac address
10792 * @param param : pointer to tx antenna param
10793 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10794 */
10795static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10796 wmi_unified_t wmi_handle,
10797 uint8_t macaddr[IEEE80211_ADDR_LEN],
10798 struct smart_ant_training_info_params *param)
10799{
10800 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10801 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10802 wmi_buf_t buf;
10803 uint8_t *buf_ptr;
10804 int32_t len = 0;
10805 QDF_STATUS ret;
10806 int loop;
10807
10808 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10809 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10810 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10811 buf = wmi_buf_alloc(wmi_handle, len);
10812
10813 if (!buf) {
10814 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10815 return QDF_STATUS_E_NOMEM;
10816 }
10817
10818 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10819 qdf_mem_zero(buf_ptr, len);
10820 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10821
10822 WMITLV_SET_HDR(&cmd->tlv_header,
10823 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10824 WMITLV_GET_STRUCT_TLVLEN(
10825 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10826
10827 cmd->vdev_id = param->vdev_id;
10828 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10829 cmd->num_pkts = param->numpkts;
10830
10831 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10832 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10833 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10834 WMI_SMART_ANT_MAX_RATE_SERIES);
10835
10836 buf_ptr += WMI_TLV_HDR_SIZE;
10837 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10838
10839 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10840 WMITLV_SET_HDR(&train_param->tlv_header,
10841 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10842 WMITLV_GET_STRUCT_TLVLEN(
10843 wmi_peer_smart_ant_set_train_antenna_param));
10844 train_param->train_rate_series = param->rate_array[loop];
10845 train_param->train_antenna_series = param->antenna_array[loop];
10846 train_param->rc_flags = 0;
10847 WMI_LOGI(FL("Series number:%d\n"), loop);
10848 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10849 train_param->train_rate_series,
10850 train_param->train_antenna_series);
10851 train_param++;
10852 }
10853
10854 ret = wmi_unified_cmd_send(wmi_handle,
10855 buf,
10856 len,
10857 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10858
10859 if (ret != 0) {
10860 WMI_LOGE(" %s :WMI Failed\n", __func__);
10861 wmi_buf_free(buf);
10862 return QDF_STATUS_E_FAILURE;
10863 }
10864
10865 return ret;
10866}
10867
10868/**
10869 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10870 * configuration function
10871 * @param wmi_handle : handle to WMI.
10872 * @macaddr : vdev mad address
10873 * @param param : pointer to tx antenna param
10874 *
10875 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10876 */
10877static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10878 wmi_unified_t wmi_handle,
10879 uint8_t macaddr[IEEE80211_ADDR_LEN],
10880 struct smart_ant_node_config_params *param)
10881{
10882 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10883 wmi_buf_t buf;
10884 uint8_t *buf_ptr;
10885 int32_t len = 0, args_tlv_len;
10886 int ret;
10887 int i = 0;
10888 A_UINT32 *node_config_args;
10889
10890 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10891 len = sizeof(*cmd) + args_tlv_len;
10892
10893 if ((param->args_count == 0)) {
10894 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10895 __func__, param->args_count);
10896 return QDF_STATUS_E_FAILURE;
10897 }
10898
10899 buf = wmi_buf_alloc(wmi_handle, len);
10900 if (!buf) {
10901 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10902 return QDF_STATUS_E_NOMEM;
10903 }
10904
10905 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10906 wmi_buf_data(buf);
10907 buf_ptr = (uint8_t *)cmd;
10908 WMITLV_SET_HDR(&cmd->tlv_header,
10909 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10910 WMITLV_GET_STRUCT_TLVLEN(
10911 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10912 cmd->vdev_id = param->vdev_id;
10913 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10914 cmd->cmd_id = param->cmd_id;
10915 cmd->args_count = param->args_count;
10916 buf_ptr += sizeof(
10917 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10918 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10919 (cmd->args_count * sizeof(A_UINT32)));
10920 buf_ptr += WMI_TLV_HDR_SIZE;
10921 node_config_args = (A_UINT32 *)buf_ptr;
10922
10923 for (i = 0; i < param->args_count; i++) {
10924 node_config_args[i] = param->args_arr[i];
10925 WMI_LOGI("%d", param->args_arr[i]);
10926 }
10927
10928 ret = wmi_unified_cmd_send(wmi_handle,
10929 buf,
10930 len,
10931 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10932
10933 if (ret != 0) {
10934 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10935 __func__, param->cmd_id, macaddr[0],
10936 macaddr[1], macaddr[2], macaddr[3],
10937 macaddr[4], macaddr[5], ret);
10938 wmi_buf_free(buf);
10939 }
10940
10941 return ret;
10942}
10943
10944/**
10945 * send_set_atf_cmd_tlv() - send set atf command to fw
10946 * @wmi_handle: wmi handle
10947 * @param: pointer to set atf param
10948 *
10949 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10950 */
10951static QDF_STATUS
10952send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10953 struct set_atf_params *param)
10954{
10955 wmi_atf_peer_info *peer_info;
10956 wmi_peer_atf_request_fixed_param *cmd;
10957 wmi_buf_t buf;
10958 uint8_t *buf_ptr;
10959 int i;
10960 int32_t len = 0;
10961 QDF_STATUS retval;
10962
10963 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10964 len += param->num_peers * sizeof(wmi_atf_peer_info);
10965 buf = wmi_buf_alloc(wmi_handle, len);
10966 if (!buf) {
10967 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10968 return QDF_STATUS_E_FAILURE;
10969 }
10970 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10971 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10972 WMITLV_SET_HDR(&cmd->tlv_header,
10973 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10974 WMITLV_GET_STRUCT_TLVLEN(
10975 wmi_peer_atf_request_fixed_param));
10976 cmd->num_peers = param->num_peers;
10977
10978 buf_ptr += sizeof(*cmd);
10979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10980 sizeof(wmi_atf_peer_info) *
10981 cmd->num_peers);
10982 buf_ptr += WMI_TLV_HDR_SIZE;
10983 peer_info = (wmi_atf_peer_info *)buf_ptr;
10984
10985 for (i = 0; i < cmd->num_peers; i++) {
10986 WMITLV_SET_HDR(&peer_info->tlv_header,
10987 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10988 WMITLV_GET_STRUCT_TLVLEN(
10989 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010990 qdf_mem_copy(&(peer_info->peer_macaddr),
10991 &(param->peer_info[i].peer_macaddr),
10992 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010993 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010994 peer_info->vdev_id = param->peer_info[i].vdev_id;
10995 peer_info->pdev_id =
10996 wmi_handle->ops->convert_pdev_id_host_to_target(
10997 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010998 /*
10999 * TLV definition for peer atf request fixed param combines
11000 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11001 * stats and atf extension stats as two different
11002 * implementations.
11003 * Need to discuss with FW on this.
11004 *
11005 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11006 * peer_info->atf_units_reserved =
11007 * param->peer_ext_info[i].atf_index_reserved;
11008 */
11009 peer_info++;
11010 }
11011
11012 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11013 WMI_PEER_ATF_REQUEST_CMDID);
11014
11015 if (retval != QDF_STATUS_SUCCESS) {
11016 WMI_LOGE("%s : WMI Failed\n", __func__);
11017 wmi_buf_free(buf);
11018 }
11019
11020 return retval;
11021}
11022
11023/**
11024 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11025 * @wmi_handle: wmi handle
11026 * @param: pointer to hold fwtest param
11027 *
11028 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11029 */
11030static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11031 struct set_fwtest_params *param)
11032{
11033 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11034 wmi_buf_t buf;
11035 int32_t len = sizeof(*cmd);
11036
11037 buf = wmi_buf_alloc(wmi_handle, len);
11038
11039 if (!buf) {
11040 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11041 return QDF_STATUS_E_FAILURE;
11042 }
11043
11044 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11045 WMITLV_SET_HDR(&cmd->tlv_header,
11046 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11047 WMITLV_GET_STRUCT_TLVLEN(
11048 wmi_fwtest_set_param_cmd_fixed_param));
11049 cmd->param_id = param->arg;
11050 cmd->param_value = param->value;
11051
11052 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11053 WMI_LOGE("Setting FW test param failed\n");
11054 wmi_buf_free(buf);
11055 return QDF_STATUS_E_FAILURE;
11056 }
11057
11058 return QDF_STATUS_SUCCESS;
11059}
11060
11061/**
11062 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11063 * @wmi_handle: wmi handle
11064 * @param: pointer to qboost params
11065 * @macaddr: vdev mac address
11066 *
11067 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11068 */
11069static QDF_STATUS
11070send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11071 uint8_t macaddr[IEEE80211_ADDR_LEN],
11072 struct set_qboost_params *param)
11073{
11074 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11075 wmi_buf_t buf;
11076 int32_t len;
11077 QDF_STATUS ret;
11078
11079 len = sizeof(*cmd);
11080
11081 buf = wmi_buf_alloc(wmi_handle, len);
11082 if (!buf) {
11083 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11084 return QDF_STATUS_E_FAILURE;
11085 }
11086
11087 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11088 WMITLV_SET_HDR(&cmd->tlv_header,
11089 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11090 WMITLV_GET_STRUCT_TLVLEN(
11091 WMI_QBOOST_CFG_CMD_fixed_param));
11092 cmd->vdev_id = param->vdev_id;
11093 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11094 cmd->qb_enable = param->value;
11095
11096 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11097 WMI_QBOOST_CFG_CMDID);
11098
11099 if (ret != 0) {
11100 WMI_LOGE("Setting qboost cmd failed\n");
11101 wmi_buf_free(buf);
11102 }
11103
11104 return ret;
11105}
11106
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011107/**
11108 * send_gpio_config_cmd_tlv() - send gpio config to fw
11109 * @wmi_handle: wmi handle
11110 * @param: pointer to hold gpio config param
11111 *
11112 * Return: 0 for success or error code
11113 */
11114static QDF_STATUS
11115send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11116 struct gpio_config_params *param)
11117{
11118 wmi_gpio_config_cmd_fixed_param *cmd;
11119 wmi_buf_t buf;
11120 int32_t len;
11121 QDF_STATUS ret;
11122
11123 len = sizeof(*cmd);
11124
11125 /* Sanity Checks */
11126 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11127 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11128 return QDF_STATUS_E_FAILURE;
11129 }
11130
11131 buf = wmi_buf_alloc(wmi_handle, len);
11132 if (!buf) {
11133 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11134 return QDF_STATUS_E_FAILURE;
11135 }
11136
11137 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11138 WMITLV_SET_HDR(&cmd->tlv_header,
11139 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11140 WMITLV_GET_STRUCT_TLVLEN(
11141 wmi_gpio_config_cmd_fixed_param));
11142 cmd->gpio_num = param->gpio_num;
11143 cmd->input = param->input;
11144 cmd->pull_type = param->pull_type;
11145 cmd->intr_mode = param->intr_mode;
11146
11147 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11148 WMI_GPIO_CONFIG_CMDID);
11149
11150 if (ret != 0) {
11151 WMI_LOGE("Sending GPIO config cmd failed\n");
11152 wmi_buf_free(buf);
11153 }
11154
11155 return ret;
11156}
11157
11158/**
11159 * send_gpio_output_cmd_tlv() - send gpio output to fw
11160 * @wmi_handle: wmi handle
11161 * @param: pointer to hold gpio output param
11162 *
11163 * Return: 0 for success or error code
11164 */
11165static QDF_STATUS
11166send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11167 struct gpio_output_params *param)
11168{
11169 wmi_gpio_output_cmd_fixed_param *cmd;
11170 wmi_buf_t buf;
11171 int32_t len;
11172 QDF_STATUS ret;
11173
11174 len = sizeof(*cmd);
11175
11176 buf = wmi_buf_alloc(wmi_handle, len);
11177 if (!buf) {
11178 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11179 return QDF_STATUS_E_FAILURE;
11180 }
11181
11182 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11183 WMITLV_SET_HDR(&cmd->tlv_header,
11184 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11185 WMITLV_GET_STRUCT_TLVLEN(
11186 wmi_gpio_output_cmd_fixed_param));
11187 cmd->gpio_num = param->gpio_num;
11188 cmd->set = param->set;
11189
11190 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11191 WMI_GPIO_OUTPUT_CMDID);
11192
11193 if (ret != 0) {
11194 WMI_LOGE("Sending GPIO output cmd failed\n");
11195 wmi_buf_free(buf);
11196 }
11197
11198 return ret;
11199
11200}
11201
11202/**
11203 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11204 *
11205 * @param wmi_handle : handle to WMI.
11206 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11207 */
11208static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11209{
11210 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11211 wmi_buf_t buf;
11212 QDF_STATUS ret;
11213 int32_t len;
11214
11215 len = sizeof(*cmd);
11216
11217 buf = wmi_buf_alloc(wmi_handle, len);
11218 if (!buf) {
11219 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11220 return QDF_STATUS_E_FAILURE;
11221 }
11222
11223 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11224 WMITLV_SET_HDR(&cmd->tlv_header,
11225 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11226 WMITLV_GET_STRUCT_TLVLEN(
11227 wmi_pdev_dfs_disable_cmd_fixed_param));
11228 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011229 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11230 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011231
11232 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11233 WMI_PDEV_DFS_DISABLE_CMDID);
11234
11235 if (ret != 0) {
11236 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11237 wmi_buf_free(buf);
11238 }
11239
11240 return ret;
11241}
11242
11243/**
11244 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11245 *
11246 * @param wmi_handle : handle to WMI.
11247 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11248 */
11249static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11250{
11251 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11252 wmi_buf_t buf;
11253 QDF_STATUS ret;
11254 int32_t len;
11255
11256 len = sizeof(*cmd);
11257
11258 buf = wmi_buf_alloc(wmi_handle, len);
11259 if (!buf) {
11260 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11261 return QDF_STATUS_E_FAILURE;
11262 }
11263
11264 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11265 WMITLV_SET_HDR(&cmd->tlv_header,
11266 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11267 WMITLV_GET_STRUCT_TLVLEN(
11268 wmi_pdev_dfs_enable_cmd_fixed_param));
11269 /* Reserved for future use */
11270 cmd->reserved0 = 0;
11271
11272 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11273 WMI_PDEV_DFS_ENABLE_CMDID);
11274
11275 if (ret != 0) {
11276 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11277 wmi_buf_free(buf);
11278 }
11279
11280 return ret;
11281}
11282
11283/**
11284 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11285 * @wmi_handle: wmi handle
11286 *
11287 * Return: 0 for success or error code
11288 */
11289static QDF_STATUS
11290send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
11291{
11292 wmi_buf_t buf;
11293 QDF_STATUS ret;
11294
11295 buf = wmi_buf_alloc(wmi_handle, 0);
11296 if (buf == NULL)
11297 return QDF_STATUS_E_NOMEM;
11298
11299 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
11300 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11301 if (ret != 0) {
11302 WMI_LOGE("Sending get nfcal power cmd failed\n");
11303 wmi_buf_free(buf);
11304 }
11305
11306 return ret;
11307}
11308
11309/**
11310 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11311 * @wmi_handle: wmi handle
11312 * @param: pointer to ht ie param
11313 *
11314 * Return: 0 for success or error code
11315 */
11316static QDF_STATUS
11317send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11318 struct ht_ie_params *param)
11319{
11320 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11321 wmi_buf_t buf;
11322 QDF_STATUS ret;
11323 int32_t len;
11324 uint8_t *buf_ptr;
11325
11326 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11327 roundup(param->ie_len, sizeof(uint32_t));
11328
11329 buf = wmi_buf_alloc(wmi_handle, len);
11330 if (!buf) {
11331 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11332 return QDF_STATUS_E_FAILURE;
11333 }
11334
11335 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11336 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11337 WMITLV_SET_HDR(&cmd->tlv_header,
11338 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11339 WMITLV_GET_STRUCT_TLVLEN(
11340 wmi_pdev_set_ht_ie_cmd_fixed_param));
11341 cmd->reserved0 = 0;
11342 cmd->ie_len = param->ie_len;
11343 cmd->tx_streams = param->tx_streams;
11344 cmd->rx_streams = param->rx_streams;
11345
11346 buf_ptr += sizeof(*cmd);
11347 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11348 buf_ptr += WMI_TLV_HDR_SIZE;
11349 if (param->ie_len)
11350 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11351 cmd->ie_len);
11352
11353 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11354 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11355
11356 if (ret != 0) {
11357 WMI_LOGE("Sending set ht ie cmd failed\n");
11358 wmi_buf_free(buf);
11359 }
11360
11361 return ret;
11362}
11363
11364/**
11365 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11366 * @wmi_handle: wmi handle
11367 * @param: pointer to vht ie param
11368 *
11369 * Return: 0 for success or error code
11370 */
11371static QDF_STATUS
11372send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11373 struct vht_ie_params *param)
11374{
11375 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11376 wmi_buf_t buf;
11377 QDF_STATUS ret;
11378 int32_t len;
11379 uint8_t *buf_ptr;
11380
11381 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11382 roundup(param->ie_len, sizeof(uint32_t));
11383
11384 buf = wmi_buf_alloc(wmi_handle, len);
11385 if (!buf) {
11386 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11387 return QDF_STATUS_E_FAILURE;
11388 }
11389
11390 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11391 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11392 WMITLV_SET_HDR(&cmd->tlv_header,
11393 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11394 WMITLV_GET_STRUCT_TLVLEN(
11395 wmi_pdev_set_vht_ie_cmd_fixed_param));
11396 cmd->reserved0 = 0;
11397 cmd->ie_len = param->ie_len;
11398 cmd->tx_streams = param->tx_streams;
11399 cmd->rx_streams = param->rx_streams;
11400
11401 buf_ptr += sizeof(*cmd);
11402 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11403 buf_ptr += WMI_TLV_HDR_SIZE;
11404 if (param->ie_len)
11405 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11406 cmd->ie_len);
11407
11408 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11409 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11410
11411 if (ret != 0) {
11412 WMI_LOGE("Sending set vht ie cmd failed\n");
11413 wmi_buf_free(buf);
11414 }
11415
11416 return ret;
11417}
11418
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011419/**
11420 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11421 * @wmi_handle: wmi handle
11422 * @param: pointer to quiet mode params
11423 *
11424 * Return: 0 for success or error code
11425 */
11426static QDF_STATUS
11427send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11428 struct set_quiet_mode_params *param)
11429{
11430 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11431 wmi_buf_t buf;
11432 QDF_STATUS ret;
11433 int32_t len;
11434
11435 len = sizeof(*quiet_cmd);
11436 buf = wmi_buf_alloc(wmi_handle, len);
11437 if (!buf) {
11438 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11439 return QDF_STATUS_E_FAILURE;
11440 }
11441
11442 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11443 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11444 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11445 WMITLV_GET_STRUCT_TLVLEN(
11446 wmi_pdev_set_quiet_cmd_fixed_param));
11447 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11448 quiet_cmd->enabled = param->enabled;
11449 quiet_cmd->period = (param->period)*(param->intval);
11450 quiet_cmd->duration = param->duration;
11451 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011452 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11453 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011454
11455 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11456 WMI_PDEV_SET_QUIET_MODE_CMDID);
11457
11458 if (ret != 0) {
11459 WMI_LOGE("Sending set quiet cmd failed\n");
11460 wmi_buf_free(buf);
11461 }
11462
11463 return ret;
11464}
11465
11466/**
11467 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11468 * @wmi_handle: wmi handle
11469 * @param: pointer to set bwf param
11470 *
11471 * Return: 0 for success or error code
11472 */
11473static QDF_STATUS
11474send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11475 struct set_bwf_params *param)
11476{
11477 wmi_bwf_peer_info *peer_info;
11478 wmi_peer_bwf_request_fixed_param *cmd;
11479 wmi_buf_t buf;
11480 QDF_STATUS retval;
11481 int32_t len;
11482 uint8_t *buf_ptr;
11483 int i;
11484
11485 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11486 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11487 buf = wmi_buf_alloc(wmi_handle, len);
11488 if (!buf) {
11489 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11490 return QDF_STATUS_E_FAILURE;
11491 }
11492 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11493 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11494 WMITLV_SET_HDR(&cmd->tlv_header,
11495 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11496 WMITLV_GET_STRUCT_TLVLEN(
11497 wmi_peer_bwf_request_fixed_param));
11498 cmd->num_peers = param->num_peers;
11499
11500 buf_ptr += sizeof(*cmd);
11501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11502 sizeof(wmi_bwf_peer_info) *
11503 cmd->num_peers);
11504 buf_ptr += WMI_TLV_HDR_SIZE;
11505 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11506
11507 for (i = 0; i < cmd->num_peers; i++) {
11508 WMITLV_SET_HDR(&peer_info->tlv_header,
11509 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11510 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11511 peer_info->bwf_guaranteed_bandwidth =
11512 param->peer_info[i].throughput;
11513 peer_info->bwf_max_airtime =
11514 param->peer_info[i].max_airtime;
11515 peer_info->bwf_peer_priority =
11516 param->peer_info[i].priority;
11517 qdf_mem_copy(&peer_info->peer_macaddr,
11518 &param->peer_info[i].peer_macaddr,
11519 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011520 peer_info->vdev_id =
11521 param->peer_info[i].vdev_id;
11522 peer_info->pdev_id =
11523 wmi_handle->ops->convert_pdev_id_host_to_target(
11524 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011525 peer_info++;
11526 }
11527
11528 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11529 WMI_PEER_BWF_REQUEST_CMDID);
11530
11531 if (retval != QDF_STATUS_SUCCESS) {
11532 WMI_LOGE("%s : WMI Failed\n", __func__);
11533 wmi_buf_free(buf);
11534 }
11535
11536 return retval;
11537}
11538
11539/**
11540 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11541 * @wmi_handle: wmi handle
11542 * @param: pointer to hold mcast update param
11543 *
11544 * Return: 0 for success or error code
11545 */
11546static QDF_STATUS
11547send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11548 struct mcast_group_update_params *param)
11549{
11550 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11551 wmi_buf_t buf;
11552 QDF_STATUS ret;
11553 int32_t len;
11554 int offset = 0;
11555 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11556
11557 len = sizeof(*cmd);
11558 buf = wmi_buf_alloc(wmi_handle, len);
11559 if (!buf) {
11560 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11561 return QDF_STATUS_E_FAILURE;
11562 }
11563 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11564 WMITLV_SET_HDR(&cmd->tlv_header,
11565 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11566 WMITLV_GET_STRUCT_TLVLEN(
11567 wmi_peer_mcast_group_cmd_fixed_param));
11568 /* confirm the buffer is 4-byte aligned */
11569 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11570 qdf_mem_zero(cmd, sizeof(*cmd));
11571
11572 cmd->vdev_id = param->vap_id;
11573 /* construct the message assuming our endianness matches the target */
11574 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11575 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11576 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11577 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11578 if (param->is_action_delete)
11579 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11580
11581 if (param->is_mcast_addr_len)
11582 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11583
11584 if (param->is_filter_mode_snoop)
11585 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11586
11587 /* unicast address spec only applies for non-wildcard cases */
11588 if (!param->wildcard && param->ucast_mac_addr) {
11589 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11590 &cmd->ucast_mac_addr);
11591 }
11592 if (param->mcast_ip_addr) {
11593 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11594 sizeof(cmd->mcast_ip_addr));
11595 offset = sizeof(cmd->mcast_ip_addr) -
11596 param->mcast_ip_addr_bytes;
11597 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11598 param->mcast_ip_addr,
11599 param->mcast_ip_addr_bytes);
11600 }
11601 if (!param->mask)
11602 param->mask = &dummymask[0];
11603
11604 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11605 param->mask,
11606 param->mcast_ip_addr_bytes);
11607
11608 if (param->srcs && param->nsrcs) {
11609 cmd->num_filter_addr = param->nsrcs;
11610 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11611 sizeof(cmd->filter_addr));
11612
11613 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11614 param->nsrcs * param->mcast_ip_addr_bytes);
11615 }
11616
11617 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11618 WMI_PEER_MCAST_GROUP_CMDID);
11619
11620 if (ret != QDF_STATUS_SUCCESS) {
11621 WMI_LOGE("%s : WMI Failed\n", __func__);
11622 wmi_buf_free(buf);
11623 }
11624
11625 return ret;
11626}
11627
11628/**
11629 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11630 * command to fw
11631 * @wmi_handle: wmi handle
11632 * @param: pointer to hold spectral config parameter
11633 *
11634 * Return: 0 for success or error code
11635 */
11636static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11637 struct vdev_spectral_configure_params *param)
11638{
11639 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11640 wmi_buf_t buf;
11641 QDF_STATUS ret;
11642 int32_t len;
11643
11644 len = sizeof(*cmd);
11645 buf = wmi_buf_alloc(wmi_handle, len);
11646 if (!buf) {
11647 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11648 return QDF_STATUS_E_FAILURE;
11649 }
11650
11651 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11652 WMITLV_SET_HDR(&cmd->tlv_header,
11653 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11654 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011655 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011656
11657 cmd->vdev_id = param->vdev_id;
11658 cmd->spectral_scan_count = param->count;
11659 cmd->spectral_scan_period = param->period;
11660 cmd->spectral_scan_priority = param->spectral_pri;
11661 cmd->spectral_scan_fft_size = param->fft_size;
11662 cmd->spectral_scan_gc_ena = param->gc_enable;
11663 cmd->spectral_scan_restart_ena = param->restart_enable;
11664 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11665 cmd->spectral_scan_init_delay = param->init_delay;
11666 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11667 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11668 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11669 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11670 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11671 cmd->spectral_scan_pwr_format = param->pwr_format;
11672 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11673 cmd->spectral_scan_bin_scale = param->bin_scale;
11674 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11675 cmd->spectral_scan_chn_mask = param->chn_mask;
11676
11677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11678 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11679
11680 if (ret != 0) {
11681 WMI_LOGE("Sending set quiet cmd failed\n");
11682 wmi_buf_free(buf);
11683 }
11684
11685 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11686 __func__);
11687
11688 WMI_LOGI("vdev_id = %u\n"
11689 "spectral_scan_count = %u\n"
11690 "spectral_scan_period = %u\n"
11691 "spectral_scan_priority = %u\n"
11692 "spectral_scan_fft_size = %u\n"
11693 "spectral_scan_gc_ena = %u\n"
11694 "spectral_scan_restart_ena = %u\n"
11695 "spectral_scan_noise_floor_ref = %u\n"
11696 "spectral_scan_init_delay = %u\n"
11697 "spectral_scan_nb_tone_thr = %u\n"
11698 "spectral_scan_str_bin_thr = %u\n"
11699 "spectral_scan_wb_rpt_mode = %u\n"
11700 "spectral_scan_rssi_rpt_mode = %u\n"
11701 "spectral_scan_rssi_thr = %u\n"
11702 "spectral_scan_pwr_format = %u\n"
11703 "spectral_scan_rpt_mode = %u\n"
11704 "spectral_scan_bin_scale = %u\n"
11705 "spectral_scan_dBm_adj = %u\n"
11706 "spectral_scan_chn_mask = %u\n",
11707 param->vdev_id,
11708 param->count,
11709 param->period,
11710 param->spectral_pri,
11711 param->fft_size,
11712 param->gc_enable,
11713 param->restart_enable,
11714 param->noise_floor_ref,
11715 param->init_delay,
11716 param->nb_tone_thr,
11717 param->str_bin_thr,
11718 param->wb_rpt_mode,
11719 param->rssi_rpt_mode,
11720 param->rssi_thr,
11721 param->pwr_format,
11722 param->rpt_mode,
11723 param->bin_scale,
11724 param->dBm_adj,
11725 param->chn_mask);
11726 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11727
11728 return ret;
11729}
11730
11731/**
11732 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11733 * command to fw
11734 * @wmi_handle: wmi handle
11735 * @param: pointer to hold spectral enable parameter
11736 *
11737 * Return: 0 for success or error code
11738 */
11739static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11740 struct vdev_spectral_enable_params *param)
11741{
11742 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11743 wmi_buf_t buf;
11744 QDF_STATUS ret;
11745 int32_t len;
11746
11747 len = sizeof(*cmd);
11748 buf = wmi_buf_alloc(wmi_handle, len);
11749 if (!buf) {
11750 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11751 return QDF_STATUS_E_FAILURE;
11752 }
11753
11754 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11755 WMITLV_SET_HDR(&cmd->tlv_header,
11756 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11757 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011758 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011759
11760 cmd->vdev_id = param->vdev_id;
11761
11762 if (param->active_valid) {
11763 cmd->trigger_cmd = param->active ? 1 : 2;
11764 /* 1: Trigger, 2: Clear Trigger */
11765 } else {
11766 cmd->trigger_cmd = 0; /* 0: Ignore */
11767 }
11768
11769 if (param->enabled_valid) {
11770 cmd->enable_cmd = param->enabled ? 1 : 2;
11771 /* 1: Enable 2: Disable */
11772 } else {
11773 cmd->enable_cmd = 0; /* 0: Ignore */
11774 }
11775
11776 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11777 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11778
11779 if (ret != 0) {
11780 WMI_LOGE("Sending scan enable CMD failed\n");
11781 wmi_buf_free(buf);
11782 }
11783
11784 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11785
11786 WMI_LOGI("vdev_id = %u\n"
11787 "trigger_cmd = %u\n"
11788 "enable_cmd = %u\n",
11789 cmd->vdev_id,
11790 cmd->trigger_cmd,
11791 cmd->enable_cmd);
11792
11793 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11794
11795 return ret;
11796}
11797
11798/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011799 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11800 * @param wmi_handle : handle to WMI.
11801 * @param param : pointer to hold thermal mitigation param
11802 *
11803 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11804 */
11805static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11806 wmi_unified_t wmi_handle,
11807 struct thermal_mitigation_params *param)
11808{
11809 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11810 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11811 wmi_buf_t buf = NULL;
11812 uint8_t *buf_ptr = NULL;
11813 int error;
11814 int32_t len;
11815 int i;
11816
11817 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11818 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11819
11820 buf = wmi_buf_alloc(wmi_handle, len);
11821 if (!buf) {
11822 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11823 return QDF_STATUS_E_NOMEM;
11824 }
11825 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11826
11827 /* init fixed params */
11828 WMITLV_SET_HDR(tt_conf,
11829 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11830 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11831
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011832 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11833 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011834 tt_conf->enable = param->enable;
11835 tt_conf->dc = param->dc;
11836 tt_conf->dc_per_event = param->dc_per_event;
11837 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11838
11839 buf_ptr = (uint8_t *) ++tt_conf;
11840 /* init TLV params */
11841 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11842 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11843
11844 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11845 for (i = 0; i < THERMAL_LEVELS; i++) {
11846 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11847 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11848 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11849 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11850 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11851 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11852 lvl_conf->prio = param->levelconf[i].priority;
11853 lvl_conf++;
11854 }
11855
11856 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11857 WMI_THERM_THROT_SET_CONF_CMDID);
11858 if (QDF_IS_STATUS_ERROR(error)) {
11859 wmi_buf_free(buf);
11860 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11861 }
11862
11863 return error;
11864}
11865
11866/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011867 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11868 * @wmi_handle: wmi handle
11869 * @param: pointer to pdev_qvit_params
11870 *
11871 * Return: 0 for success or error code
11872 */
11873static QDF_STATUS
11874send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11875 struct pdev_qvit_params *param)
11876{
11877 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011878 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011879 uint8_t *cmd;
11880 static uint8_t msgref = 1;
11881 uint8_t segnumber = 0, seginfo, numsegments;
11882 uint16_t chunk_len, total_bytes;
11883 uint8_t *bufpos;
11884 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11885
11886 bufpos = param->utf_payload;
11887 total_bytes = param->len;
11888 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11889 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11890 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11891
11892 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11893 numsegments++;
11894
11895 while (param->len) {
11896 if (param->len > MAX_WMI_QVIT_LEN)
11897 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11898 else
11899 chunk_len = param->len;
11900
11901 buf = wmi_buf_alloc(wmi_handle,
11902 (chunk_len + sizeof(seghdrinfo) +
11903 WMI_TLV_HDR_SIZE));
11904 if (!buf) {
11905 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11906 return QDF_STATUS_E_NOMEM;
11907 }
11908
11909 cmd = (uint8_t *) wmi_buf_data(buf);
11910
11911 seghdrinfo.len = total_bytes;
11912 seghdrinfo.msgref = msgref;
11913 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11914 seghdrinfo.segmentInfo = seginfo;
11915
11916 segnumber++;
11917
11918 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11919 (chunk_len + sizeof(seghdrinfo)));
11920 cmd += WMI_TLV_HDR_SIZE;
11921 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11922 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11923
11924 ret = wmi_unified_cmd_send(wmi_handle, buf,
11925 (chunk_len + sizeof(seghdrinfo) +
11926 WMI_TLV_HDR_SIZE),
11927 WMI_PDEV_QVIT_CMDID);
11928
11929 if (ret != 0) {
11930 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11931 wmi_buf_free(buf);
11932 break;
11933 }
11934
11935 param->len -= chunk_len;
11936 bufpos += chunk_len;
11937 }
11938 msgref++;
11939
11940 return ret;
11941}
11942
11943/**
11944 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11945 * @wmi_handle: wmi handle
11946 * @param: pointer to wmm update param
11947 *
11948 * Return: 0 for success or error code
11949 */
11950static QDF_STATUS
11951send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11952 struct wmm_update_params *param)
11953{
11954 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11955 wmi_wmm_params *wmm_param;
11956 wmi_buf_t buf;
11957 QDF_STATUS ret;
11958 int32_t len;
11959 int ac = 0;
11960 struct wmi_host_wmeParams *wmep;
11961 uint8_t *buf_ptr;
11962
11963 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11964 buf = wmi_buf_alloc(wmi_handle, len);
11965 if (!buf) {
11966 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11967 return QDF_STATUS_E_FAILURE;
11968 }
11969
11970 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11971 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11972 WMITLV_SET_HDR(&cmd->tlv_header,
11973 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11974 WMITLV_GET_STRUCT_TLVLEN
11975 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11976
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011977 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011978
11979 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11980
11981 for (ac = 0; ac < WME_NUM_AC; ac++) {
11982 wmep = &param->wmep_array[ac];
11983 wmm_param = (wmi_wmm_params *)buf_ptr;
11984 WMITLV_SET_HDR(&wmm_param->tlv_header,
11985 WMITLV_TAG_STRUC_wmi_wmm_params,
11986 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11987 wmm_param->aifs = wmep->wmep_aifsn;
11988 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11989 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11990 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11991 wmm_param->acm = wmep->wmep_acm;
11992 wmm_param->no_ack = wmep->wmep_noackPolicy;
11993 buf_ptr += sizeof(wmi_wmm_params);
11994 }
11995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11996 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11997
11998 if (ret != 0) {
11999 WMI_LOGE("Sending WMM update CMD failed\n");
12000 wmi_buf_free(buf);
12001 }
12002
12003 return ret;
12004}
12005
Sathish Kumar80f4f382017-04-24 11:36:00 +053012006/**
12007 * send_coex_config_cmd_tlv() - send coex config command to fw
12008 * @wmi_handle: wmi handle
12009 * @param: pointer to coex config param
12010 *
12011 * Return: 0 for success or error code
12012 */
12013static QDF_STATUS
12014send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12015 struct coex_config_params *param)
12016{
12017 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12018 wmi_buf_t buf;
12019 QDF_STATUS ret;
12020 int32_t len;
12021
12022 len = sizeof(*cmd);
12023 buf = wmi_buf_alloc(wmi_handle, len);
12024 if (!buf) {
12025 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12026 return QDF_STATUS_E_FAILURE;
12027 }
12028
12029 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12030 WMITLV_SET_HDR(&cmd->tlv_header,
12031 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12032 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012033 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012034
12035 cmd->vdev_id = param->vdev_id;
12036 cmd->config_type = param->config_type;
12037 cmd->config_arg1 = param->config_arg1;
12038 cmd->config_arg2 = param->config_arg2;
12039 cmd->config_arg3 = param->config_arg3;
12040 cmd->config_arg4 = param->config_arg4;
12041 cmd->config_arg5 = param->config_arg5;
12042 cmd->config_arg6 = param->config_arg6;
12043
12044 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12045 WMI_COEX_CONFIG_CMDID);
12046
12047 if (ret != 0) {
12048 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12049 wmi_buf_free(buf);
12050 }
12051
12052 return ret;
12053}
12054
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012055static
Govind Singh9ddd5162016-03-07 16:30:32 +053012056void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012057 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012058{
Govind Singhe7f2f342016-05-23 12:12:52 +053012059 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012060 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12061 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12062 resource_cfg->num_offload_reorder_buffs =
12063 tgt_res_cfg->num_offload_reorder_buffs;
12064 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12065 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12066 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12067 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12068 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12069 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12070 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12071 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12072 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12073 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12074 resource_cfg->scan_max_pending_req =
12075 tgt_res_cfg->scan_max_pending_req;
12076 resource_cfg->bmiss_offload_max_vdev =
12077 tgt_res_cfg->bmiss_offload_max_vdev;
12078 resource_cfg->roam_offload_max_vdev =
12079 tgt_res_cfg->roam_offload_max_vdev;
12080 resource_cfg->roam_offload_max_ap_profiles =
12081 tgt_res_cfg->roam_offload_max_ap_profiles;
12082 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12083 resource_cfg->num_mcast_table_elems =
12084 tgt_res_cfg->num_mcast_table_elems;
12085 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12086 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12087 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12088 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12089 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12090 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12091 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12092 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12093 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12094 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12095 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12096 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12097 resource_cfg->num_tdls_conn_table_entries =
12098 tgt_res_cfg->num_tdls_conn_table_entries;
12099 resource_cfg->beacon_tx_offload_max_vdev =
12100 tgt_res_cfg->beacon_tx_offload_max_vdev;
12101 resource_cfg->num_multicast_filter_entries =
12102 tgt_res_cfg->num_multicast_filter_entries;
12103 resource_cfg->num_wow_filters =
12104 tgt_res_cfg->num_wow_filters;
12105 resource_cfg->num_keep_alive_pattern =
12106 tgt_res_cfg->num_keep_alive_pattern;
12107 resource_cfg->keep_alive_pattern_size =
12108 tgt_res_cfg->keep_alive_pattern_size;
12109 resource_cfg->max_tdls_concurrent_sleep_sta =
12110 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12111 resource_cfg->max_tdls_concurrent_buffer_sta =
12112 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12113 resource_cfg->wmi_send_separate =
12114 tgt_res_cfg->wmi_send_separate;
12115 resource_cfg->num_ocb_vdevs =
12116 tgt_res_cfg->num_ocb_vdevs;
12117 resource_cfg->num_ocb_channels =
12118 tgt_res_cfg->num_ocb_channels;
12119 resource_cfg->num_ocb_schedules =
12120 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012121 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
12122 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12123 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012124
12125 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
12126 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053012127}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012128#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012129/**
12130 * send_init_cmd_tlv() - wmi init command
12131 * @wmi_handle: pointer to wmi handle
12132 * @res_cfg: resource config
12133 * @num_mem_chunks: no of mem chunck
12134 * @mem_chunk: pointer to mem chunck structure
12135 *
12136 * This function sends IE information to firmware
12137 *
Govind Singhb53420c2016-03-09 14:32:57 +053012138 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012139 *
12140 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012141static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012142 wmi_resource_config *tgt_res_cfg,
12143 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
12144 bool action)
12145{
12146 wmi_buf_t buf;
12147 wmi_init_cmd_fixed_param *cmd;
12148 wmi_abi_version my_vers;
12149 int num_whitelist;
12150 uint8_t *buf_ptr;
12151 wmi_resource_config *resource_cfg;
12152 wlan_host_memory_chunk *host_mem_chunks;
12153 uint32_t mem_chunk_len = 0;
12154 uint16_t idx;
12155 int len;
12156 int ret;
12157
12158 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
12159 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
12160 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
12161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012162 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
12163 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012164 }
12165
12166 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12167 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
12168 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
12169
12170 host_mem_chunks = (wlan_host_memory_chunk *)
12171 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
12172 + WMI_TLV_HDR_SIZE);
12173
12174 WMITLV_SET_HDR(&cmd->tlv_header,
12175 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
12176 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
12177
Govind Singhb53420c2016-03-09 14:32:57 +053012178 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053012179 WMITLV_SET_HDR(&resource_cfg->tlv_header,
12180 WMITLV_TAG_STRUC_wmi_resource_config,
12181 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
12182
12183 for (idx = 0; idx < num_mem_chunks; ++idx) {
12184 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
12185 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
12186 WMITLV_GET_STRUCT_TLVLEN
12187 (wlan_host_memory_chunk));
12188 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
12189 host_mem_chunks[idx].size = mem_chunks[idx].len;
12190 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053012191 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053012192 idx, host_mem_chunks[idx].size,
12193 host_mem_chunks[idx].ptr);
12194 }
12195 cmd->num_host_mem_chunks = num_mem_chunks;
12196 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
12197 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
12198 WMITLV_TAG_ARRAY_STRUC,
12199 (sizeof(wlan_host_memory_chunk) *
12200 num_mem_chunks));
12201
12202 num_whitelist = sizeof(version_whitelist) /
12203 sizeof(wmi_whitelist_version_info);
12204 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12205 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12206 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12207 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12208 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12209 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053012210#ifdef CONFIG_MCL
12211 /* This needs to be enabled for WIN Lithium after removing dependency
12212 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053012213 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12214 &my_vers,
12215 &wmi_handle->fw_abi_version,
12216 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053012217#endif
Govind Singhb53420c2016-03-09 14:32:57 +053012218 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053012219 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12220 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12221 cmd->host_abi_vers.abi_version_ns_0,
12222 cmd->host_abi_vers.abi_version_ns_1,
12223 cmd->host_abi_vers.abi_version_ns_2,
12224 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053012225#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012226 /* Save version sent from host -
12227 * Will be used to check ready event
12228 */
Govind Singhb53420c2016-03-09 14:32:57 +053012229 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012230 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012231#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012232 if (action) {
12233 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12234 WMI_INIT_CMDID);
12235 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053012236 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053012237 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012238 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012239 }
12240 } else {
12241 wmi_handle->saved_wmi_init_cmd.buf = buf;
12242 wmi_handle->saved_wmi_init_cmd.buf_len = len;
12243 }
12244
Govind Singhb53420c2016-03-09 14:32:57 +053012245 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012246
12247}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012248#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012249/**
12250 * send_saved_init_cmd_tlv() - wmi init command
12251 * @wmi_handle: pointer to wmi handle
12252 *
12253 * This function sends IE information to firmware
12254 *
Govind Singhb53420c2016-03-09 14:32:57 +053012255 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012256 *
12257 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012258static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053012259{
12260 int status;
12261
12262 if (!wmi_handle->saved_wmi_init_cmd.buf ||
12263 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053012264 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
12265 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012266 }
12267 status = wmi_unified_cmd_send(wmi_handle,
12268 wmi_handle->saved_wmi_init_cmd.buf,
12269 wmi_handle->saved_wmi_init_cmd.buf_len,
12270 WMI_INIT_CMDID);
12271 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053012272 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053012273 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012274 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012275 }
12276 wmi_handle->saved_wmi_init_cmd.buf = NULL;
12277 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
12278
Govind Singhb53420c2016-03-09 14:32:57 +053012279 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012280}
12281
Sathish Kumarfd347372017-02-13 12:29:09 +053012282static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012283{
12284 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12285 wmi_service_ready_event_fixed_param *ev;
12286
12287
12288 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12289
12290 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12291 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012292 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012293
Govind Singh87542482016-06-08 19:40:11 +053012294#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012295 /*Save fw version from service ready message */
12296 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012297 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012298 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012299#endif
Govind Singhb53420c2016-03-09 14:32:57 +053012300 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012301}
12302
12303/**
12304 * wmi_unified_save_fw_version_cmd() - save fw version
12305 * @wmi_handle: pointer to wmi handle
12306 * @res_cfg: resource config
12307 * @num_mem_chunks: no of mem chunck
12308 * @mem_chunk: pointer to mem chunck structure
12309 *
12310 * This function sends IE information to firmware
12311 *
Govind Singhb53420c2016-03-09 14:32:57 +053012312 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012313 *
12314 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012315static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012316 void *evt_buf)
12317{
12318 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12319 wmi_ready_event_fixed_param *ev = NULL;
12320
12321 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12322 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053012323#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012324 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
12325 &ev->fw_abi_vers)) {
12326 /*
12327 * Error: Our host version and the given firmware version
12328 * are incompatible.
12329 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012330 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012331 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12332 __func__,
12333 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12334 abi_version_0),
12335 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12336 abi_version_0),
12337 wmi_handle->final_abi_vers.abi_version_ns_0,
12338 wmi_handle->final_abi_vers.abi_version_ns_1,
12339 wmi_handle->final_abi_vers.abi_version_ns_2,
12340 wmi_handle->final_abi_vers.abi_version_ns_3,
12341 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12342 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12343 ev->fw_abi_vers.abi_version_ns_0,
12344 ev->fw_abi_vers.abi_version_ns_1,
12345 ev->fw_abi_vers.abi_version_ns_2,
12346 ev->fw_abi_vers.abi_version_ns_3);
12347
Govind Singhb53420c2016-03-09 14:32:57 +053012348 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012349 }
Govind Singhb53420c2016-03-09 14:32:57 +053012350 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012351 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012352 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012353 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012354#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012355
Govind Singhb53420c2016-03-09 14:32:57 +053012356 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012357}
Govind Singha4836fd2016-03-07 16:45:38 +053012358
12359/**
12360 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12361 * @wmi_handle: wmi handle
12362 * @custom_addr: base mac address
12363 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012364 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012365 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012366static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012367 uint8_t *custom_addr)
12368{
12369 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12370 wmi_buf_t buf;
12371 int err;
12372
12373 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12374 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012375 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012376 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012377 }
12378
12379 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012380 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012381
12382 WMITLV_SET_HDR(&cmd->tlv_header,
12383 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12384 WMITLV_GET_STRUCT_TLVLEN
12385 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12386 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012387 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12388 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012389 err = wmi_unified_cmd_send(wmi_handle, buf,
12390 sizeof(*cmd),
12391 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12392 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012393 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012394 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012395 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012396 }
12397
12398 return 0;
12399}
12400
12401/**
12402 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12403 * @handle: wmi handle
12404 * @event: Event received from FW
12405 * @len: Length of the event
12406 *
12407 * Enables the low frequency events and disables the high frequency
12408 * events. Bit 17 indicates if the event if low/high frequency.
12409 * 1 - high frequency, 0 - low frequency
12410 *
12411 * Return: 0 on successfully enabling/disabling the events
12412 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012413static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012414 uint8_t *event,
12415 uint32_t len)
12416{
12417 uint32_t num_of_diag_events_logs;
12418 wmi_diag_event_log_config_fixed_param *cmd;
12419 wmi_buf_t buf;
12420 uint8_t *buf_ptr;
12421 uint32_t *cmd_args, *evt_args;
12422 uint32_t buf_len, i;
12423
12424 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12425 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12426
Govind Singhb53420c2016-03-09 14:32:57 +053012427 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012428
12429 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12430 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012431 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012432 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012433 }
12434 wmi_event = param_buf->fixed_param;
12435 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12436 evt_args = param_buf->diag_events_logs_list;
12437 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012438 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012439 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012440 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012441 }
12442
Govind Singhb53420c2016-03-09 14:32:57 +053012443 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012444 __func__, num_of_diag_events_logs);
12445
12446 /* Free any previous allocation */
12447 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012448 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012449
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012450 if (num_of_diag_events_logs >
12451 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12452 WMI_LOGE("%s: excess num of logs:%d", __func__,
12453 num_of_diag_events_logs);
12454 QDF_ASSERT(0);
12455 return QDF_STATUS_E_INVAL;
12456 }
Govind Singha4836fd2016-03-07 16:45:38 +053012457 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012458 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012459 sizeof(uint32_t));
12460 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012461 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012462 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012463 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012464 }
12465 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12466
12467 /* Prepare the send buffer */
12468 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12469 (num_of_diag_events_logs * sizeof(uint32_t));
12470
12471 buf = wmi_buf_alloc(wmi_handle, buf_len);
12472 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012473 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12474 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012475 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012476 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012477 }
12478
12479 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12480 buf_ptr = (uint8_t *) cmd;
12481
12482 WMITLV_SET_HDR(&cmd->tlv_header,
12483 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12484 WMITLV_GET_STRUCT_TLVLEN(
12485 wmi_diag_event_log_config_fixed_param));
12486
12487 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12488
12489 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12490
12491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12492 (num_of_diag_events_logs * sizeof(uint32_t)));
12493
12494 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12495
12496 /* Populate the events */
12497 for (i = 0; i < num_of_diag_events_logs; i++) {
12498 /* Low freq (0) - Enable (1) the event
12499 * High freq (1) - Disable (0) the event
12500 */
12501 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12502 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12503 /* Set the event ID */
12504 WMI_DIAG_ID_SET(cmd_args[i],
12505 WMI_DIAG_ID_GET(evt_args[i]));
12506 /* Set the type */
12507 WMI_DIAG_TYPE_SET(cmd_args[i],
12508 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012509 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012510 wmi_handle->events_logs_list[i] = evt_args[i];
12511 }
12512
12513 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12514 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012515 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012516 __func__);
12517 wmi_buf_free(buf);
12518 /* Not clearing events_logs_list, though wmi cmd failed.
12519 * Host can still have this list
12520 */
Govind Singh67922e82016-04-01 16:48:57 +053012521 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012522 }
12523
12524 return 0;
12525}
12526
12527/**
12528 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12529 * @wmi_handle: wmi handle
12530 * @start_log: Start logging related parameters
12531 *
12532 * Send the command to the FW based on which specific logging of diag
12533 * event/log id can be started/stopped
12534 *
12535 * Return: None
12536 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012537static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012538 struct wmi_wifi_start_log *start_log)
12539{
12540 wmi_diag_event_log_config_fixed_param *cmd;
12541 wmi_buf_t buf;
12542 uint8_t *buf_ptr;
12543 uint32_t len, count, log_level, i;
12544 uint32_t *cmd_args;
12545 uint32_t total_len;
12546 count = 0;
12547
12548 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012549 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012550 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012551 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012552 }
12553 /* total_len stores the number of events where BITS 17 and 18 are set.
12554 * i.e., events of high frequency (17) and for extended debugging (18)
12555 */
12556 total_len = 0;
12557 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12558 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12559 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12560 total_len++;
12561 }
12562
12563 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12564 (total_len * sizeof(uint32_t));
12565
12566 buf = wmi_buf_alloc(wmi_handle, len);
12567 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012568 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012569 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012570 }
12571 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12572 buf_ptr = (uint8_t *) cmd;
12573
12574 WMITLV_SET_HDR(&cmd->tlv_header,
12575 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12576 WMITLV_GET_STRUCT_TLVLEN(
12577 wmi_diag_event_log_config_fixed_param));
12578
12579 cmd->num_of_diag_events_logs = total_len;
12580
12581 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12582
12583 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12584 (total_len * sizeof(uint32_t)));
12585
12586 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12587
Govind Singh224a7312016-06-21 14:33:26 +053012588 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012589 log_level = 1;
12590 else
12591 log_level = 0;
12592
Govind Singhb53420c2016-03-09 14:32:57 +053012593 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012594 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12595 uint32_t val = wmi_handle->events_logs_list[i];
12596 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12597 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12598
12599 WMI_DIAG_ID_SET(cmd_args[count],
12600 WMI_DIAG_ID_GET(val));
12601 WMI_DIAG_TYPE_SET(cmd_args[count],
12602 WMI_DIAG_TYPE_GET(val));
12603 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12604 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012605 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012606 count++;
12607 }
12608 }
12609
12610 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12611 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012612 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012613 __func__);
12614 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012615 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012616 }
12617
Govind Singhb53420c2016-03-09 14:32:57 +053012618 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012619}
12620
12621/**
12622 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12623 * @wmi_handle: WMI handle
12624 *
12625 * This function is used to send the flush command to the FW,
12626 * that will flush the fw logs that are residue in the FW
12627 *
12628 * Return: None
12629 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012630static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012631{
12632 wmi_debug_mesg_flush_fixed_param *cmd;
12633 wmi_buf_t buf;
12634 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012635 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012636
12637 buf = wmi_buf_alloc(wmi_handle, len);
12638 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012639 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012640 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012641 }
12642
12643 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12644 WMITLV_SET_HDR(&cmd->tlv_header,
12645 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12646 WMITLV_GET_STRUCT_TLVLEN(
12647 wmi_debug_mesg_flush_fixed_param));
12648 cmd->reserved0 = 0;
12649
12650 ret = wmi_unified_cmd_send(wmi_handle,
12651 buf,
12652 len,
12653 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012654 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012655 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012656 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012657 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012658 }
Govind Singhb53420c2016-03-09 14:32:57 +053012659 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012660
Govind Singh67922e82016-04-01 16:48:57 +053012661 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012662}
12663
12664/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012665 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012666 * @wmi_handle: wmi handle
12667 * @msg: PCL structure containing the PCL and the number of channels
12668 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012669 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012670 * firmware. The DBS Manager is the consumer of this information in the WLAN
12671 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12672 * to migrate to a new channel without host driver involvement. An example of
12673 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12674 * manage the channel selection without firmware involvement.
12675 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012676 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12677 * channel list. The weights corresponds to the channels sent in
12678 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12679 * weightage compared to the non PCL channels.
12680 *
Govind Singha4836fd2016-03-07 16:45:38 +053012681 * Return: Success if the cmd is sent successfully to the firmware
12682 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012683static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012684 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012685{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012686 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012687 wmi_buf_t buf;
12688 uint8_t *buf_ptr;
12689 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012690 uint32_t chan_len;
12691
12692 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012693
12694 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012695 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012696
12697 buf = wmi_buf_alloc(wmi_handle, len);
12698 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012699 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12700 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012701 }
12702
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012703 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012704 buf_ptr = (uint8_t *) cmd;
12705 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012706 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12707 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012708
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012709 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12710 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012711 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012712 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012713
12714 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012715 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012716 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012717 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012718 for (i = 0; i < chan_len ; i++) {
12719 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012720 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012721 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012722 }
12723 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012724 WMI_PDEV_SET_PCL_CMDID)) {
12725 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012726 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012727 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012728 }
Govind Singhb53420c2016-03-09 14:32:57 +053012729 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012730}
12731
12732/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012733 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012734 * @wmi_handle: wmi handle
12735 * @msg: Structure containing the following parameters
12736 *
12737 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12738 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12739 *
12740 * Provides notification to the WLAN firmware that host driver is requesting a
12741 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12742 * configurations that include the Dual Band Simultaneous (DBS) feature.
12743 *
12744 * Return: Success if the cmd is sent successfully to the firmware
12745 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012746static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012747 uint32_t hw_mode_index)
12748{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012749 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012750 wmi_buf_t buf;
12751 uint32_t len;
12752
12753 len = sizeof(*cmd);
12754
12755 buf = wmi_buf_alloc(wmi_handle, len);
12756 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012757 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12758 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012759 }
12760
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012761 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012762 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012763 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12764 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12765
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012766 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12767 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012768 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012769 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012770
12771 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012772 WMI_PDEV_SET_HW_MODE_CMDID)) {
12773 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012774 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012775 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012776 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012777 }
12778
Govind Singhb53420c2016-03-09 14:32:57 +053012779 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012780}
12781
12782/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012783 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012784 * @wmi_handle: wmi handle
12785 * @msg: Dual MAC config parameters
12786 *
12787 * Configures WLAN firmware with the dual MAC features
12788 *
Govind Singhb53420c2016-03-09 14:32:57 +053012789 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012790 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012791static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012792QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012793 struct wmi_dual_mac_config *msg)
12794{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012795 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012796 wmi_buf_t buf;
12797 uint32_t len;
12798
12799 len = sizeof(*cmd);
12800
12801 buf = wmi_buf_alloc(wmi_handle, len);
12802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012803 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12804 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012805 }
12806
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012807 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012808 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012809 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012810 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012811 wmi_pdev_set_mac_config_cmd_fixed_param));
12812
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012813 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12814 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012815 cmd->concurrent_scan_config_bits = msg->scan_config;
12816 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012817 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012818 __func__, msg->scan_config, msg->fw_mode_config);
12819
12820 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012821 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12822 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012823 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012824 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012825 }
Govind Singhb53420c2016-03-09 14:32:57 +053012826 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012827}
12828
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012829#ifdef BIG_ENDIAN_HOST
12830/**
12831* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12832* @param data_len - data length
12833* @param data - pointer to data
12834*
12835* Return: QDF_STATUS - success or error status
12836*/
12837static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12838 struct fips_params *param)
12839{
12840 unsigned char *key_unaligned, *data_unaligned;
12841 int c;
12842 u_int8_t *key_aligned = NULL;
12843 u_int8_t *data_aligned = NULL;
12844
12845 /* Assigning unaligned space to copy the key */
12846 key_unaligned = qdf_mem_malloc(
12847 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12848 data_unaligned = qdf_mem_malloc(
12849 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12850
12851 /* Checking if kmalloc is succesful to allocate space */
12852 if (key_unaligned == NULL)
12853 return QDF_STATUS_SUCCESS;
12854 /* Checking if space is aligned */
12855 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12856 /* align to 4 */
12857 key_aligned =
12858 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12859 FIPS_ALIGN);
12860 } else {
12861 key_aligned = (u_int8_t *)key_unaligned;
12862 }
12863
12864 /* memset and copy content from key to key aligned */
12865 OS_MEMSET(key_aligned, 0, param->key_len);
12866 OS_MEMCPY(key_aligned, param->key, param->key_len);
12867
12868 /* print a hexdump for host debug */
12869 print_hex_dump(KERN_DEBUG,
12870 "\t Aligned and Copied Key:@@@@ ",
12871 DUMP_PREFIX_NONE,
12872 16, 1, key_aligned, param->key_len, true);
12873
12874 /* Checking if kmalloc is succesful to allocate space */
12875 if (data_unaligned == NULL)
12876 return QDF_STATUS_SUCCESS;
12877 /* Checking of space is aligned */
12878 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12879 /* align to 4 */
12880 data_aligned =
12881 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12882 FIPS_ALIGN);
12883 } else {
12884 data_aligned = (u_int8_t *)data_unaligned;
12885 }
12886
12887 /* memset and copy content from data to data aligned */
12888 OS_MEMSET(data_aligned, 0, param->data_len);
12889 OS_MEMCPY(data_aligned, param->data, param->data_len);
12890
12891 /* print a hexdump for host debug */
12892 print_hex_dump(KERN_DEBUG,
12893 "\t Properly Aligned and Copied Data:@@@@ ",
12894 DUMP_PREFIX_NONE,
12895 16, 1, data_aligned, param->data_len, true);
12896
12897 /* converting to little Endian both key_aligned and
12898 * data_aligned*/
12899 for (c = 0; c < param->key_len/4; c++) {
12900 *((u_int32_t *)key_aligned+c) =
12901 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12902 }
12903 for (c = 0; c < param->data_len/4; c++) {
12904 *((u_int32_t *)data_aligned+c) =
12905 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12906 }
12907
12908 /* update endian data to key and data vectors */
12909 OS_MEMCPY(param->key, key_aligned, param->key_len);
12910 OS_MEMCPY(param->data, data_aligned, param->data_len);
12911
12912 /* clean up allocated spaces */
12913 qdf_mem_free(key_unaligned);
12914 key_unaligned = NULL;
12915 key_aligned = NULL;
12916
12917 qdf_mem_free(data_unaligned);
12918 data_unaligned = NULL;
12919 data_aligned = NULL;
12920
12921 return QDF_STATUS_SUCCESS;
12922}
12923#else
12924/**
12925* fips_align_data_be() - DUMMY for LE platform
12926*
12927* Return: QDF_STATUS - success
12928*/
12929static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12930 struct fips_params *param)
12931{
12932 return QDF_STATUS_SUCCESS;
12933}
12934#endif
12935
12936
12937/**
12938 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12939 * @wmi_handle: wmi handle
12940 * @param: pointer to hold pdev fips param
12941 *
12942 * Return: 0 for success or error code
12943 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012944static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012945send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12946 struct fips_params *param)
12947{
12948 wmi_pdev_fips_cmd_fixed_param *cmd;
12949 wmi_buf_t buf;
12950 uint8_t *buf_ptr;
12951 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12952 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12953
12954 /* Length TLV placeholder for array of bytes */
12955 len += WMI_TLV_HDR_SIZE;
12956 if (param->data_len)
12957 len += (param->data_len*sizeof(uint8_t));
12958
12959 /*
12960 * Data length must be multiples of 16 bytes - checked against 0xF -
12961 * and must be less than WMI_SVC_MSG_SIZE - static size of
12962 * wmi_pdev_fips_cmd structure
12963 */
12964
12965 /* do sanity on the input */
12966 if (!(((param->data_len & 0xF) == 0) &&
12967 ((param->data_len > 0) &&
12968 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12969 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12970 return QDF_STATUS_E_INVAL;
12971 }
12972
12973 buf = wmi_buf_alloc(wmi_handle, len);
12974 if (!buf) {
12975 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12976 return QDF_STATUS_E_FAILURE;
12977 }
12978
12979 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12980 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12981 WMITLV_SET_HDR(&cmd->tlv_header,
12982 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12983 WMITLV_GET_STRUCT_TLVLEN
12984 (wmi_pdev_fips_cmd_fixed_param));
12985
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012986 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12987 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012988 if (param->key != NULL && param->data != NULL) {
12989 cmd->key_len = param->key_len;
12990 cmd->data_len = param->data_len;
12991 cmd->fips_cmd = !!(param->op);
12992
12993 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12994 return QDF_STATUS_E_FAILURE;
12995
12996 qdf_mem_copy(cmd->key, param->key, param->key_len);
12997
12998 if (param->mode == FIPS_ENGINE_AES_CTR ||
12999 param->mode == FIPS_ENGINE_AES_MIC) {
13000 cmd->mode = param->mode;
13001 } else {
13002 cmd->mode = FIPS_ENGINE_AES_CTR;
13003 }
13004 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13005 cmd->key_len, cmd->data_len);
13006
13007 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13008 cmd->key, cmd->key_len, true);
13009 buf_ptr += sizeof(*cmd);
13010
13011 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13012
13013 buf_ptr += WMI_TLV_HDR_SIZE;
13014 if (param->data_len)
13015 qdf_mem_copy(buf_ptr,
13016 (uint8_t *) param->data, param->data_len);
13017
13018 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13019 16, 1, buf_ptr, cmd->data_len, true);
13020
13021 buf_ptr += param->data_len;
13022
13023 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13024 WMI_PDEV_FIPS_CMDID);
13025 qdf_print("%s return value %d\n", __func__, retval);
13026 } else {
13027 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13028 wmi_buf_free(buf);
13029 retval = -QDF_STATUS_E_BADMSG;
13030 }
13031
13032 return retval;
13033}
13034
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013035#ifdef WLAN_PMO_ENABLE
13036/**
13037 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13038 * @wmi_handle: wmi handle
13039 * @vdev_id: vdev id
13040 * @bitmap: Event bitmap
13041 * @enable: enable/disable
13042 *
13043 * Return: CDF status
13044 */
13045static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13046 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013047 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013048 bool enable)
13049{
13050 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13051 uint16_t len;
13052 wmi_buf_t buf;
13053 int ret;
13054
13055 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13056 buf = wmi_buf_alloc(wmi_handle, len);
13057 if (!buf) {
13058 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13059 return QDF_STATUS_E_NOMEM;
13060 }
13061 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13062 WMITLV_SET_HDR(&cmd->tlv_header,
13063 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13064 WMITLV_GET_STRUCT_TLVLEN
13065 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13066 cmd->vdev_id = vdev_id;
13067 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013068 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13069 WMI_WOW_MAX_EVENT_BM_LEN);
13070
13071 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13072 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13073 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013074
13075 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13076 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13077 if (ret) {
13078 WMI_LOGE("Failed to config wow wakeup event");
13079 wmi_buf_free(buf);
13080 return QDF_STATUS_E_FAILURE;
13081 }
13082
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013083 return QDF_STATUS_SUCCESS;
13084}
13085
13086/**
13087 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13088 * @wmi_handle: wmi handle
13089 * @vdev_id: vdev id
13090 * @ptrn_id: pattern id
13091 * @ptrn: pattern
13092 * @ptrn_len: pattern length
13093 * @ptrn_offset: pattern offset
13094 * @mask: mask
13095 * @mask_len: mask length
13096 * @user: true for user configured pattern and false for default pattern
13097 * @default_patterns: default patterns
13098 *
13099 * Return: CDF status
13100 */
13101static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13102 uint8_t vdev_id, uint8_t ptrn_id,
13103 const uint8_t *ptrn, uint8_t ptrn_len,
13104 uint8_t ptrn_offset, const uint8_t *mask,
13105 uint8_t mask_len, bool user,
13106 uint8_t default_patterns)
13107{
13108 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13109 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13110 wmi_buf_t buf;
13111 uint8_t *buf_ptr;
13112 int32_t len;
13113 int ret;
13114
13115 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13116 WMI_TLV_HDR_SIZE +
13117 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13118 WMI_TLV_HDR_SIZE +
13119 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13120 WMI_TLV_HDR_SIZE +
13121 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13122 WMI_TLV_HDR_SIZE +
13123 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13124 WMI_TLV_HDR_SIZE +
13125 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13126
13127 buf = wmi_buf_alloc(wmi_handle, len);
13128 if (!buf) {
13129 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13130 return QDF_STATUS_E_NOMEM;
13131 }
13132
13133 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13134 buf_ptr = (uint8_t *) cmd;
13135
13136 WMITLV_SET_HDR(&cmd->tlv_header,
13137 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13138 WMITLV_GET_STRUCT_TLVLEN
13139 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13140 cmd->vdev_id = vdev_id;
13141 cmd->pattern_id = ptrn_id;
13142
13143 cmd->pattern_type = WOW_BITMAP_PATTERN;
13144 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13145
13146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13147 sizeof(WOW_BITMAP_PATTERN_T));
13148 buf_ptr += WMI_TLV_HDR_SIZE;
13149 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13150
13151 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13152 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13153 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13154
13155 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13156 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13157
13158 bitmap_pattern->pattern_offset = ptrn_offset;
13159 bitmap_pattern->pattern_len = ptrn_len;
13160
13161 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13162 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13163
13164 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13165 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13166
13167 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13168 bitmap_pattern->pattern_id = ptrn_id;
13169
13170 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13171 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13172 bitmap_pattern->pattern_offset, user);
13173 WMI_LOGI("Pattern : ");
13174 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13175 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13176
13177 WMI_LOGI("Mask : ");
13178 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13179 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13180
13181 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13182
13183 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13185 buf_ptr += WMI_TLV_HDR_SIZE;
13186
13187 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13188 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13189 buf_ptr += WMI_TLV_HDR_SIZE;
13190
13191 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13192 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13193 buf_ptr += WMI_TLV_HDR_SIZE;
13194
13195 /* Fill TLV for pattern_info_timeout but no data. */
13196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13197 buf_ptr += WMI_TLV_HDR_SIZE;
13198
13199 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
13200 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
13201 buf_ptr += WMI_TLV_HDR_SIZE;
13202 *(A_UINT32 *) buf_ptr = 0;
13203
13204 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13205 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13206 if (ret) {
13207 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13208 wmi_buf_free(buf);
13209 return QDF_STATUS_E_FAILURE;
13210 }
13211
13212 return QDF_STATUS_SUCCESS;
13213}
13214
Govind Singha4836fd2016-03-07 16:45:38 +053013215/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013216 * fill_arp_offload_params_tlv() - Fill ARP offload data
13217 * @wmi_handle: wmi handle
13218 * @offload_req: offload request
13219 * @buf_ptr: buffer pointer
13220 *
13221 * To fill ARP offload data to firmware
13222 * when target goes to wow mode.
13223 *
13224 * Return: None
13225 */
13226static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013227 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013228{
13229
13230 int i;
13231 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013232 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013233
13234 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13235 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13236 *buf_ptr += WMI_TLV_HDR_SIZE;
13237 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13238 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13239 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13240 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13241 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13242
13243 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013244 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013245 /* Copy the target ip addr and flags */
13246 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13247 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013248 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013249 WMI_IPV4_ADDR_LEN);
13250 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013251 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013252 }
13253 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13254 }
13255}
13256
13257#ifdef WLAN_NS_OFFLOAD
13258/**
13259 * fill_ns_offload_params_tlv() - Fill NS offload data
13260 * @wmi|_handle: wmi handle
13261 * @offload_req: offload request
13262 * @buf_ptr: buffer pointer
13263 *
13264 * To fill NS offload data to firmware
13265 * when target goes to wow mode.
13266 *
13267 * Return: None
13268 */
13269static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013270 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013271{
13272
13273 int i;
13274 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013275
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013276 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13277 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13278 *buf_ptr += WMI_TLV_HDR_SIZE;
13279 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13280 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13281 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13282 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13283 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13284
13285 /*
13286 * Fill data only for NS offload in the first ARP tuple for LA
13287 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013288 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013289 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13290 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013291 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013292 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013293 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013294 sizeof(WMI_IPV6_ADDR));
13295 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013296 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013297 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013298 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013299 ns_tuple->flags |=
13300 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13301 }
13302 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013303 i, &ns_req->self_ipv6_addr[i],
13304 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013305
13306 /* target MAC is optional, check if it is valid,
13307 * if this is not valid, the target will use the known
13308 * local MAC address rather than the tuple
13309 */
13310 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013311 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013312 &ns_tuple->target_mac);
13313 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13314 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13315 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13316 }
13317 }
13318 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13319 }
13320}
13321
13322
13323/**
13324 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13325 * @wmi: wmi handle
13326 * @offload_req: offload request
13327 * @buf_ptr: buffer pointer
13328 *
13329 * To fill extended NS offload extended data to firmware
13330 * when target goes to wow mode.
13331 *
13332 * Return: None
13333 */
13334static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013335 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013336{
13337 int i;
13338 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13339 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013340
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013341 count = ns_req->num_ns_offload_count;
13342 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013343 WMI_MAX_NS_OFFLOADS;
13344
13345 /* Populate extended NS offload tuples */
13346 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13347 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13348 *buf_ptr += WMI_TLV_HDR_SIZE;
13349 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13350 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13351 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13352 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13353 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13354
13355 /*
13356 * Fill data only for NS offload in the first ARP tuple for LA
13357 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013358 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013359 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13360 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013361 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013362 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013363 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013364 sizeof(WMI_IPV6_ADDR));
13365 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013366 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013367 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013368 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013369 ns_tuple->flags |=
13370 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13371 }
13372 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013373 i, &ns_req->self_ipv6_addr[i],
13374 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013375
13376 /* target MAC is optional, check if it is valid,
13377 * if this is not valid, the target will use the
13378 * known local MAC address rather than the tuple
13379 */
13380 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013381 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013382 &ns_tuple->target_mac);
13383 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13384 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13385 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13386 }
13387 }
13388 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13389 }
13390}
13391#else
13392static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013393 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013394{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013395}
13396
13397static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013398 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013399{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013400}
13401#endif
13402
13403/**
Govind Singha4836fd2016-03-07 16:45:38 +053013404 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13405 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013406 * @arp_offload_req: arp offload request
13407 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013408 * @arp_only: flag
13409 *
13410 * To configure ARP NS off load data to firmware
13411 * when target goes to wow mode.
13412 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013413 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013414 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013415static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013416 struct pmo_arp_offload_params *arp_offload_req,
13417 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013418 uint8_t vdev_id)
13419{
Govind Singha4836fd2016-03-07 16:45:38 +053013420 int32_t res;
13421 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013422 A_UINT8 *buf_ptr;
13423 wmi_buf_t buf;
13424 int32_t len;
13425 uint32_t count = 0, num_ns_ext_tuples = 0;
13426
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013427 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013428
Govind Singha4836fd2016-03-07 16:45:38 +053013429 /*
13430 * TLV place holder size for array of NS tuples
13431 * TLV place holder size for array of ARP tuples
13432 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013433 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13434 WMI_TLV_HDR_SIZE +
13435 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13436 WMI_TLV_HDR_SIZE +
13437 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013438
13439 /*
13440 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13441 * extra length for extended NS offload tuples which follows ARP offload
13442 * tuples. Host needs to fill this structure in following format:
13443 * 2 NS ofload tuples
13444 * 2 ARP offload tuples
13445 * N numbers of extended NS offload tuples if HDD has given more than
13446 * 2 NS offload addresses
13447 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013448 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013449 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013450 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13451 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013452 }
13453
13454 buf = wmi_buf_alloc(wmi_handle, len);
13455 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013456 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013457 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013458 }
13459
13460 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13461 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13462 WMITLV_SET_HDR(&cmd->tlv_header,
13463 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13464 WMITLV_GET_STRUCT_TLVLEN
13465 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13466 cmd->flags = 0;
13467 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013468 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013469
Govind Singhb53420c2016-03-09 14:32:57 +053013470 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013471
Govind Singha4836fd2016-03-07 16:45:38 +053013472 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013473 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13474 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13475 if (num_ns_ext_tuples)
13476 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013477
13478 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13479 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13480 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013481 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013482 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013483 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013484 }
13485
Govind Singhb53420c2016-03-09 14:32:57 +053013486 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013487}
13488
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013489/**
13490 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13491 * @wmi_handle: wmi handle
13492 * @vdev_id: vdev id
13493 * @action: true for enable else false
13494 *
13495 * To enable enhance multicast offload to firmware
13496 * when target goes to wow mode.
13497 *
13498 * Return: QDF Status
13499 */
13500
13501static
13502QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13503 wmi_unified_t wmi_handle,
13504 uint8_t vdev_id, bool action)
13505{
13506 QDF_STATUS status;
13507 wmi_buf_t buf;
13508 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13509
13510 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13511 if (!buf) {
13512 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13513 return QDF_STATUS_E_NOMEM;
13514 }
13515
13516 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13517 wmi_buf_data(buf);
13518
13519 WMITLV_SET_HDR(&cmd->tlv_header,
13520 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13521 WMITLV_GET_STRUCT_TLVLEN(
13522 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13523
13524 cmd->vdev_id = vdev_id;
13525 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13526 ENHANCED_MCAST_FILTER_ENABLED);
13527 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13528 __func__, action, vdev_id);
13529 status = wmi_unified_cmd_send(wmi_handle, buf,
13530 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13531 if (status != QDF_STATUS_SUCCESS) {
13532 qdf_nbuf_free(buf);
13533 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13534 __func__);
13535 }
13536
13537 return status;
13538}
13539
13540/**
13541 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13542 * @wmi_handle: wmi handle
13543 * @param evt_buf: pointer to event buffer
13544 * @param hdr: Pointer to hold header
13545 * @param bufp: Pointer to hold pointer to rx param buffer
13546 *
13547 * Return: QDF_STATUS_SUCCESS for success or error code
13548 */
13549static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13550 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13551{
13552 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13553 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13554
13555 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13556 if (!param_buf) {
13557 WMI_LOGE("gtk param_buf is NULL");
13558 return QDF_STATUS_E_INVAL;
13559 }
13560
13561 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13562 WMI_LOGE("Invalid length for GTK status");
13563 return QDF_STATUS_E_INVAL;
13564 }
13565
13566 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13567 param_buf->fixed_param;
13568 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13569 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13570 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13571 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13572 &fixed_param->replay_counter,
13573 GTK_REPLAY_COUNTER_BYTES);
13574
13575 return QDF_STATUS_SUCCESS;
13576
13577}
13578
13579#ifdef FEATURE_WLAN_RA_FILTERING
13580/**
13581 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13582 * @wmi_handle: wmi handle
13583 * @vdev_id: vdev id
13584 *
13585 * Return: CDF status
13586 */
13587static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13588 uint8_t vdev_id, uint8_t default_pattern,
13589 uint16_t rate_limit_interval)
13590{
13591
13592 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13593 wmi_buf_t buf;
13594 uint8_t *buf_ptr;
13595 int32_t len;
13596 int ret;
13597
13598 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13599 WMI_TLV_HDR_SIZE +
13600 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13601 WMI_TLV_HDR_SIZE +
13602 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13603 WMI_TLV_HDR_SIZE +
13604 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13605 WMI_TLV_HDR_SIZE +
13606 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13607 WMI_TLV_HDR_SIZE +
13608 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13609
13610 buf = wmi_buf_alloc(wmi_handle, len);
13611 if (!buf) {
13612 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13613 return QDF_STATUS_E_NOMEM;
13614 }
13615
13616 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13617 buf_ptr = (uint8_t *) cmd;
13618
13619 WMITLV_SET_HDR(&cmd->tlv_header,
13620 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13621 WMITLV_GET_STRUCT_TLVLEN
13622 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13623 cmd->vdev_id = vdev_id;
13624 cmd->pattern_id = default_pattern,
13625 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13626 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13627
13628 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13630 buf_ptr += WMI_TLV_HDR_SIZE;
13631
13632 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13633 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13634 buf_ptr += WMI_TLV_HDR_SIZE;
13635
13636 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13638 buf_ptr += WMI_TLV_HDR_SIZE;
13639
13640 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13642 buf_ptr += WMI_TLV_HDR_SIZE;
13643
13644 /* Fill TLV for pattern_info_timeout but no data. */
13645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13646 buf_ptr += WMI_TLV_HDR_SIZE;
13647
13648 /* Fill TLV for ra_ratelimit_interval. */
13649 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13650 buf_ptr += WMI_TLV_HDR_SIZE;
13651
13652 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13653
13654 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13655 rate_limit_interval, vdev_id);
13656
13657 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13658 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13659 if (ret) {
13660 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13661 wmi_buf_free(buf);
13662 return QDF_STATUS_E_FAILURE;
13663 }
13664
13665 return QDF_STATUS_SUCCESS;
13666
13667}
13668#endif /* FEATURE_WLAN_RA_FILTERING */
13669
13670/**
13671 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13672 * @wmi_handle: wmi handle
13673 * @vdev_id: vdev id
13674 * @multicastAddr: mcast address
13675 * @clearList: clear list flag
13676 *
13677 * Return: QDF_STATUS_SUCCESS for success or error code
13678 */
13679static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13680 uint8_t vdev_id,
13681 struct qdf_mac_addr multicast_addr,
13682 bool clearList)
13683{
13684 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13685 wmi_buf_t buf;
13686 int err;
13687
13688 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13689 if (!buf) {
13690 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13691 return QDF_STATUS_E_NOMEM;
13692 }
13693
13694 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13695 qdf_mem_zero(cmd, sizeof(*cmd));
13696
13697 WMITLV_SET_HDR(&cmd->tlv_header,
13698 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13699 WMITLV_GET_STRUCT_TLVLEN
13700 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13701 cmd->action =
13702 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13703 cmd->vdev_id = vdev_id;
13704 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13705
13706 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13707 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13708
13709 err = wmi_unified_cmd_send(wmi_handle, buf,
13710 sizeof(*cmd),
13711 WMI_SET_MCASTBCAST_FILTER_CMDID);
13712 if (err) {
13713 WMI_LOGE("Failed to send set_param cmd");
13714 wmi_buf_free(buf);
13715 return QDF_STATUS_E_FAILURE;
13716 }
13717
13718 return QDF_STATUS_SUCCESS;
13719}
13720
13721/**
13722 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13723 * @wmi_handle: wmi handle
13724 * @vdev_id: vdev id
13725 * @params: GTK offload parameters
13726 *
13727 * Return: CDF status
13728 */
13729static
13730QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13731 struct pmo_gtk_req *params,
13732 bool enable_offload,
13733 uint32_t gtk_offload_opcode)
13734{
13735 int len;
13736 wmi_buf_t buf;
13737 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13738 QDF_STATUS status = QDF_STATUS_SUCCESS;
13739
13740 WMI_LOGD("%s Enter", __func__);
13741
13742 len = sizeof(*cmd);
13743
13744 /* alloc wmi buffer */
13745 buf = wmi_buf_alloc(wmi_handle, len);
13746 if (!buf) {
13747 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13748 status = QDF_STATUS_E_NOMEM;
13749 goto out;
13750 }
13751
13752 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13753 WMITLV_SET_HDR(&cmd->tlv_header,
13754 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13755 WMITLV_GET_STRUCT_TLVLEN
13756 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13757
13758 cmd->vdev_id = vdev_id;
13759
13760 /* Request target to enable GTK offload */
13761 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13762 cmd->flags = gtk_offload_opcode;
13763
13764 /* Copy the keys and replay counter */
13765 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13766 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13767 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13768 GTK_REPLAY_COUNTER_BYTES);
13769 } else {
13770 cmd->flags = gtk_offload_opcode;
13771 }
13772
13773 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13774
13775 /* send the wmi command */
13776 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13777 WMI_GTK_OFFLOAD_CMDID)) {
13778 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13779 wmi_buf_free(buf);
13780 status = QDF_STATUS_E_FAILURE;
13781 }
13782
13783out:
13784 WMI_LOGD("%s Exit", __func__);
13785 return status;
13786}
13787
13788/**
13789 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13790 * @wmi_handle: wmi handle
13791 * @params: GTK offload params
13792 *
13793 * Return: CDF status
13794 */
13795static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13796 wmi_unified_t wmi_handle,
13797 uint8_t vdev_id,
13798 uint64_t offload_req_opcode)
13799{
13800 int len;
13801 wmi_buf_t buf;
13802 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13803 QDF_STATUS status = QDF_STATUS_SUCCESS;
13804
13805 len = sizeof(*cmd);
13806
13807 /* alloc wmi buffer */
13808 buf = wmi_buf_alloc(wmi_handle, len);
13809 if (!buf) {
13810 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13811 status = QDF_STATUS_E_NOMEM;
13812 goto out;
13813 }
13814
13815 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13816 WMITLV_SET_HDR(&cmd->tlv_header,
13817 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13818 WMITLV_GET_STRUCT_TLVLEN
13819 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13820
13821 /* Request for GTK offload status */
13822 cmd->flags = offload_req_opcode;
13823 cmd->vdev_id = vdev_id;
13824
13825 /* send the wmi command */
13826 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13827 WMI_GTK_OFFLOAD_CMDID)) {
13828 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13829 wmi_buf_free(buf);
13830 status = QDF_STATUS_E_FAILURE;
13831 }
13832
13833out:
13834 return status;
13835}
13836
13837/**
13838 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13839 * @wmi_handle: wmi handler
13840 * @action_params: pointer to action_params
13841 *
13842 * Return: 0 for success, otherwise appropriate error code
13843 */
13844static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13845 struct pmo_action_wakeup_set_params *action_params)
13846{
13847 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13848 wmi_buf_t buf;
13849 int i;
13850 int32_t err;
13851
13852 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13853 if (!buf) {
13854 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13855 return QDF_STATUS_E_NOMEM;
13856 }
13857 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13858 WMITLV_SET_HDR(&cmd->tlv_header,
13859 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13860 WMITLV_GET_STRUCT_TLVLEN(
13861 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13862
13863 cmd->vdev_id = action_params->vdev_id;
13864 cmd->operation = action_params->operation;
13865
13866 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13867 cmd->action_category_map[i] =
13868 action_params->action_category_map[i];
13869
13870 err = wmi_unified_cmd_send(wmi_handle, buf,
13871 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13872 if (err) {
13873 WMI_LOGE("Failed to send ap_ps_egap cmd");
13874 wmi_buf_free(buf);
13875 return QDF_STATUS_E_FAILURE;
13876 }
13877
13878 return QDF_STATUS_SUCCESS;
13879}
13880
13881#ifdef FEATURE_WLAN_LPHB
13882
13883/**
13884 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13885 * @wmi_handle: wmi handle
13886 * @lphb_conf_req: configuration info
13887 *
13888 * Return: CDF status
13889 */
13890static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13891 wmi_hb_set_enable_cmd_fixed_param *params)
13892{
13893 QDF_STATUS status;
13894 wmi_buf_t buf = NULL;
13895 uint8_t *buf_ptr;
13896 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13897 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13898
13899
13900 buf = wmi_buf_alloc(wmi_handle, len);
13901 if (!buf) {
13902 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13903 return QDF_STATUS_E_NOMEM;
13904 }
13905
13906 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13907 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13908 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13909 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13910 WMITLV_GET_STRUCT_TLVLEN
13911 (wmi_hb_set_enable_cmd_fixed_param));
13912
13913 /* fill in values */
13914 hb_enable_fp->vdev_id = params->session;
13915 hb_enable_fp->enable = params->enable;
13916 hb_enable_fp->item = params->item;
13917 hb_enable_fp->session = params->session;
13918
13919 status = wmi_unified_cmd_send(wmi_handle, buf,
13920 len, WMI_HB_SET_ENABLE_CMDID);
13921 if (QDF_IS_STATUS_ERROR(status)) {
13922 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13923 status);
13924 wmi_buf_free(buf);
13925 }
13926
13927 return status;
13928}
13929
13930/**
13931 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13932 * @wmi_handle: wmi handle
13933 * @lphb_conf_req: lphb config request
13934 *
13935 * Return: CDF status
13936 */
13937static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13938 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13939{
13940 QDF_STATUS status;
13941 wmi_buf_t buf = NULL;
13942 uint8_t *buf_ptr;
13943 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13944 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13945
13946 buf = wmi_buf_alloc(wmi_handle, len);
13947 if (!buf) {
13948 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13949 return QDF_STATUS_E_NOMEM;
13950 }
13951
13952 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13953 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13954 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13955 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13956 WMITLV_GET_STRUCT_TLVLEN
13957 (wmi_hb_set_tcp_params_cmd_fixed_param));
13958
13959 /* fill in values */
13960 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13961 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13962 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13963 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13964 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13965 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13966 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13967 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13968 hb_tcp_params_fp->session = lphb_conf_req->session;
13969 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13970 &lphb_conf_req->gateway_mac,
13971 sizeof(hb_tcp_params_fp->gateway_mac));
13972
13973 status = wmi_unified_cmd_send(wmi_handle, buf,
13974 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13975 if (QDF_IS_STATUS_ERROR(status)) {
13976 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13977 status);
13978 wmi_buf_free(buf);
13979 }
13980
13981 return status;
13982}
13983
13984/**
13985 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13986 * @wmi_handle: wmi handle
13987 * @lphb_conf_req: lphb config request
13988 *
13989 * Return: CDF status
13990 */
13991static
13992QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13993 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13994{
13995 QDF_STATUS status;
13996 wmi_buf_t buf = NULL;
13997 uint8_t *buf_ptr;
13998 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13999 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14000
14001 buf = wmi_buf_alloc(wmi_handle, len);
14002 if (!buf) {
14003 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14004 return QDF_STATUS_E_NOMEM;
14005 }
14006
14007 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14008 hb_tcp_filter_fp =
14009 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14010 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14011 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14012 WMITLV_GET_STRUCT_TLVLEN
14013 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14014
14015 /* fill in values */
14016 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14017 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14018 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14019 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14020 memcpy((void *)&hb_tcp_filter_fp->filter,
14021 (void *)&g_hb_tcp_filter_fp->filter,
14022 WMI_WLAN_HB_MAX_FILTER_SIZE);
14023
14024 status = wmi_unified_cmd_send(wmi_handle, buf,
14025 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14026 if (QDF_IS_STATUS_ERROR(status)) {
14027 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14028 status);
14029 wmi_buf_free(buf);
14030 }
14031
14032 return status;
14033}
14034
14035/**
14036 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14037 * @wmi_handle: wmi handle
14038 * @lphb_conf_req: lphb config request
14039 *
14040 * Return: CDF status
14041 */
14042static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14043 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14044{
14045 QDF_STATUS status;
14046 wmi_buf_t buf = NULL;
14047 uint8_t *buf_ptr;
14048 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14049 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14050
14051 buf = wmi_buf_alloc(wmi_handle, len);
14052 if (!buf) {
14053 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14054 return QDF_STATUS_E_NOMEM;
14055 }
14056
14057 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14058 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14059 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14060 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14061 WMITLV_GET_STRUCT_TLVLEN
14062 (wmi_hb_set_udp_params_cmd_fixed_param));
14063
14064 /* fill in values */
14065 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14066 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14067 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14068 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14069 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14070 hb_udp_params_fp->interval = lphb_conf_req->interval;
14071 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14072 hb_udp_params_fp->session = lphb_conf_req->session;
14073 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14074 &lphb_conf_req->gateway_mac,
14075 sizeof(lphb_conf_req->gateway_mac));
14076
14077 status = wmi_unified_cmd_send(wmi_handle, buf,
14078 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14079 if (QDF_IS_STATUS_ERROR(status)) {
14080 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14081 status);
14082 wmi_buf_free(buf);
14083 }
14084
14085 return status;
14086}
14087
14088/**
14089 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14090 * @wmi_handle: wmi handle
14091 * @lphb_conf_req: lphb config request
14092 *
14093 * Return: CDF status
14094 */
14095static
14096QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14097 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14098{
14099 QDF_STATUS status;
14100 wmi_buf_t buf = NULL;
14101 uint8_t *buf_ptr;
14102 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14103 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14104
14105 buf = wmi_buf_alloc(wmi_handle, len);
14106 if (!buf) {
14107 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14108 return QDF_STATUS_E_NOMEM;
14109 }
14110
14111 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14112 hb_udp_filter_fp =
14113 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14114 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14115 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14116 WMITLV_GET_STRUCT_TLVLEN
14117 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14118
14119 /* fill in values */
14120 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14121 hb_udp_filter_fp->length = lphb_conf_req->length;
14122 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14123 hb_udp_filter_fp->session = lphb_conf_req->session;
14124 memcpy((void *)&hb_udp_filter_fp->filter,
14125 (void *)&lphb_conf_req->filter,
14126 WMI_WLAN_HB_MAX_FILTER_SIZE);
14127
14128 status = wmi_unified_cmd_send(wmi_handle, buf,
14129 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14130 if (QDF_IS_STATUS_ERROR(status)) {
14131 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14132 status);
14133 wmi_buf_free(buf);
14134 }
14135
14136 return status;
14137}
14138#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014139
Dustin Brownf31f88b2017-05-12 14:01:44 -070014140static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14141 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014142{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014143 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014144 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014145 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014146
Dustin Brownf31f88b2017-05-12 14:01:44 -070014147 if (!req) {
14148 WMI_LOGE("req is null");
14149 return QDF_STATUS_E_INVAL;
14150 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014151
Dustin Brownf31f88b2017-05-12 14:01:44 -070014152 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14153 if (!wmi_buf) {
14154 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014155 return QDF_STATUS_E_NOMEM;
14156 }
14157
Dustin Brownf31f88b2017-05-12 14:01:44 -070014158 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014159 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014160 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14161 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14162 cmd->vdev_id = req->vdev_id;
14163 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
14164 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014165
Dustin Brownf31f88b2017-05-12 14:01:44 -070014166 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
14167 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014168
Dustin Brownf31f88b2017-05-12 14:01:44 -070014169 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14170 WMI_HW_DATA_FILTER_CMDID);
14171 if (QDF_IS_STATUS_ERROR(status)) {
14172 WMI_LOGE("Failed to configure hw filter");
14173 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014174 }
14175
Dustin Brownf31f88b2017-05-12 14:01:44 -070014176 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014177}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014178
14179/**
14180 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14181 * @wmi_handle: wmi handle
14182 * @vdev_id: vdev id
14183 * @enable: Flag to enable/disable packet filter
14184 *
14185 * Return: QDF_STATUS_SUCCESS for success or error code
14186 */
14187static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14188 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14189{
14190 int32_t len;
14191 int ret = 0;
14192 wmi_buf_t buf;
14193 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14194
14195 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14196
14197 buf = wmi_buf_alloc(wmi_handle, len);
14198 if (!buf) {
14199 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14200 return QDF_STATUS_E_NOMEM;
14201 }
14202
14203 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14204 WMITLV_SET_HDR(&cmd->tlv_header,
14205 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14206 WMITLV_GET_STRUCT_TLVLEN(
14207 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14208
14209 cmd->vdev_id = vdev_id;
14210 if (enable)
14211 cmd->enable = PACKET_FILTER_SET_ENABLE;
14212 else
14213 cmd->enable = PACKET_FILTER_SET_DISABLE;
14214
14215 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14216 __func__, cmd->enable, vdev_id);
14217
14218 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14219 WMI_PACKET_FILTER_ENABLE_CMDID);
14220 if (ret) {
14221 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14222 wmi_buf_free(buf);
14223 }
14224
14225 return ret;
14226}
14227
14228/**
14229 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14230 * @wmi_handle: wmi handle
14231 * @vdev_id: vdev id
14232 * @rcv_filter_param: Packet filter parameters
14233 * @filter_id: Filter id
14234 * @enable: Flag to add/delete packet filter configuration
14235 *
14236 * Return: QDF_STATUS_SUCCESS for success or error code
14237 */
14238static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14239 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14240 uint8_t filter_id, bool enable)
14241{
14242 int len, i;
14243 int err = 0;
14244 wmi_buf_t buf;
14245 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14246
14247
14248 /* allocate the memory */
14249 len = sizeof(*cmd);
14250 buf = wmi_buf_alloc(wmi_handle, len);
14251 if (!buf) {
14252 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14253 return QDF_STATUS_E_NOMEM;
14254 }
14255
14256 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14257 WMITLV_SET_HDR(&cmd->tlv_header,
14258 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14259 WMITLV_GET_STRUCT_TLVLEN
14260 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14261
14262 cmd->vdev_id = vdev_id;
14263 cmd->filter_id = filter_id;
14264 if (enable)
14265 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14266 else
14267 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14268
14269 if (enable) {
14270 cmd->num_params = QDF_MIN(
14271 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14272 rcv_filter_param->num_params);
14273 cmd->filter_type = rcv_filter_param->filter_type;
14274 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14275
14276 for (i = 0; i < cmd->num_params; i++) {
14277 cmd->paramsData[i].proto_type =
14278 rcv_filter_param->params_data[i].protocol_layer;
14279 cmd->paramsData[i].cmp_type =
14280 rcv_filter_param->params_data[i].compare_flag;
14281 cmd->paramsData[i].data_length =
14282 rcv_filter_param->params_data[i].data_length;
14283 cmd->paramsData[i].data_offset =
14284 rcv_filter_param->params_data[i].data_offset;
14285 memcpy(&cmd->paramsData[i].compareData,
14286 rcv_filter_param->params_data[i].compare_data,
14287 sizeof(cmd->paramsData[i].compareData));
14288 memcpy(&cmd->paramsData[i].dataMask,
14289 rcv_filter_param->params_data[i].data_mask,
14290 sizeof(cmd->paramsData[i].dataMask));
14291 }
14292 }
14293
14294 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14295 cmd->filter_action, cmd->filter_id, cmd->num_params);
14296 /* send the command along with data */
14297 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14298 WMI_PACKET_FILTER_CONFIG_CMDID);
14299 if (err) {
14300 WMI_LOGE("Failed to send pkt_filter cmd");
14301 wmi_buf_free(buf);
14302 return QDF_STATUS_E_FAILURE;
14303 }
14304
14305 return QDF_STATUS_SUCCESS;
14306}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053014307#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014308
Govind Singha4836fd2016-03-07 16:45:38 +053014309/**
14310 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14311 * @wmi_handle: wmi handle
14312 * @request: SSID hotlist set request
14313 *
Govind Singhb53420c2016-03-09 14:32:57 +053014314 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014315 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014316static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014317send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14318 struct ssid_hotlist_request_params *request)
14319{
14320 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14321 wmi_buf_t wmi_buf;
14322 uint32_t len;
14323 uint32_t array_size;
14324 uint8_t *buf_ptr;
14325
14326 /* length of fixed portion */
14327 len = sizeof(*cmd);
14328
14329 /* length of variable portion */
14330 array_size =
14331 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14332 len += WMI_TLV_HDR_SIZE + array_size;
14333
14334 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14335 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014336 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14337 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014338 }
14339
14340 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14341 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14342 buf_ptr;
14343 WMITLV_SET_HDR
14344 (&cmd->tlv_header,
14345 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14346 WMITLV_GET_STRUCT_TLVLEN
14347 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14348
14349 cmd->request_id = request->request_id;
14350 cmd->requestor_id = 0;
14351 cmd->vdev_id = request->session_id;
14352 cmd->table_id = 0;
14353 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14354 cmd->total_entries = request->ssid_count;
14355 cmd->num_entries_in_page = request->ssid_count;
14356 cmd->first_entry_index = 0;
14357
14358 buf_ptr += sizeof(*cmd);
14359 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14360
14361 if (request->ssid_count) {
14362 wmi_extscan_hotlist_ssid_entry *entry;
14363 int i;
14364
14365 buf_ptr += WMI_TLV_HDR_SIZE;
14366 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14367 for (i = 0; i < request->ssid_count; i++) {
14368 WMITLV_SET_HDR
14369 (entry,
14370 WMITLV_TAG_ARRAY_STRUC,
14371 WMITLV_GET_STRUCT_TLVLEN
14372 (wmi_extscan_hotlist_ssid_entry));
14373 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014374 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014375 request->ssids[i].ssid.mac_ssid,
14376 request->ssids[i].ssid.length);
14377 entry->band = request->ssids[i].band;
14378 entry->min_rssi = request->ssids[i].rssi_low;
14379 entry->max_rssi = request->ssids[i].rssi_high;
14380 entry++;
14381 }
14382 cmd->mode = WMI_EXTSCAN_MODE_START;
14383 } else {
14384 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14385 }
14386
14387 if (wmi_unified_cmd_send
14388 (wmi_handle, wmi_buf, len,
14389 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014390 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014391 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014392 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014393 }
14394
Govind Singhb53420c2016-03-09 14:32:57 +053014395 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014396}
14397
14398/**
14399 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14400 * @wmi_handle: wmi handle
14401 * @vdev_id: vdev id
14402 *
14403 * This function sends roam synch complete event to fw.
14404 *
14405 * Return: CDF STATUS
14406 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014407static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014408 uint8_t vdev_id)
14409{
14410 wmi_roam_synch_complete_fixed_param *cmd;
14411 wmi_buf_t wmi_buf;
14412 uint8_t *buf_ptr;
14413 uint16_t len;
14414 len = sizeof(wmi_roam_synch_complete_fixed_param);
14415
14416 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14417 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014418 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14419 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014420 }
14421 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14422 buf_ptr = (uint8_t *) cmd;
14423 WMITLV_SET_HDR(&cmd->tlv_header,
14424 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14425 WMITLV_GET_STRUCT_TLVLEN
14426 (wmi_roam_synch_complete_fixed_param));
14427 cmd->vdev_id = vdev_id;
14428 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14429 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014430 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014431 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014432 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014433 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014434 }
14435
Govind Singhb53420c2016-03-09 14:32:57 +053014436 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014437}
14438
14439/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014440 * send_fw_test_cmd_tlv() - send fw test command to fw.
14441 * @wmi_handle: wmi handle
14442 * @wmi_fwtest: fw test command
14443 *
14444 * This function sends fw test command to fw.
14445 *
14446 * Return: CDF STATUS
14447 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014448static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014449QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14450 struct set_fwtest_params *wmi_fwtest)
14451{
14452 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14453 wmi_buf_t wmi_buf;
14454 uint16_t len;
14455
14456 len = sizeof(*cmd);
14457
14458 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14459 if (!wmi_buf) {
14460 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14461 return QDF_STATUS_E_NOMEM;
14462 }
14463
14464 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14465 WMITLV_SET_HDR(&cmd->tlv_header,
14466 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14467 WMITLV_GET_STRUCT_TLVLEN(
14468 wmi_fwtest_set_param_cmd_fixed_param));
14469 cmd->param_id = wmi_fwtest->arg;
14470 cmd->param_value = wmi_fwtest->value;
14471
14472 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14473 WMI_FWTEST_CMDID)) {
14474 WMI_LOGP("%s: failed to send fw test command", __func__);
14475 qdf_nbuf_free(wmi_buf);
14476 return QDF_STATUS_E_FAILURE;
14477 }
14478
14479 return QDF_STATUS_SUCCESS;
14480}
14481
14482/**
Govind Singha4836fd2016-03-07 16:45:38 +053014483 * send_unit_test_cmd_tlv() - send unit test command to fw.
14484 * @wmi_handle: wmi handle
14485 * @wmi_utest: unit test command
14486 *
14487 * This function send unit test command to fw.
14488 *
14489 * Return: CDF STATUS
14490 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014491static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014492 struct wmi_unit_test_cmd *wmi_utest)
14493{
14494 wmi_unit_test_cmd_fixed_param *cmd;
14495 wmi_buf_t wmi_buf;
14496 uint8_t *buf_ptr;
14497 int i;
14498 uint16_t len, args_tlv_len;
14499 A_UINT32 *unit_test_cmd_args;
14500
14501 args_tlv_len =
14502 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14503 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14504
14505 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14506 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014507 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14508 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014509 }
14510
14511 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14512 buf_ptr = (uint8_t *) cmd;
14513 WMITLV_SET_HDR(&cmd->tlv_header,
14514 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14515 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14516 cmd->vdev_id = wmi_utest->vdev_id;
14517 cmd->module_id = wmi_utest->module_id;
14518 cmd->num_args = wmi_utest->num_args;
14519 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14521 (wmi_utest->num_args * sizeof(uint32_t)));
14522 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014523 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014524 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14525 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014526 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014527 }
14528 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14529 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014530 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014531 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014532 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014533 }
14534
Govind Singhb53420c2016-03-09 14:32:57 +053014535 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014536}
14537
14538/**
14539 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14540 * @wmi_handle: wma handle
14541 * @roaminvoke: roam invoke command
14542 *
14543 * Send roam invoke command to fw for fastreassoc.
14544 *
14545 * Return: CDF STATUS
14546 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014547static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014548 struct wmi_roam_invoke_cmd *roaminvoke,
14549 uint32_t ch_hz)
14550{
14551 wmi_roam_invoke_cmd_fixed_param *cmd;
14552 wmi_buf_t wmi_buf;
14553 u_int8_t *buf_ptr;
14554 u_int16_t len, args_tlv_len;
14555 A_UINT32 *channel_list;
14556 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014557 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014558
14559 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014560 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14561 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14562 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014563 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14564 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14565 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014566 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14567 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014568 }
14569
14570 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14571 buf_ptr = (u_int8_t *) cmd;
14572 WMITLV_SET_HDR(&cmd->tlv_header,
14573 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14574 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14575 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014576 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014577
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014578 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080014579 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014580 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14581 cmd->num_buf = 1;
14582 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080014583 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014584 cmd->num_buf = 0;
14585 }
Naveen Rawat77797922017-01-20 17:00:07 -080014586
Govind Singha4836fd2016-03-07 16:45:38 +053014587 cmd->roam_ap_sel_mode = 0;
14588 cmd->roam_delay = 0;
14589 cmd->num_chan = 1;
14590 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014591
Govind Singha4836fd2016-03-07 16:45:38 +053014592 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14593 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14594 (sizeof(u_int32_t)));
14595 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14596 *channel_list = ch_hz;
14597 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14599 (sizeof(wmi_mac_addr)));
14600 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14601 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014602
14603 /* move to next tlv i.e. bcn_prb_buf_list */
14604 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14605
14606 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14607 sizeof(wmi_tlv_buf_len_param));
14608
14609 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14610 buf_len_tlv->buf_len = roaminvoke->frame_len;
14611
14612 /* move to next tlv i.e. bcn_prb_frm */
14613 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14614 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14615 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14616
14617 /* copy frame after the header */
14618 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14619 roaminvoke->frame_buf,
14620 roaminvoke->frame_len);
14621
14622 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14623 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14624 buf_ptr + WMI_TLV_HDR_SIZE,
14625 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014626 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
14627 cmd->flags, cmd->roam_scan_mode,
14628 cmd->roam_ap_sel_mode, cmd->roam_delay,
14629 cmd->num_chan, cmd->num_bssid);
14630 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080014631
Govind Singha4836fd2016-03-07 16:45:38 +053014632 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14633 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014634 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014635 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014636 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014637 }
14638
Govind Singhb53420c2016-03-09 14:32:57 +053014639 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014640}
14641
14642/**
14643 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14644 * @wmi_handle: wmi handle
14645 * @command: command
14646 * @vdev_id: vdev id
14647 *
14648 * This function set roam offload command to fw.
14649 *
14650 * Return: CDF status
14651 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014652static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014653 uint32_t command, uint32_t vdev_id)
14654{
Govind Singh67922e82016-04-01 16:48:57 +053014655 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014656 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14657 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014658 int len;
14659 uint8_t *buf_ptr;
14660
14661 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14662 buf = wmi_buf_alloc(wmi_handle, len);
14663 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014664 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14665 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014666 }
14667
14668 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14669
14670 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14671 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14672 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14673 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14674 cmd_fp->vdev_id = vdev_id;
14675 cmd_fp->command_arg = command;
14676
14677 status = wmi_unified_cmd_send(wmi_handle, buf,
14678 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014679 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014680 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014681 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014682 goto error;
14683 }
14684
Govind Singhb53420c2016-03-09 14:32:57 +053014685 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14686 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014687
14688error:
14689 wmi_buf_free(buf);
14690
Govind Singh67922e82016-04-01 16:48:57 +053014691 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014692}
14693
14694/**
14695 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14696 * @wmi_handle: wmi handle
14697 * @ap_profile_p: ap profile
14698 * @vdev_id: vdev id
14699 *
14700 * Send WMI_ROAM_AP_PROFILE to firmware
14701 *
14702 * Return: CDF status
14703 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014704static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014705 wmi_ap_profile *ap_profile_p,
14706 uint32_t vdev_id)
14707{
Govind Singha4836fd2016-03-07 16:45:38 +053014708 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014709 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014710 int len;
14711 uint8_t *buf_ptr;
14712 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14713
14714 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14715
14716 buf = wmi_buf_alloc(wmi_handle, len);
14717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014718 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14719 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014720 }
14721
14722 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14723 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14724 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14725 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14726 WMITLV_GET_STRUCT_TLVLEN
14727 (wmi_roam_ap_profile_fixed_param));
14728 /* fill in threshold values */
14729 roam_ap_profile_fp->vdev_id = vdev_id;
14730 roam_ap_profile_fp->id = 0;
14731 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14732
Govind Singhb53420c2016-03-09 14:32:57 +053014733 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014734 WMITLV_SET_HDR(buf_ptr,
14735 WMITLV_TAG_STRUC_wmi_ap_profile,
14736 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14737 status = wmi_unified_cmd_send(wmi_handle, buf,
14738 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014739 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014740 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014741 status);
Govind Singh67922e82016-04-01 16:48:57 +053014742 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014743 }
14744
Govind Singhb53420c2016-03-09 14:32:57 +053014745 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014746
Govind Singh67922e82016-04-01 16:48:57 +053014747 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014748}
14749
14750/**
14751 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14752 * @wmi_handle: wmi handle
14753 * @scan_period: scan period
14754 * @scan_age: scan age
14755 * @vdev_id: vdev id
14756 *
14757 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14758 *
14759 * Return: CDF status
14760 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014761static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014762 uint32_t scan_period,
14763 uint32_t scan_age,
14764 uint32_t vdev_id)
14765{
Govind Singh67922e82016-04-01 16:48:57 +053014766 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014767 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014768 int len;
14769 uint8_t *buf_ptr;
14770 wmi_roam_scan_period_fixed_param *scan_period_fp;
14771
14772 /* Send scan period values */
14773 len = sizeof(wmi_roam_scan_period_fixed_param);
14774 buf = wmi_buf_alloc(wmi_handle, len);
14775 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014776 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14777 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014778 }
14779
14780 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14781 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14782 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14783 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14784 WMITLV_GET_STRUCT_TLVLEN
14785 (wmi_roam_scan_period_fixed_param));
14786 /* fill in scan period values */
14787 scan_period_fp->vdev_id = vdev_id;
14788 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14789 scan_period_fp->roam_scan_age = scan_age;
14790
14791 status = wmi_unified_cmd_send(wmi_handle, buf,
14792 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014793 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014794 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014795 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014796 goto error;
14797 }
14798
Govind Singhb53420c2016-03-09 14:32:57 +053014799 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014800 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014801 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014802error:
14803 wmi_buf_free(buf);
14804
Govind Singh67922e82016-04-01 16:48:57 +053014805 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014806}
14807
14808/**
14809 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14810 * @wmi_handle: wmi handle
14811 * @chan_count: channel count
14812 * @chan_list: channel list
14813 * @list_type: list type
14814 * @vdev_id: vdev id
14815 *
14816 * Set roam offload channel list.
14817 *
14818 * Return: CDF status
14819 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014820static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014821 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014822 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014823 uint8_t list_type, uint32_t vdev_id)
14824{
Govind Singha4836fd2016-03-07 16:45:38 +053014825 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014826 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014827 int len, list_tlv_len;
14828 int i;
14829 uint8_t *buf_ptr;
14830 wmi_roam_chan_list_fixed_param *chan_list_fp;
14831 A_UINT32 *roam_chan_list_array;
14832
14833 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014834 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014835 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014836 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014837 }
14838 /* Channel list is a table of 2 TLV's */
14839 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14840 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14841 buf = wmi_buf_alloc(wmi_handle, len);
14842 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014843 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14844 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014845 }
14846
14847 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14848 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14849 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14850 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14851 WMITLV_GET_STRUCT_TLVLEN
14852 (wmi_roam_chan_list_fixed_param));
14853 chan_list_fp->vdev_id = vdev_id;
14854 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014855 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014856 /* external app is controlling channel list */
14857 chan_list_fp->chan_list_type =
14858 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14859 } else {
14860 /* umac supplied occupied channel list in LFR */
14861 chan_list_fp->chan_list_type =
14862 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14863 }
14864
14865 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14866 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14867 (chan_list_fp->num_chan * sizeof(uint32_t)));
14868 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014869 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014870 for (i = 0; ((i < chan_list_fp->num_chan) &&
14871 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14872 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014873 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014874 }
14875
14876 status = wmi_unified_cmd_send(wmi_handle, buf,
14877 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014878 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014879 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014880 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014881 goto error;
14882 }
14883
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014884 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014885 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014886error:
14887 wmi_buf_free(buf);
14888
Govind Singh67922e82016-04-01 16:48:57 +053014889 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014890}
14891
14892/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014893 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14894 * @wmi_handle: wmi handle
14895 * @req_buf: per roam config buffer
14896 *
14897 * Return: QDF status
14898 */
14899static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14900 struct wmi_per_roam_config_req *req_buf)
14901{
14902 wmi_buf_t buf = NULL;
14903 QDF_STATUS status;
14904 int len;
14905 uint8_t *buf_ptr;
14906 wmi_roam_per_config_fixed_param *wmi_per_config;
14907
14908 len = sizeof(wmi_roam_per_config_fixed_param);
14909 buf = wmi_buf_alloc(wmi_handle, len);
14910 if (!buf) {
14911 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14912 return QDF_STATUS_E_NOMEM;
14913 }
14914
14915 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14916 wmi_per_config =
14917 (wmi_roam_per_config_fixed_param *) buf_ptr;
14918 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14919 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14920 WMITLV_GET_STRUCT_TLVLEN
14921 (wmi_roam_per_config_fixed_param));
14922
14923 /* fill in per roam config values */
14924 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014925
14926 wmi_per_config->enable = req_buf->per_config.enable;
14927 wmi_per_config->high_rate_thresh =
14928 (req_buf->per_config.tx_high_rate_thresh << 16) |
14929 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14930 wmi_per_config->low_rate_thresh =
14931 (req_buf->per_config.tx_low_rate_thresh << 16) |
14932 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14933 wmi_per_config->pkt_err_rate_thresh_pct =
14934 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14935 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14936 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014937 wmi_per_config->pkt_err_rate_mon_time =
14938 (req_buf->per_config.tx_per_mon_time << 16) |
14939 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014940 wmi_per_config->min_candidate_rssi =
14941 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014942
14943 /* Send per roam config parameters */
14944 status = wmi_unified_cmd_send(wmi_handle, buf,
14945 len, WMI_ROAM_PER_CONFIG_CMDID);
14946 if (QDF_IS_STATUS_ERROR(status)) {
14947 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14948 status);
14949 wmi_buf_free(buf);
14950 return status;
14951 }
14952
14953 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14954 req_buf->per_config.enable, req_buf->vdev_id);
14955 return QDF_STATUS_SUCCESS;
14956}
14957
14958/**
Govind Singha4836fd2016-03-07 16:45:38 +053014959 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14960 * @wmi_handle: wmi handle
14961 * @rssi_change_thresh: RSSI Change threshold
14962 * @bcn_rssi_weight: beacon RSSI weight
14963 * @vdev_id: vdev id
14964 *
14965 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14966 *
14967 * Return: CDF status
14968 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014969static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014970 uint32_t vdev_id,
14971 int32_t rssi_change_thresh,
14972 uint32_t bcn_rssi_weight,
14973 uint32_t hirssi_delay_btw_scans)
14974{
Govind Singha4836fd2016-03-07 16:45:38 +053014975 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014976 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014977 int len;
14978 uint8_t *buf_ptr;
14979 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14980
14981 /* Send rssi change parameters */
14982 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14983 buf = wmi_buf_alloc(wmi_handle, len);
14984 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014985 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14986 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014987 }
14988
14989 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14990 rssi_change_fp =
14991 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14992 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14993 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14994 WMITLV_GET_STRUCT_TLVLEN
14995 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14996 /* fill in rssi change threshold (hysteresis) values */
14997 rssi_change_fp->vdev_id = vdev_id;
14998 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14999 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15000 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15001
15002 status = wmi_unified_cmd_send(wmi_handle, buf,
15003 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015004 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015005 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015006 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015007 goto error;
15008 }
15009
Govind Singhb53420c2016-03-09 14:32:57 +053015010 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015011 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015012 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15013 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015014error:
15015 wmi_buf_free(buf);
15016
Govind Singh67922e82016-04-01 16:48:57 +053015017 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015018}
15019
15020/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
15021 * @wmi_handle: wmi handle.
15022 * @cmd: size of command structure.
15023 * @per_entry_size: per entry size.
15024 *
15025 * This utility function calculates how many hotlist entries can
15026 * fit in one page.
15027 *
15028 * Return: number of entries
15029 */
15030static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
15031 size_t cmd_size,
15032 size_t per_entry_size)
15033{
15034 uint32_t avail_space = 0;
15035 int num_entries = 0;
15036 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
15037
15038 /* Calculate number of hotlist entries that can
15039 * be passed in wma message request.
15040 */
15041 avail_space = max_msg_len - cmd_size;
15042 num_entries = avail_space / per_entry_size;
15043 return num_entries;
15044}
15045
15046/**
15047 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
15048 * @wmi_handle: wmi handle
15049 * @photlist: hotlist command params
15050 * @buf_len: buffer length
15051 *
15052 * This function fills individual elements for hotlist request and
15053 * TLV for bssid entries
15054 *
15055 * Return: CDF Status.
15056 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015057static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015058 struct ext_scan_setbssi_hotlist_params *
15059 photlist, int *buf_len)
15060{
15061 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
15062 wmi_extscan_hotlist_entry *dest_hotlist;
15063 struct ap_threshold_params *src_ap = photlist->ap;
15064 wmi_buf_t buf;
15065 uint8_t *buf_ptr;
15066
15067 int j, index = 0;
15068 int cmd_len = 0;
15069 int num_entries;
15070 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080015071 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053015072 int len = sizeof(*cmd);
15073
15074 len += WMI_TLV_HDR_SIZE;
15075 cmd_len = len;
15076
15077 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
15078 cmd_len,
15079 sizeof(*dest_hotlist));
15080 /* setbssid hotlist expects the bssid list
15081 * to be non zero value
15082 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080015083 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080015084 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053015085 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053015086 }
15087
15088 /* Split the hot list entry pages and send multiple command
15089 * requests if the buffer reaches the maximum request size
15090 */
15091 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053015092 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053015093 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
15094 buf = wmi_buf_alloc(wmi_handle, len);
15095 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015096 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
15097 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015098 }
15099 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15100 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
15101 buf_ptr;
15102 WMITLV_SET_HDR(&cmd->tlv_header,
15103 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
15104 WMITLV_GET_STRUCT_TLVLEN
15105 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
15106
15107 /* Multiple requests are sent until the num_entries_in_page
15108 * matches the total_entries
15109 */
15110 cmd->request_id = photlist->requestId;
15111 cmd->vdev_id = photlist->sessionId;
15112 cmd->total_entries = numap;
15113 cmd->mode = 1;
15114 cmd->num_entries_in_page = min_entries;
15115 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
15116 cmd->first_entry_index = index;
15117
Govind Singhb53420c2016-03-09 14:32:57 +053015118 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015119 __func__, cmd->vdev_id, cmd->total_entries,
15120 cmd->num_entries_in_page,
15121 cmd->lost_ap_scan_count);
15122
15123 buf_ptr += sizeof(*cmd);
15124 WMITLV_SET_HDR(buf_ptr,
15125 WMITLV_TAG_ARRAY_STRUC,
15126 min_entries * sizeof(wmi_extscan_hotlist_entry));
15127 dest_hotlist = (wmi_extscan_hotlist_entry *)
15128 (buf_ptr + WMI_TLV_HDR_SIZE);
15129
15130 /* Populate bssid, channel info and rssi
15131 * for the bssid's that are sent as hotlists.
15132 */
15133 for (j = 0; j < min_entries; j++) {
15134 WMITLV_SET_HDR(dest_hotlist,
15135 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
15136 WMITLV_GET_STRUCT_TLVLEN
15137 (wmi_extscan_hotlist_entry));
15138
15139 dest_hotlist->min_rssi = src_ap->low;
15140 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
15141 &dest_hotlist->bssid);
15142
Govind Singhb53420c2016-03-09 14:32:57 +053015143 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015144 __func__, dest_hotlist->channel,
15145 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053015146 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053015147 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
15148 __func__, dest_hotlist->bssid.mac_addr31to0,
15149 dest_hotlist->bssid.mac_addr47to32);
15150 dest_hotlist++;
15151 src_ap++;
15152 }
15153 buf_ptr += WMI_TLV_HDR_SIZE +
15154 (min_entries * sizeof(wmi_extscan_hotlist_entry));
15155
15156 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15157 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015158 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015159 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015160 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015161 }
15162 index = index + min_entries;
15163 num_entries = numap - min_entries;
15164 len = cmd_len;
15165 }
Govind Singhb53420c2016-03-09 14:32:57 +053015166 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015167}
15168
Govind Singhbca3b1b2016-05-02 17:59:24 +053015169/**
Dustin Brown4423f632017-01-13 15:24:07 -080015170 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
15171 * @wmi_handle: the WMI handle
15172 * @vdev_id: the Id of the vdev to apply the configuration to
15173 * @ucast_mode: the active BPF mode to configure for unicast packets
15174 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
15175 * packets
15176 *
15177 * Return: QDF status
15178 */
15179static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
15180 uint8_t vdev_id,
15181 enum wmi_host_active_bpf_mode ucast_mode,
15182 enum wmi_host_active_bpf_mode mcast_bcast_mode)
15183{
15184 const WMITLV_TAG_ID tag_id =
15185 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
15186 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
15187 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
15188 QDF_STATUS status;
15189 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
15190 wmi_buf_t buf;
15191
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015192 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080015193 vdev_id, ucast_mode, mcast_bcast_mode);
15194
15195 /* allocate command buffer */
15196 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
15197 if (!buf) {
15198 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15199 return QDF_STATUS_E_NOMEM;
15200 }
15201
15202 /* set TLV header */
15203 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
15204 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
15205
15206 /* populate data */
15207 cmd->vdev_id = vdev_id;
15208 cmd->uc_mode = ucast_mode;
15209 cmd->mcbc_mode = mcast_bcast_mode;
15210
15211 /* send to FW */
15212 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
15213 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
15214 if (QDF_IS_STATUS_ERROR(status)) {
15215 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
15216 status);
15217 wmi_buf_free(buf);
15218 return status;
15219 }
15220
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015221 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080015222
15223 return QDF_STATUS_SUCCESS;
15224}
15225
15226/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053015227 * send_power_dbg_cmd_tlv() - send power debug commands
15228 * @wmi_handle: wmi handle
15229 * @param: wmi power debug parameter
15230 *
15231 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15232 *
15233 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15234 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015235static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15236 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015237{
15238 wmi_buf_t buf = NULL;
15239 QDF_STATUS status;
15240 int len, args_tlv_len;
15241 uint8_t *buf_ptr;
15242 uint8_t i;
15243 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15244 uint32_t *cmd_args;
15245
15246 /* Prepare and send power debug cmd parameters */
15247 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15248 len = sizeof(*cmd) + args_tlv_len;
15249 buf = wmi_buf_alloc(wmi_handle, len);
15250 if (!buf) {
15251 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15252 return QDF_STATUS_E_NOMEM;
15253 }
15254
15255 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15256 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15257 WMITLV_SET_HDR(&cmd->tlv_header,
15258 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15259 WMITLV_GET_STRUCT_TLVLEN
15260 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15261
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015262 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15263 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015264 cmd->module_id = param->module_id;
15265 cmd->num_args = param->num_args;
15266 buf_ptr += sizeof(*cmd);
15267 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15268 (param->num_args * sizeof(uint32_t)));
15269 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15270 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
15271 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15272 cmd_args[i] = param->args[i];
15273 WMI_LOGI("%d,", param->args[i]);
15274 }
15275
15276 status = wmi_unified_cmd_send(wmi_handle, buf,
15277 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15278 if (QDF_IS_STATUS_ERROR(status)) {
15279 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15280 status);
15281 goto error;
15282 }
15283
15284 return QDF_STATUS_SUCCESS;
15285error:
15286 wmi_buf_free(buf);
15287
15288 return status;
15289}
15290
Kiran Venkatappa26117052016-12-23 19:58:54 +053015291/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015292 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015293 * @buf_ptr: pointer to current position in init command buffer
15294 * @len: pointer to length. This will be updated with current lenght of cmd
15295 * @param: point host parameters for init command
15296 *
15297 * Return: Updated pointer of buf_ptr.
15298 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015299static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
15300 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053015301{
15302 uint16_t idx;
15303
15304 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
15305 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
15306 wmi_pdev_band_to_mac *band_to_mac;
15307
15308 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
15309 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
15310 sizeof(wmi_resource_config) +
15311 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
15312 sizeof(wlan_host_memory_chunk)));
15313
15314 WMITLV_SET_HDR(&hw_mode->tlv_header,
15315 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
15316 (WMITLV_GET_STRUCT_TLVLEN
15317 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
15318
15319 hw_mode->hw_mode_index = param->hw_mode_id;
15320 hw_mode->num_band_to_mac = param->num_band_to_mac;
15321
15322 buf_ptr = (uint8_t *) (hw_mode + 1);
15323 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
15324 WMI_TLV_HDR_SIZE);
15325 for (idx = 0; idx < param->num_band_to_mac; idx++) {
15326 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
15327 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
15328 WMITLV_GET_STRUCT_TLVLEN
15329 (wmi_pdev_band_to_mac));
15330 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015331 wmi_handle->ops->convert_pdev_id_host_to_target(
15332 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015333 band_to_mac[idx].start_freq =
15334 param->band_to_mac[idx].start_freq;
15335 band_to_mac[idx].end_freq =
15336 param->band_to_mac[idx].end_freq;
15337 }
15338 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15339 (param->num_band_to_mac *
15340 sizeof(wmi_pdev_band_to_mac)) +
15341 WMI_TLV_HDR_SIZE;
15342
15343 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
15344 (param->num_band_to_mac *
15345 sizeof(wmi_pdev_band_to_mac)));
15346 }
15347
15348 return buf_ptr;
15349}
15350
Govind Singhe7f2f342016-05-23 12:12:52 +053015351/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015352 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15353 * @wmi_handle: wmi handle
15354 * @param: wmi multiple vdev restart req param
15355 *
15356 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15357 *
15358 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15359 */
15360static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15361 wmi_unified_t wmi_handle,
15362 struct multiple_vdev_restart_params *param)
15363{
15364 wmi_buf_t buf;
15365 QDF_STATUS qdf_status;
15366 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15367 int i;
15368 uint8_t *buf_ptr;
15369 uint32_t *vdev_ids;
15370 wmi_channel *chan_info;
15371 struct channel_param *tchan_info;
15372 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15373
15374 len += sizeof(wmi_channel);
15375 if (param->num_vdevs)
15376 len += sizeof(uint32_t) * param->num_vdevs;
15377
15378 buf = wmi_buf_alloc(wmi_handle, len);
15379 if (!buf) {
15380 WMI_LOGE("Failed to allocate memory\n");
15381 qdf_status = QDF_STATUS_E_NOMEM;
15382 goto end;
15383 }
15384
15385 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15386 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15387 buf_ptr;
15388
15389 WMITLV_SET_HDR(&cmd->tlv_header,
15390 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15391 WMITLV_GET_STRUCT_TLVLEN
15392 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015393 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15394 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015395 cmd->requestor_id = param->requestor_id;
15396 cmd->disable_hw_ack = param->disable_hw_ack;
15397 cmd->cac_duration_ms = param->cac_duration_ms;
15398 cmd->num_vdevs = param->num_vdevs;
15399
15400 buf_ptr += sizeof(*cmd);
15401
15402 WMITLV_SET_HDR(buf_ptr,
15403 WMITLV_TAG_ARRAY_UINT32,
15404 sizeof(A_UINT32) * param->num_vdevs);
15405 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15406 for (i = 0; i < param->num_vdevs; i++) {
15407 vdev_ids[i] = param->vdev_ids[i];
15408 }
15409
15410 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
15411
15412 WMITLV_SET_HDR(buf_ptr,
15413 WMITLV_TAG_STRUC_wmi_channel,
15414 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015415 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015416 tchan_info = &(param->ch_param);
15417 chan_info->mhz = tchan_info->mhz;
15418 chan_info->band_center_freq1 = tchan_info->cfreq1;
15419 chan_info->band_center_freq2 = tchan_info->cfreq2;
15420 if (tchan_info->is_chan_passive)
15421 WMI_SET_CHANNEL_FLAG(chan_info,
15422 WMI_CHAN_FLAG_PASSIVE);
15423 if (tchan_info->allow_vht)
15424 WMI_SET_CHANNEL_FLAG(chan_info,
15425 WMI_CHAN_FLAG_ALLOW_VHT);
15426 else if (tchan_info->allow_ht)
15427 WMI_SET_CHANNEL_FLAG(chan_info,
15428 WMI_CHAN_FLAG_ALLOW_HT);
15429 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15430 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15431 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15432 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15433 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15434 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
15435
15436 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15437 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15438
15439 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15440 WMI_LOGE("%s: Failed to send\n", __func__);
15441 wmi_buf_free(buf);
15442 }
15443
15444end:
15445 return qdf_status;
15446}
15447
15448/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015449 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15450 * @wmi_handle: wmi handle
15451 * @pdev_id: pdev id
15452 *
15453 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15454 *
15455 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15456 */
15457static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15458 uint32_t pdev_id)
15459{
15460 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15461 wmi_buf_t buf;
15462 uint16_t len;
15463 QDF_STATUS ret;
15464
15465 len = sizeof(*cmd);
15466 buf = wmi_buf_alloc(wmi_handle, len);
15467
15468 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15469
15470 if (!buf) {
15471 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15472 return QDF_STATUS_E_NOMEM;
15473 }
15474
15475 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15476 wmi_buf_data(buf);
15477
15478 WMITLV_SET_HDR(&cmd->tlv_header,
15479 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15480 WMITLV_GET_STRUCT_TLVLEN(
15481 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15482
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015483 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015484 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15485 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15486 if (QDF_IS_STATUS_ERROR(ret)) {
15487 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15488 __func__, ret, pdev_id);
15489 wmi_buf_free(buf);
15490 return QDF_STATUS_E_FAILURE;
15491 }
15492
15493 return QDF_STATUS_SUCCESS;
15494}
15495
15496/**
15497 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15498 * @wmi_handle: wmi handle
15499 * @pdev_id: pdev id
15500 *
15501 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15502 *
15503 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15504 */
15505static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15506 uint32_t pdev_id)
15507{
15508 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15509 wmi_buf_t buf;
15510 uint16_t len;
15511 QDF_STATUS ret;
15512
15513 len = sizeof(*cmd);
15514 buf = wmi_buf_alloc(wmi_handle, len);
15515
15516 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15517
15518 if (!buf) {
15519 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15520 return QDF_STATUS_E_NOMEM;
15521 }
15522
15523 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15524 wmi_buf_data(buf);
15525
15526 WMITLV_SET_HDR(&cmd->tlv_header,
15527 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15528 WMITLV_GET_STRUCT_TLVLEN(
15529 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15530
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015531 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015532 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15533 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15534 if (QDF_IS_STATUS_ERROR(ret)) {
15535 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15536 __func__, ret, pdev_id);
15537 wmi_buf_free(buf);
15538 return QDF_STATUS_E_FAILURE;
15539 }
15540
15541 return QDF_STATUS_SUCCESS;
15542}
15543
15544/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015545 * init_cmd_send_tlv() - send initialization cmd to fw
15546 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015547 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015548 *
15549 * Return: QDF_STATUS_SUCCESS for success or error code
15550 */
15551static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015552 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015553{
15554 wmi_buf_t buf;
15555 wmi_init_cmd_fixed_param *cmd;
15556 wmi_abi_version my_vers;
15557 int num_whitelist;
15558 uint8_t *buf_ptr;
15559 wmi_resource_config *resource_cfg;
15560 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015561 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015562 uint16_t idx;
15563 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015564 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015565
Kiran Venkatappa26117052016-12-23 19:58:54 +053015566 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15567 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015568 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015569
15570 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15571 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15572 WMI_TLV_HDR_SIZE +
15573 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15574
15575 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015576 if (!buf) {
15577 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15578 return QDF_STATUS_E_FAILURE;
15579 }
15580
15581 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15582 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15583 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15584
15585 host_mem_chunks = (wlan_host_memory_chunk *)
15586 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15587 + WMI_TLV_HDR_SIZE);
15588
15589 WMITLV_SET_HDR(&cmd->tlv_header,
15590 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15591 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15592
Kiran Venkatappa26117052016-12-23 19:58:54 +053015593 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015594 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15595 WMITLV_TAG_STRUC_wmi_resource_config,
15596 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15597
Kiran Venkatappa26117052016-12-23 19:58:54 +053015598 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015599 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15600 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15601 WMITLV_GET_STRUCT_TLVLEN
15602 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015603 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15604 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15605 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015606 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15607 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015608 idx, host_mem_chunks[idx].size,
15609 host_mem_chunks[idx].ptr);
15610 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015611 cmd->num_host_mem_chunks = param->num_mem_chunks;
15612 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15613
Govind Singhe7f2f342016-05-23 12:12:52 +053015614 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15615 WMITLV_TAG_ARRAY_STRUC,
15616 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015617 param->num_mem_chunks));
15618
15619 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015620 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015621
15622 num_whitelist = sizeof(version_whitelist) /
15623 sizeof(wmi_whitelist_version_info);
15624 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15625 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15626 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15627 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15628 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15629 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15630
Govind Singh87542482016-06-08 19:40:11 +053015631#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015632 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15633 &my_vers,
15634 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15635 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015636#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015637 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15638 __func__,
15639 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15640 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15641 cmd->host_abi_vers.abi_version_ns_0,
15642 cmd->host_abi_vers.abi_version_ns_1,
15643 cmd->host_abi_vers.abi_version_ns_2,
15644 cmd->host_abi_vers.abi_version_ns_3);
15645
15646 /* Save version sent from host -
15647 * Will be used to check ready event
15648 */
Govind Singh87542482016-06-08 19:40:11 +053015649#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015650 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15651 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015652#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015653 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15654 if (QDF_IS_STATUS_ERROR(ret)) {
15655 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15656 ret);
15657 wmi_buf_free(buf);
15658 }
15659 return ret;
15660
Govind Singhe7f2f342016-05-23 12:12:52 +053015661}
15662
15663/**
15664 * save_service_bitmap_tlv() - save service bitmap
15665 * @wmi_handle: wmi handle
15666 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015667 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015668 *
15669 * Return: None
15670 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015671#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015672static
Rajeev Kumar77901472017-02-12 02:12:17 -080015673void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15674 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015675{
15676 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15677 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15678
15679 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15680 param_buf->wmi_service_bitmap,
15681 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015682
15683 if (bitmap_buf)
15684 qdf_mem_copy(bitmap_buf,
15685 param_buf->wmi_service_bitmap,
15686 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015687}
15688#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015689static
Rajeev Kumar77901472017-02-12 02:12:17 -080015690void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15691 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015692{
Rajeev Kumar77901472017-02-12 02:12:17 -080015693 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15694 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015695
Rajeev Kumar77901472017-02-12 02:12:17 -080015696 if (bitmap_buf)
15697 qdf_mem_copy(bitmap_buf,
15698 param_buf->wmi_service_bitmap,
15699 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15700}
Govind Singhe7f2f342016-05-23 12:12:52 +053015701#endif
15702
15703/**
15704 * is_service_enabled_tlv() - Check if service enabled
15705 * @param wmi_handle: wmi handle
15706 * @param service_id: service identifier
15707 *
15708 * Return: 1 enabled, 0 disabled
15709 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015710#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015711static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15712 uint32_t service_id)
15713{
15714 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15715 service_id);
15716}
15717#else
15718static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15719 uint32_t service_id)
15720{
15721 return false;
15722}
15723#endif
15724
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015725static inline void copy_ht_cap_info(uint32_t ev_target_cap,
15726 struct wlan_psoc_target_capability_info *cap)
15727{
15728 /* except LDPC all flags are common betwen legacy and here
15729 * also IBFEER is not defined for TLV
15730 */
15731 cap->ht_cap_info |= ev_target_cap & (
15732 WMI_HT_CAP_ENABLED
15733 | WMI_HT_CAP_HT20_SGI
15734 | WMI_HT_CAP_DYNAMIC_SMPS
15735 | WMI_HT_CAP_TX_STBC
15736 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
15737 | WMI_HT_CAP_RX_STBC
15738 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
15739 | WMI_HT_CAP_LDPC
15740 | WMI_HT_CAP_L_SIG_TXOP_PROT
15741 | WMI_HT_CAP_MPDU_DENSITY
15742 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
15743 | WMI_HT_CAP_HT40_SGI);
15744 if (ev_target_cap & WMI_HT_CAP_LDPC)
15745 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
15746 WMI_HOST_HT_CAP_TX_LDPC;
15747}
Govind Singhe7f2f342016-05-23 12:12:52 +053015748/**
15749 * extract_service_ready_tlv() - extract service ready event
15750 * @wmi_handle: wmi handle
15751 * @param evt_buf: pointer to received event buffer
15752 * @param cap: pointer to hold target capability information extracted from even
15753 *
15754 * Return: QDF_STATUS_SUCCESS for success or error code
15755 */
15756static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015757 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015758{
15759 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15760 wmi_service_ready_event_fixed_param *ev;
15761
15762
15763 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15764
15765 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15766 if (!ev) {
15767 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15768 return QDF_STATUS_E_FAILURE;
15769 }
15770
15771 cap->phy_capability = ev->phy_capability;
15772 cap->max_frag_entry = ev->max_frag_entry;
15773 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015774 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053015775 cap->vht_cap_info = ev->vht_cap_info;
15776 cap->vht_supp_mcs = ev->vht_supp_mcs;
15777 cap->hw_min_tx_power = ev->hw_min_tx_power;
15778 cap->hw_max_tx_power = ev->hw_max_tx_power;
15779 cap->sys_cap_info = ev->sys_cap_info;
15780 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15781 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15782 cap->max_num_scan_channels = ev->max_num_scan_channels;
15783 cap->max_supported_macs = ev->max_supported_macs;
15784 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15785 cap->txrx_chainmask = ev->txrx_chainmask;
15786 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15787 cap->num_msdu_desc = ev->num_msdu_desc;
15788
15789 return QDF_STATUS_SUCCESS;
15790}
15791
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015792/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15793 * to host internal WMI_HOST_REGDMN_MODE values.
15794 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15795 * host currently. Add this in the future if required.
15796 * 11AX (Phase II) : 11ax related values are not currently
15797 * advertised separately by FW. As part of phase II regulatory bring-up,
15798 * finalize the advertisement mechanism.
15799 * @target_wireless_mode: target wireless mode received in message
15800 *
15801 * Return: returns the host internal wireless mode.
15802 */
15803static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15804{
15805
15806 uint32_t wireless_modes = 0;
15807
15808 if (target_wireless_mode & REGDMN_MODE_11A)
15809 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15810
15811 if (target_wireless_mode & REGDMN_MODE_TURBO)
15812 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15813
15814 if (target_wireless_mode & REGDMN_MODE_11B)
15815 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15816
15817 if (target_wireless_mode & REGDMN_MODE_PUREG)
15818 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15819
15820 if (target_wireless_mode & REGDMN_MODE_11G)
15821 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15822
15823 if (target_wireless_mode & REGDMN_MODE_108G)
15824 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15825
15826 if (target_wireless_mode & REGDMN_MODE_108A)
15827 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15828
15829 if (target_wireless_mode & REGDMN_MODE_XR)
15830 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15831
15832 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15833 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15834
15835 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15836 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15837
15838 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15839 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15840
15841 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15842 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15843
15844 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15845 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15846
15847 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15848 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15849
15850 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15851 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15852
15853 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15854 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15855
15856 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15857 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15858
15859 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15860 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15861
15862 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15863 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15864
15865 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15866 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15867
15868 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15869 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15870
15871 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15872 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15873
15874 return wireless_modes;
15875}
15876
Govind Singhe7f2f342016-05-23 12:12:52 +053015877/**
15878 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15879 * @wmi_handle: wmi handle
15880 * @param evt_buf: Pointer to event buffer
15881 * @param cap: pointer to hold HAL reg capabilities
15882 *
15883 * Return: QDF_STATUS_SUCCESS for success or error code
15884 */
15885static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015886 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015887{
15888 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15889
15890 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15891
15892 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15893 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015894 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015895
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015896 cap->wireless_modes = convert_wireless_modes_tlv(
15897 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015898
Govind Singhe7f2f342016-05-23 12:12:52 +053015899 return QDF_STATUS_SUCCESS;
15900}
15901
15902/**
15903 * extract_host_mem_req_tlv() - Extract host memory request event
15904 * @wmi_handle: wmi handle
15905 * @param evt_buf: pointer to event buffer
15906 * @param num_entries: pointer to hold number of entries requested
15907 *
15908 * Return: Number of entries requested
15909 */
15910static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15911 void *evt_buf, uint8_t *num_entries)
15912{
15913 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15914 wmi_service_ready_event_fixed_param *ev;
15915
15916 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15917
15918 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15919 if (!ev) {
15920 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15921 return NULL;
15922 }
15923
15924 *num_entries = ev->num_mem_reqs;
15925
15926 return (host_mem_req *)param_buf->mem_reqs;
15927}
15928
15929/**
15930 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15931 * ready function
15932 * @wmi_handle: wmi handle
15933 * @param evt_buf: pointer to event buffer
15934 *
15935 * Return: QDF_STATUS_SUCCESS for success or error code
15936 */
15937static QDF_STATUS
15938save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15939{
15940 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15941 wmi_service_ready_event_fixed_param *ev;
15942
15943
15944 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15945
15946 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15947 if (!ev) {
15948 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15949 return QDF_STATUS_E_FAILURE;
15950 }
15951
Govind Singh87542482016-06-08 19:40:11 +053015952#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015953 /*Save fw version from service ready message */
15954 /*This will be used while sending INIT message */
15955 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15956 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015957#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015958 return QDF_STATUS_SUCCESS;
15959}
15960
15961/**
15962 * ready_extract_init_status_tlv() - Extract init status from ready event
15963 * @wmi_handle: wmi handle
15964 * @param evt_buf: Pointer to event buffer
15965 *
15966 * Return: ready status
15967 */
15968static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15969 void *evt_buf)
15970{
15971 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15972 wmi_ready_event_fixed_param *ev = NULL;
15973
15974
15975 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15976 ev = param_buf->fixed_param;
15977
15978 qdf_print("%s:%d\n", __func__, ev->status);
15979
15980 return ev->status;
15981}
15982
15983/**
15984 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15985 * @wmi_handle: wmi handle
15986 * @param evt_buf: pointer to event buffer
15987 * @param macaddr: Pointer to hold MAC address
15988 *
15989 * Return: QDF_STATUS_SUCCESS for success or error code
15990 */
15991static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15992 void *evt_buf, uint8_t *macaddr)
15993{
15994 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15995 wmi_ready_event_fixed_param *ev = NULL;
15996
15997
15998 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15999 ev = param_buf->fixed_param;
16000
16001 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
16002
16003 return QDF_STATUS_SUCCESS;
16004}
16005
16006/**
16007 * extract_dbglog_data_len_tlv() - extract debuglog data length
16008 * @wmi_handle: wmi handle
16009 * @param evt_buf: pointer to event buffer
16010 *
16011 * Return: length
16012 */
16013static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080016014 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053016015{
16016 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
16017
16018 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
16019
16020 *len = param_buf->num_bufp;
16021
16022 return param_buf->bufp;
16023}
16024
16025/**
16026 * extract_vdev_start_resp_tlv() - extract vdev start response
16027 * @wmi_handle: wmi handle
16028 * @param evt_buf: pointer to event buffer
16029 * @param vdev_rsp: Pointer to hold vdev response
16030 *
16031 * Return: QDF_STATUS_SUCCESS for success or error code
16032 */
16033static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
16034 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
16035{
16036 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
16037 wmi_vdev_start_response_event_fixed_param *ev;
16038
16039 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
16040 if (!param_buf) {
16041 qdf_print("Invalid start response event buffer\n");
16042 return QDF_STATUS_E_INVAL;
16043 }
16044
16045 ev = param_buf->fixed_param;
16046 if (!ev) {
16047 qdf_print("Invalid start response event buffer\n");
16048 return QDF_STATUS_E_INVAL;
16049 }
16050
16051 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
16052
16053 vdev_rsp->vdev_id = ev->vdev_id;
16054 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070016055 switch (ev->resp_type) {
16056 case WMI_VDEV_START_RESP_EVENT:
16057 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
16058 break;
16059 case WMI_VDEV_RESTART_RESP_EVENT:
16060 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
16061 break;
16062 default:
16063 qdf_print("Invalid start response event buffer\n");
16064 break;
16065 };
Govind Singhe7f2f342016-05-23 12:12:52 +053016066 vdev_rsp->status = ev->status;
16067 vdev_rsp->chain_mask = ev->chain_mask;
16068 vdev_rsp->smps_mode = ev->smps_mode;
16069 vdev_rsp->mac_id = ev->mac_id;
16070 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
16071 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
16072
16073 return QDF_STATUS_SUCCESS;
16074}
16075
16076/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016077 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053016078 * @wmi_handle: wmi handle
16079 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016080 * @param num_vdevs: Pointer to hold num vdev
16081 *
16082 * Return: QDF_STATUS_SUCCESS for success or error code
16083 */
16084static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
16085 void *evt_buf, uint32_t *num_vdevs)
16086{
16087 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
16088 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
16089 uint32_t vdev_map;
16090
16091 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
16092 if (!param_buf) {
16093 qdf_print("Invalid tbtt update ext event buffer\n");
16094 return QDF_STATUS_E_INVAL;
16095 }
16096 tbtt_offset_event = param_buf->fixed_param;
16097 vdev_map = tbtt_offset_event->vdev_map;
16098 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16099
16100 return QDF_STATUS_SUCCESS;
16101}
16102
16103/**
16104 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
16105 * @wmi_handle: wmi handle
16106 * @param evt_buf: pointer to event buffer
16107 * @param num_vdevs: Pointer to hold num vdev
16108 *
16109 * Return: QDF_STATUS_SUCCESS for success or error code
16110 */
16111static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
16112 void *evt_buf, uint32_t *num_vdevs)
16113{
16114 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
16115 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
16116
16117 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
16118 if (!param_buf) {
16119 qdf_print("Invalid tbtt update ext event buffer\n");
16120 return QDF_STATUS_E_INVAL;
16121 }
16122 tbtt_offset_ext_event = param_buf->fixed_param;
16123
16124 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
16125
16126 return QDF_STATUS_SUCCESS;
16127}
16128
16129/**
16130 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
16131 * @wmi_handle: wmi handle
16132 * @param evt_buf: pointer to event buffer
16133 * @param idx: Index refering to a vdev
16134 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053016135 *
16136 * Return: QDF_STATUS_SUCCESS for success or error code
16137 */
16138static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016139 void *evt_buf, uint8_t idx,
16140 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016141{
16142 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
16143 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016144 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016145
16146 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
16147 if (!param_buf) {
16148 qdf_print("Invalid tbtt update event buffer\n");
16149 return QDF_STATUS_E_INVAL;
16150 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016151
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016152 tbtt_offset_event = param_buf->fixed_param;
16153 vdev_map = tbtt_offset_event->vdev_map;
16154 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
16155 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
16156 return QDF_STATUS_E_INVAL;
16157 tbtt_param->tbttoffset =
16158 param_buf->tbttoffset_list[tbtt_param->vdev_id];
16159
16160 return QDF_STATUS_SUCCESS;
16161}
16162
16163/**
16164 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
16165 * @wmi_handle: wmi handle
16166 * @param evt_buf: pointer to event buffer
16167 * @param idx: Index refering to a vdev
16168 * @param tbtt_param: Pointer to tbttoffset event param
16169 *
16170 * Return: QDF_STATUS_SUCCESS for success or error code
16171 */
16172static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
16173 void *evt_buf, uint8_t idx,
16174 struct tbttoffset_params *tbtt_param)
16175{
16176 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
16177 wmi_tbtt_offset_info *tbtt_offset_info;
16178
16179 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
16180 if (!param_buf) {
16181 qdf_print("Invalid tbtt update event buffer\n");
16182 return QDF_STATUS_E_INVAL;
16183 }
16184 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
16185
16186 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
16187 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053016188
16189 return QDF_STATUS_SUCCESS;
16190}
16191
16192/**
16193 * extract_mgmt_rx_params_tlv() - extract management rx params from event
16194 * @wmi_handle: wmi handle
16195 * @param evt_buf: pointer to event buffer
16196 * @param hdr: Pointer to hold header
16197 * @param bufp: Pointer to hold pointer to rx param buffer
16198 *
16199 * Return: QDF_STATUS_SUCCESS for success or error code
16200 */
16201static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053016202 void *evt_buf, struct mgmt_rx_event_params *hdr,
16203 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053016204{
16205 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
16206 wmi_mgmt_rx_hdr *ev_hdr = NULL;
16207
16208 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
16209 if (!param_tlvs) {
16210 WMI_LOGE("Get NULL point message from FW");
16211 return QDF_STATUS_E_INVAL;
16212 }
16213
16214 ev_hdr = param_tlvs->hdr;
16215 if (!hdr) {
16216 WMI_LOGE("Rx event is NULL");
16217 return QDF_STATUS_E_INVAL;
16218 }
16219
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016220 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16221 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016222
16223 hdr->channel = ev_hdr->channel;
16224 hdr->snr = ev_hdr->snr;
16225 hdr->rate = ev_hdr->rate;
16226 hdr->phy_mode = ev_hdr->phy_mode;
16227 hdr->buf_len = ev_hdr->buf_len;
16228 hdr->status = ev_hdr->status;
16229 hdr->flags = ev_hdr->flags;
16230 hdr->rssi = ev_hdr->rssi;
16231 hdr->tsf_delta = ev_hdr->tsf_delta;
16232 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
16233
16234 *bufp = param_tlvs->bufp;
16235
16236 return QDF_STATUS_SUCCESS;
16237}
16238
16239/**
16240 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
16241 * @wmi_handle: wmi handle
16242 * @param evt_buf: pointer to event buffer
16243 * @param vdev_id: Pointer to hold vdev identifier
16244 *
16245 * Return: QDF_STATUS_SUCCESS for success or error code
16246 */
16247static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
16248 void *evt_buf, uint32_t *vdev_id)
16249{
16250 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
16251 wmi_vdev_stopped_event_fixed_param *resp_event;
16252
16253 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
16254 if (!param_buf) {
16255 WMI_LOGE("Invalid event buffer");
16256 return QDF_STATUS_E_INVAL;
16257 }
16258 resp_event = param_buf->fixed_param;
16259 *vdev_id = resp_event->vdev_id;
16260
16261 return QDF_STATUS_SUCCESS;
16262}
16263
16264/**
16265 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
16266 * @wmi_handle: wmi handle
16267 * @param evt_buf: pointer to event buffer
16268 * @param param: Pointer to hold roam param
16269 *
16270 * Return: QDF_STATUS_SUCCESS for success or error code
16271 */
16272static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
16273 void *evt_buf, wmi_host_roam_event *param)
16274{
16275 WMI_ROAM_EVENTID_param_tlvs *param_buf;
16276 wmi_roam_event_fixed_param *evt;
16277
16278 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
16279 if (!param_buf) {
16280 WMI_LOGE("Invalid roam event buffer");
16281 return QDF_STATUS_E_INVAL;
16282 }
16283
16284 evt = param_buf->fixed_param;
16285 qdf_mem_zero(param, sizeof(*param));
16286
16287 param->vdev_id = evt->vdev_id;
16288 param->reason = evt->reason;
16289 param->rssi = evt->rssi;
16290
16291 return QDF_STATUS_SUCCESS;
16292}
16293
16294/**
16295 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
16296 * @wmi_handle: wmi handle
16297 * @param evt_buf: pointer to event buffer
16298 * @param param: Pointer to hold vdev scan param
16299 *
16300 * Return: QDF_STATUS_SUCCESS for success or error code
16301 */
16302static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016303 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016304{
16305 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
16306 wmi_scan_event_fixed_param *evt = NULL;
16307
16308 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
16309 evt = param_buf->fixed_param;
16310
16311 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016312
Govind Singhe7f2f342016-05-23 12:12:52 +053016313 switch (evt->event) {
16314 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016315 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016316 break;
16317 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016318 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016319 break;
16320 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016321 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016322 break;
16323 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016324 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016325 break;
16326 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016327 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016328 break;
16329 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016330 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016331 break;
16332 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016333 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016334 break;
16335 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016336 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016337 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053016338 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016339 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016340 break;
16341 case WMI_SCAN_EVENT_MAX:
16342 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016343 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016344 break;
16345 };
16346
16347 switch (evt->reason) {
16348 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016349 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016350 break;
16351 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016352 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016353 break;
16354 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016355 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016356 break;
16357 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016358 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016359 break;
16360 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016361 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016362 break;
16363 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016364 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016365 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016366 case WMI_SCAN_REASON_SUSPENDED:
16367 param->reason = SCAN_REASON_SUSPENDED;
16368 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016369 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016370 param->reason = SCAN_REASON_MAX;
16371 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016372 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016373 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016374 break;
16375 };
16376
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016377 param->chan_freq = evt->channel_freq;
16378 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053016379 param->scan_id = evt->scan_id;
16380 param->vdev_id = evt->vdev_id;
16381
16382 return QDF_STATUS_SUCCESS;
16383}
16384
Frank Liu3d5e9992017-03-15 17:51:43 +080016385#ifdef CONVERGED_TDLS_ENABLE
16386/**
16387 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
16388 * @wmi_handle: wmi handle
16389 * @param evt_buf: pointer to event buffer
16390 * @param param: Pointer to hold vdev tdls param
16391 *
16392 * Return: QDF_STATUS_SUCCESS for success or error code
16393 */
16394static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
16395 void *evt_buf, struct tdls_event_info *param)
16396{
16397 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
16398 wmi_tdls_peer_event_fixed_param *evt;
16399
16400 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
16401 if (!param_buf) {
16402 WMI_LOGE("%s: NULL param_buf", __func__);
16403 return QDF_STATUS_E_NULL_VALUE;
16404 }
16405
16406 evt = param_buf->fixed_param;
16407
16408 qdf_mem_zero(param, sizeof(*param));
16409
16410 param->vdev_id = evt->vdev_id;
16411 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
16412 param->peermac.bytes);
16413 switch (evt->peer_status) {
16414 case WMI_TDLS_SHOULD_DISCOVER:
16415 param->message_type = TDLS_SHOULD_DISCOVER;
16416 break;
16417 case WMI_TDLS_SHOULD_TEARDOWN:
16418 param->message_type = TDLS_SHOULD_TEARDOWN;
16419 break;
16420 case WMI_TDLS_PEER_DISCONNECTED:
16421 param->message_type = TDLS_PEER_DISCONNECTED;
16422 break;
16423 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
16424 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
16425 break;
16426 default:
16427 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
16428 __func__, evt->peer_status);
16429 return QDF_STATUS_E_INVAL;
16430 };
16431
16432 switch (evt->peer_reason) {
16433 case WMI_TDLS_TEARDOWN_REASON_TX:
16434 param->peer_reason = TDLS_TEARDOWN_TX;
16435 break;
16436 case WMI_TDLS_TEARDOWN_REASON_RSSI:
16437 param->peer_reason = TDLS_TEARDOWN_RSSI;
16438 break;
16439 case WMI_TDLS_TEARDOWN_REASON_SCAN:
16440 param->peer_reason = TDLS_TEARDOWN_SCAN;
16441 break;
16442 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
16443 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
16444 break;
16445 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
16446 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
16447 break;
16448 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
16449 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
16450 break;
16451 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
16452 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
16453 break;
16454 case WMI_TDLS_ENTER_BUF_STA:
16455 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
16456 break;
16457 case WMI_TDLS_EXIT_BUF_STA:
16458 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
16459 break;
16460 case WMI_TDLS_ENTER_BT_BUSY_MODE:
16461 param->peer_reason = TDLS_ENTER_BT_BUSY;
16462 break;
16463 case WMI_TDLS_EXIT_BT_BUSY_MODE:
16464 param->peer_reason = TDLS_EXIT_BT_BUSY;
16465 break;
16466 case WMI_TDLS_SCAN_STARTED_EVENT:
16467 param->peer_reason = TDLS_SCAN_STARTED;
16468 break;
16469 case WMI_TDLS_SCAN_COMPLETED_EVENT:
16470 param->peer_reason = TDLS_SCAN_COMPLETED;
16471 break;
16472
16473 default:
16474 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16475 __func__, evt->peer_reason, evt->peer_status);
16476 return QDF_STATUS_E_INVAL;
16477 };
16478
16479 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16480 __func__, param->peermac.bytes, param->message_type,
16481 param->peer_reason, param->vdev_id);
16482
16483 return QDF_STATUS_SUCCESS;
16484}
16485#endif
16486
Govind Singhe7f2f342016-05-23 12:12:52 +053016487/**
16488 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16489 * @wmi_handle: wmi handle
16490 * @param evt_buf: pointer to event buffer
16491 * @param param: Pointer to hold MGMT TX completion params
16492 *
16493 * Return: QDF_STATUS_SUCCESS for success or error code
16494 */
16495static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16496 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16497{
16498 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16499 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16500
16501 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16502 evt_buf;
16503 if (!param_buf) {
16504 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16505 return QDF_STATUS_E_INVAL;
16506 }
16507 cmpl_params = param_buf->fixed_param;
16508
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016509 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16510 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016511 param->desc_id = cmpl_params->desc_id;
16512 param->status = cmpl_params->status;
16513
16514 return QDF_STATUS_SUCCESS;
16515}
16516
16517/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016518 * extract_offchan_data_tx_compl_param_tlv() -
16519 * extract Offchan data tx completion event params
16520 * @wmi_handle: wmi handle
16521 * @param evt_buf: pointer to event buffer
16522 * @param param: Pointer to hold offchan data TX completion params
16523 *
16524 * Return: QDF_STATUS_SUCCESS for success or error code
16525 */
16526static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16527 wmi_unified_t wmi_handle, void *evt_buf,
16528 struct wmi_host_offchan_data_tx_compl_event *param)
16529{
16530 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16531 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16532
16533 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16534 evt_buf;
16535 if (!param_buf) {
16536 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16537 return QDF_STATUS_E_INVAL;
16538 }
16539 cmpl_params = param_buf->fixed_param;
16540
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016541 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16542 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016543 param->desc_id = cmpl_params->desc_id;
16544 param->status = cmpl_params->status;
16545
16546 return QDF_STATUS_SUCCESS;
16547}
16548
16549/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016550 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16551 * status tlv
16552 * @wmi_handle: wmi handle
16553 * @param evt_buf: pointer to event buffer
16554 * @param param: Pointer to hold csa switch count status event param
16555 *
16556 * Return: QDF_STATUS_SUCCESS for success or error code
16557 */
16558static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16559 wmi_unified_t wmi_handle,
16560 void *evt_buf,
16561 struct pdev_csa_switch_count_status *param)
16562{
16563 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16564 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16565
16566 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16567 evt_buf;
16568 if (!param_buf) {
16569 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16570 return QDF_STATUS_E_INVAL;
16571 }
16572
16573 csa_status = param_buf->fixed_param;
16574
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016575 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16576 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016577 param->current_switch_count = csa_status->current_switch_count;
16578 param->num_vdevs = csa_status->num_vdevs;
16579 param->vdev_ids = param_buf->vdev_ids;
16580
16581 return QDF_STATUS_SUCCESS;
16582}
16583
16584/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016585 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016586 * @wmi_handle: wmi handle
16587 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016588 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016589 *
16590 * Return: QDF_STATUS_SUCCESS for success or error code
16591 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016592static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16593 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016594{
16595 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16596 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016597 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016598
16599 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16600 if (!param_buf) {
16601 WMI_LOGE("Invalid swba event buffer");
16602 return QDF_STATUS_E_INVAL;
16603 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016604
Govind Singhe7f2f342016-05-23 12:12:52 +053016605 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016606 *num_vdevs = swba_event->num_vdevs;
16607 if (!(*num_vdevs)) {
16608 vdev_map = swba_event->vdev_map;
16609 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16610 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016611
16612 return QDF_STATUS_SUCCESS;
16613}
16614
16615/**
16616 * extract_swba_tim_info_tlv() - extract swba tim info from event
16617 * @wmi_handle: wmi handle
16618 * @param evt_buf: pointer to event buffer
16619 * @param idx: Index to bcn info
16620 * @param tim_info: Pointer to hold tim info
16621 *
16622 * Return: QDF_STATUS_SUCCESS for success or error code
16623 */
16624static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16625 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16626{
16627 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16628 wmi_tim_info *tim_info_ev;
16629
16630 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16631 if (!param_buf) {
16632 WMI_LOGE("Invalid swba event buffer");
16633 return QDF_STATUS_E_INVAL;
16634 }
16635
16636 tim_info_ev = &param_buf->tim_info[idx];
16637
16638 tim_info->tim_len = tim_info_ev->tim_len;
16639 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16640 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16641 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16642 tim_info->tim_changed = tim_info_ev->tim_changed;
16643 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016644 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016645
16646 return QDF_STATUS_SUCCESS;
16647}
16648
16649/**
16650 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16651 * @wmi_handle: wmi handle
16652 * @param evt_buf: pointer to event buffer
16653 * @param idx: Index to bcn info
16654 * @param p2p_desc: Pointer to hold p2p NoA info
16655 *
16656 * Return: QDF_STATUS_SUCCESS for success or error code
16657 */
16658static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16659 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16660{
16661 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16662 wmi_p2p_noa_info *p2p_noa_info;
16663 uint8_t i = 0;
16664
16665 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16666 if (!param_buf) {
16667 WMI_LOGE("Invalid swba event buffer");
16668 return QDF_STATUS_E_INVAL;
16669 }
16670
16671 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16672
16673 p2p_desc->modified = false;
16674 p2p_desc->num_descriptors = 0;
16675 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16676 p2p_desc->modified = true;
16677 p2p_desc->index =
16678 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16679 p2p_desc->oppPS =
16680 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16681 p2p_desc->ctwindow =
16682 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16683 p2p_desc->num_descriptors =
16684 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16685 (p2p_noa_info);
16686 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16687 p2p_desc->noa_descriptors[i].type_count =
16688 (uint8_t) p2p_noa_info->noa_descriptors[i].
16689 type_count;
16690 p2p_desc->noa_descriptors[i].duration =
16691 p2p_noa_info->noa_descriptors[i].duration;
16692 p2p_desc->noa_descriptors[i].interval =
16693 p2p_noa_info->noa_descriptors[i].interval;
16694 p2p_desc->noa_descriptors[i].start_time =
16695 p2p_noa_info->noa_descriptors[i].start_time;
16696 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016697 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016698 }
16699
16700 return QDF_STATUS_SUCCESS;
16701}
16702
Wu Gaocd3a8512017-03-13 20:17:34 +080016703#ifdef CONVERGED_P2P_ENABLE
16704/**
16705 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16706 * @wmi_handle: wmi handle
16707 * @param evt_buf: pointer to event buffer
16708 * @param param: Pointer to hold p2p noa info
16709 *
16710 * Return: QDF_STATUS_SUCCESS for success or error code
16711 */
16712static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16713 wmi_unified_t wmi_handle, void *evt_buf,
16714 struct p2p_noa_info *param)
16715{
16716 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16717 wmi_p2p_noa_event_fixed_param *fixed_param;
16718 uint8_t i;
16719 wmi_p2p_noa_info *wmi_noa_info;
16720 uint8_t *buf_ptr;
16721 uint32_t descriptors;
16722
16723 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16724 if (!param_tlvs) {
16725 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16726 return QDF_STATUS_E_INVAL;
16727 }
16728
16729 if (!param) {
16730 WMI_LOGE("noa information param is null");
16731 return QDF_STATUS_E_INVAL;
16732 }
16733
16734 fixed_param = param_tlvs->fixed_param;
16735 buf_ptr = (uint8_t *) fixed_param;
16736 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16737 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16738
16739 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16740 WMI_LOGE("%s: noa attr is not modified", __func__);
16741 return QDF_STATUS_E_INVAL;
16742 }
16743
16744 param->vdev_id = fixed_param->vdev_id;
16745 param->index =
16746 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16747 param->opps_ps =
16748 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16749 param->ct_window =
16750 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16751 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16752 param->num_desc = (uint8_t) descriptors;
16753
16754 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16755 param->index, param->opps_ps, param->ct_window,
16756 param->num_desc);
16757 for (i = 0; i < param->num_desc; i++) {
16758 param->noa_desc[i].type_count =
16759 (uint8_t) wmi_noa_info->noa_descriptors[i].
16760 type_count;
16761 param->noa_desc[i].duration =
16762 wmi_noa_info->noa_descriptors[i].duration;
16763 param->noa_desc[i].interval =
16764 wmi_noa_info->noa_descriptors[i].interval;
16765 param->noa_desc[i].start_time =
16766 wmi_noa_info->noa_descriptors[i].start_time;
16767 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16768 __func__, i, param->noa_desc[i].type_count,
16769 param->noa_desc[i].duration,
16770 param->noa_desc[i].interval,
16771 param->noa_desc[i].start_time);
16772 }
16773
16774 return QDF_STATUS_SUCCESS;
16775}
16776
16777/**
16778 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16779 * information from event
16780 * @wmi_handle: wmi handle
16781 * @param evt_buf: pointer to event buffer
16782 * @param param: Pointer to hold p2p lo stop event information
16783 *
16784 * Return: QDF_STATUS_SUCCESS for success or error code
16785 */
16786static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16787 wmi_unified_t wmi_handle, void *evt_buf,
16788 struct p2p_lo_event *param)
16789{
16790 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16791 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16792
16793 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16794 evt_buf;
16795 if (!param_tlvs) {
16796 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16797 return QDF_STATUS_E_INVAL;
16798 }
16799
16800 if (!param) {
16801 WMI_LOGE("lo stop event param is null");
16802 return QDF_STATUS_E_INVAL;
16803 }
16804
16805 lo_param = param_tlvs->fixed_param;
16806 param->vdev_id = lo_param->vdev_id;
16807 param->reason_code = lo_param->reason;
16808 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16809 param->vdev_id, param->reason_code);
16810
16811 return QDF_STATUS_SUCCESS;
16812}
16813#endif /* End of CONVERGED_P2P_ENABLE */
16814
Govind Singhe7f2f342016-05-23 12:12:52 +053016815/**
16816 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16817 * @wmi_handle: wmi handle
16818 * @param evt_buf: pointer to event buffer
16819 * @param ev: Pointer to hold peer param
16820 *
16821 * Return: QDF_STATUS_SUCCESS for success or error code
16822 */
16823static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16824 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16825{
16826 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16827 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16828
16829 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16830 kickout_event = param_buf->fixed_param;
16831
16832 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16833 ev->peer_macaddr);
16834
16835 ev->reason = kickout_event->reason;
16836 ev->rssi = kickout_event->rssi;
16837
16838 return QDF_STATUS_SUCCESS;
16839}
16840
16841/**
16842 * extract_all_stats_counts_tlv() - extract all stats count from event
16843 * @wmi_handle: wmi handle
16844 * @param evt_buf: pointer to event buffer
16845 * @param stats_param: Pointer to hold stats count
16846 *
16847 * Return: QDF_STATUS_SUCCESS for success or error code
16848 */
16849static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16850 void *evt_buf, wmi_host_stats_event *stats_param)
16851{
16852 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16853 wmi_stats_event_fixed_param *ev;
16854
16855 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16856
16857 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16858 if (!ev) {
16859 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16860 return QDF_STATUS_E_FAILURE;
16861 }
16862
16863 switch (ev->stats_id) {
16864 case WMI_REQUEST_PEER_STAT:
16865 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16866 break;
16867
16868 case WMI_REQUEST_AP_STAT:
16869 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16870 break;
16871
16872 case WMI_REQUEST_PDEV_STAT:
16873 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16874 break;
16875
16876 case WMI_REQUEST_VDEV_STAT:
16877 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16878 break;
16879
16880 case WMI_REQUEST_BCNFLT_STAT:
16881 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16882 break;
16883
16884 case WMI_REQUEST_VDEV_RATE_STAT:
16885 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16886 break;
16887
16888 default:
16889 stats_param->stats_id = 0;
16890 break;
16891
16892 }
16893
16894 stats_param->num_pdev_stats = ev->num_pdev_stats;
16895 stats_param->num_pdev_ext_stats = 0;
16896 stats_param->num_vdev_stats = ev->num_vdev_stats;
16897 stats_param->num_peer_stats = ev->num_peer_stats;
16898 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16899 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016900 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016901
16902 return QDF_STATUS_SUCCESS;
16903}
16904
16905/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016906 * extract_pdev_tx_stats() - extract pdev tx stats from event
16907 */
16908static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16909{
16910 /* Tx Stats */
16911 tx->comp_queued = tx_stats->comp_queued;
16912 tx->comp_delivered = tx_stats->comp_delivered;
16913 tx->msdu_enqued = tx_stats->msdu_enqued;
16914 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16915 tx->wmm_drop = tx_stats->wmm_drop;
16916 tx->local_enqued = tx_stats->local_enqued;
16917 tx->local_freed = tx_stats->local_freed;
16918 tx->hw_queued = tx_stats->hw_queued;
16919 tx->hw_reaped = tx_stats->hw_reaped;
16920 tx->underrun = tx_stats->underrun;
16921 tx->tx_abort = tx_stats->tx_abort;
16922 tx->mpdus_requed = tx_stats->mpdus_requed;
16923 tx->data_rc = tx_stats->data_rc;
16924 tx->self_triggers = tx_stats->self_triggers;
16925 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16926 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16927 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16928 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16929 tx->pdev_resets = tx_stats->pdev_resets;
16930 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16931 tx->phy_underrun = tx_stats->phy_underrun;
16932 tx->txop_ovf = tx_stats->txop_ovf;
16933
16934 return;
16935}
16936
16937
16938/**
16939 * extract_pdev_rx_stats() - extract pdev rx stats from event
16940 */
16941static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16942{
16943 /* Rx Stats */
16944 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16945 rx->status_rcvd = rx_stats->status_rcvd;
16946 rx->r0_frags = rx_stats->r0_frags;
16947 rx->r1_frags = rx_stats->r1_frags;
16948 rx->r2_frags = rx_stats->r2_frags;
16949 /* Only TLV */
16950 rx->r3_frags = 0;
16951 rx->htt_msdus = rx_stats->htt_msdus;
16952 rx->htt_mpdus = rx_stats->htt_mpdus;
16953 rx->loc_msdus = rx_stats->loc_msdus;
16954 rx->loc_mpdus = rx_stats->loc_mpdus;
16955 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16956 rx->phy_errs = rx_stats->phy_errs;
16957 rx->phy_err_drop = rx_stats->phy_err_drop;
16958 rx->mpdu_errs = rx_stats->mpdu_errs;
16959
16960 return;
16961}
16962
16963/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016964 * extract_pdev_stats_tlv() - extract pdev stats from event
16965 * @wmi_handle: wmi handle
16966 * @param evt_buf: pointer to event buffer
16967 * @param index: Index into pdev stats
16968 * @param pdev_stats: Pointer to hold pdev stats
16969 *
16970 * Return: QDF_STATUS_SUCCESS for success or error code
16971 */
16972static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16973 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16974{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016975 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16976 wmi_stats_event_fixed_param *ev_param;
16977 uint8_t *data;
16978
16979 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16980 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16981
16982 data = param_buf->data;
16983
16984 if (index < ev_param->num_pdev_stats) {
16985 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
16986 (index * sizeof(wmi_pdev_stats)));
16987
16988 pdev_stats->chan_nf = ev->chan_nf;
16989 pdev_stats->tx_frame_count = ev->tx_frame_count;
16990 pdev_stats->rx_frame_count = ev->rx_frame_count;
16991 pdev_stats->rx_clear_count = ev->rx_clear_count;
16992 pdev_stats->cycle_count = ev->cycle_count;
16993 pdev_stats->phy_err_count = ev->phy_err_count;
16994 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
16995
16996 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
16997 &(ev->pdev_stats.tx));
16998 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
16999 &(ev->pdev_stats.rx));
17000 }
17001
Govind Singhe7f2f342016-05-23 12:12:52 +053017002 return QDF_STATUS_SUCCESS;
17003}
17004
17005/**
17006 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
17007 * @wmi_handle: wmi handle
17008 * @param evt_buf: pointer to event buffer
17009 * @param index: Index into extended pdev stats
17010 * @param pdev_ext_stats: Pointer to hold extended pdev stats
17011 *
17012 * Return: QDF_STATUS_SUCCESS for success or error code
17013 */
17014static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
17015 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
17016{
17017 return QDF_STATUS_SUCCESS;
17018}
17019
17020/**
17021 * extract_vdev_stats_tlv() - extract vdev stats from event
17022 * @wmi_handle: wmi handle
17023 * @param evt_buf: pointer to event buffer
17024 * @param index: Index into vdev stats
17025 * @param vdev_stats: Pointer to hold vdev stats
17026 *
17027 * Return: QDF_STATUS_SUCCESS for success or error code
17028 */
17029static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
17030 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
17031{
17032 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17033 wmi_stats_event_fixed_param *ev_param;
17034 uint8_t *data;
17035
17036 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17037 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17038 data = (uint8_t *) param_buf->data;
17039
17040 if (index < ev_param->num_vdev_stats) {
17041 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
17042 ((ev_param->num_pdev_stats) *
17043 sizeof(wmi_pdev_stats)) +
17044 (index * sizeof(wmi_vdev_stats)));
17045
17046 vdev_stats->vdev_id = ev->vdev_id;
17047 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
17048 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
17049
17050 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
17051 sizeof(ev->tx_frm_cnt));
17052 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
17053 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
17054 ev->multiple_retry_cnt,
17055 sizeof(ev->multiple_retry_cnt));
17056 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
17057 sizeof(ev->fail_cnt));
17058 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
17059 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
17060 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
17061 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
17062 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
17063 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
17064 sizeof(ev->tx_rate_history));
17065 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
17066 sizeof(ev->bcn_rssi_history));
17067
17068 }
17069
17070 return QDF_STATUS_SUCCESS;
17071}
17072
17073/**
17074 * extract_peer_stats_tlv() - extract peer stats from event
17075 * @wmi_handle: wmi handle
17076 * @param evt_buf: pointer to event buffer
17077 * @param index: Index into peer stats
17078 * @param peer_stats: Pointer to hold peer stats
17079 *
17080 * Return: QDF_STATUS_SUCCESS for success or error code
17081 */
17082static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
17083 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
17084{
17085 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17086 wmi_stats_event_fixed_param *ev_param;
17087 uint8_t *data;
17088
17089 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17090 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17091 data = (uint8_t *) param_buf->data;
17092
17093 if (index < ev_param->num_peer_stats) {
17094 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
17095 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
17096 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
17097 (index * sizeof(wmi_peer_stats)));
17098
17099 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
17100
17101 OS_MEMCPY(&(peer_stats->peer_macaddr),
17102 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
17103
17104 peer_stats->peer_rssi = ev->peer_rssi;
17105 peer_stats->peer_tx_rate = ev->peer_tx_rate;
17106 peer_stats->peer_rx_rate = ev->peer_rx_rate;
17107 }
17108
17109 return QDF_STATUS_SUCCESS;
17110}
17111
17112/**
17113 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
17114 * @wmi_handle: wmi handle
17115 * @param evt_buf: pointer to event buffer
17116 * @param index: Index into bcn fault stats
17117 * @param bcnflt_stats: Pointer to hold bcn fault stats
17118 *
17119 * Return: QDF_STATUS_SUCCESS for success or error code
17120 */
17121static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
17122 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
17123{
17124 return QDF_STATUS_SUCCESS;
17125}
17126
17127/**
17128 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
17129 * @wmi_handle: wmi handle
17130 * @param evt_buf: pointer to event buffer
17131 * @param index: Index into extended peer stats
17132 * @param peer_extd_stats: Pointer to hold extended peer stats
17133 *
17134 * Return: QDF_STATUS_SUCCESS for success or error code
17135 */
17136static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
17137 void *evt_buf, uint32_t index,
17138 wmi_host_peer_extd_stats *peer_extd_stats)
17139{
17140 return QDF_STATUS_SUCCESS;
17141}
17142
17143/**
17144 * extract_chan_stats_tlv() - extract chan stats from event
17145 * @wmi_handle: wmi handle
17146 * @param evt_buf: pointer to event buffer
17147 * @param index: Index into chan stats
17148 * @param vdev_extd_stats: Pointer to hold chan stats
17149 *
17150 * Return: QDF_STATUS_SUCCESS for success or error code
17151 */
17152static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
17153 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
17154{
17155 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17156 wmi_stats_event_fixed_param *ev_param;
17157 uint8_t *data;
17158
17159 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17160 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17161 data = (uint8_t *) param_buf->data;
17162
17163 if (index < ev_param->num_chan_stats) {
17164 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
17165 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
17166 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
17167 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
17168 (index * sizeof(wmi_chan_stats)));
17169
17170
17171 /* Non-TLV doesnt have num_chan_stats */
17172 chan_stats->chan_mhz = ev->chan_mhz;
17173 chan_stats->sampling_period_us = ev->sampling_period_us;
17174 chan_stats->rx_clear_count = ev->rx_clear_count;
17175 chan_stats->tx_duration_us = ev->tx_duration_us;
17176 chan_stats->rx_duration_us = ev->rx_duration_us;
17177 }
17178
17179 return QDF_STATUS_SUCCESS;
17180}
17181
17182/**
17183 * extract_profile_ctx_tlv() - extract profile context from event
17184 * @wmi_handle: wmi handle
17185 * @param evt_buf: pointer to event buffer
17186 * @idx: profile stats index to extract
17187 * @param profile_ctx: Pointer to hold profile context
17188 *
17189 * Return: QDF_STATUS_SUCCESS for success or error code
17190 */
17191static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
17192 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
17193{
17194 return QDF_STATUS_SUCCESS;
17195}
17196
17197/**
17198 * extract_profile_data_tlv() - extract profile data from event
17199 * @wmi_handle: wmi handle
17200 * @param evt_buf: pointer to event buffer
17201 * @param profile_data: Pointer to hold profile data
17202 *
17203 * Return: QDF_STATUS_SUCCESS for success or error code
17204 */
17205static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
17206 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
17207{
17208
17209 return QDF_STATUS_SUCCESS;
17210}
17211
17212/**
17213 * extract_chan_info_event_tlv() - extract chan information from event
17214 * @wmi_handle: wmi handle
17215 * @param evt_buf: pointer to event buffer
17216 * @param chan_info: Pointer to hold chan information
17217 *
17218 * Return: QDF_STATUS_SUCCESS for success or error code
17219 */
17220static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
17221 void *evt_buf, wmi_host_chan_info_event *chan_info)
17222{
17223 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
17224 wmi_chan_info_event_fixed_param *ev;
17225
17226 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
17227
17228 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
17229 if (!ev) {
17230 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
17231 return QDF_STATUS_E_FAILURE;
17232 }
17233
17234 chan_info->err_code = ev->err_code;
17235 chan_info->freq = ev->freq;
17236 chan_info->cmd_flags = ev->cmd_flags;
17237 chan_info->noise_floor = ev->noise_floor;
17238 chan_info->rx_clear_count = ev->rx_clear_count;
17239 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053017240 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
17241 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
17242 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053017243 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
17244 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
17245 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17246 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
17247 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
17248 chan_info->rx_frame_count = ev->rx_frame_count;
17249 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
17250 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053017251
17252 return QDF_STATUS_SUCCESS;
17253}
17254
17255/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017256 * extract_pdev_utf_event_tlv() - extract UTF data info from event
17257 * @wmi_handle: WMI handle
17258 * @param evt_buf: Pointer to event buffer
17259 * @param param: Pointer to hold data
17260 *
17261 * Return : QDF_STATUS_SUCCESS for success or error code
17262 */
17263static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
17264 uint8_t *evt_buf,
17265 struct wmi_host_pdev_utf_event *event)
17266{
17267 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017268 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017269
17270 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
17271 event->data = param_buf->data;
17272 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017273 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053017274 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017275 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017276 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017277
17278 return QDF_STATUS_SUCCESS;
17279}
Govind Singhe7f2f342016-05-23 12:12:52 +053017280
Kiran Venkatappa06520822016-08-10 23:55:40 +053017281/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017282 * extract_chainmask_tables_tlv() - extract chain mask tables from event
17283 * @wmi_handle: wmi handle
17284 * @param evt_buf: pointer to event buffer
17285 * @param param: Pointer to hold evt buf
17286 *
17287 * Return: QDF_STATUS_SUCCESS for success or error code
17288 */
17289static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
17290 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
17291{
17292 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17293 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
17294 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17295 uint8_t i = 0, j = 0;
17296
17297 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17298 if (!param_buf)
17299 return QDF_STATUS_E_INVAL;
17300
17301 hw_caps = param_buf->soc_hw_mode_caps;
17302 if (!hw_caps)
17303 return QDF_STATUS_E_INVAL;
17304
17305 if (!hw_caps->num_chainmask_tables)
17306 return QDF_STATUS_E_INVAL;
17307
17308 chainmask_caps = param_buf->mac_phy_chainmask_caps;
17309
17310 if (chainmask_caps == NULL)
17311 return QDF_STATUS_E_INVAL;
17312
17313 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
17314
17315 qdf_print("Dumping chain mask combo data for table : %d\n", i);
17316 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
17317
17318 chainmask_table[i].cap_list[j].chainmask =
17319 chainmask_caps->chainmask;
17320
17321 chainmask_table[i].cap_list[j].supports_chan_width_20 =
17322 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
17323
17324 chainmask_table[i].cap_list[j].supports_chan_width_40 =
17325 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
17326
17327 chainmask_table[i].cap_list[j].supports_chan_width_80 =
17328 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
17329
17330 chainmask_table[i].cap_list[j].supports_chan_width_160 =
17331 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
17332
17333 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
17334 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
17335
17336 chainmask_table[i].cap_list[j].chain_mask_2G =
17337 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
17338
17339 chainmask_table[i].cap_list[j].chain_mask_5G =
17340 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
17341
17342 chainmask_table[i].cap_list[j].chain_mask_tx =
17343 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
17344
17345 chainmask_table[i].cap_list[j].chain_mask_rx =
17346 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
17347
17348 chainmask_table[i].cap_list[j].supports_aDFS =
17349 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
17350
17351 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
17352 chainmask_caps->supported_flags,
17353 chainmask_caps->chainmask
17354 );
17355 chainmask_caps++;
17356 }
17357 }
17358
17359 return QDF_STATUS_SUCCESS;
17360}
17361
17362/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053017363 * extract_service_ready_ext_tlv() - extract basic extended service ready params
17364 * from event
17365 * @wmi_handle: wmi handle
17366 * @param evt_buf: pointer to event buffer
17367 * @param param: Pointer to hold evt buf
17368 *
17369 * Return: QDF_STATUS_SUCCESS for success or error code
17370 */
17371static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017372 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017373{
17374 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17375 wmi_service_ready_ext_event_fixed_param *ev;
17376 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17377 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017378 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
17379 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017380
17381 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17382 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017383 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017384
17385 ev = param_buf->fixed_param;
17386 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017387 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017388
17389 /* Move this to host based bitmap */
17390 param->default_conc_scan_config_bits =
17391 ev->default_conc_scan_config_bits;
17392 param->default_fw_config_bits = ev->default_fw_config_bits;
17393 param->he_cap_info = ev->he_cap_info;
17394 param->mpdu_density = ev->mpdu_density;
17395 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
17396 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
17397
17398 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017399 if (hw_caps)
17400 param->num_hw_modes = hw_caps->num_hw_modes;
17401 else
17402 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017403
17404 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017405 if (reg_caps)
17406 param->num_phy = reg_caps->num_phy;
17407 else
17408 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017409
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017410 if (hw_caps) {
17411 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
17412 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
17413 } else
17414 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017415
17416 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
17417
17418 if (chain_mask_combo == NULL)
17419 return QDF_STATUS_SUCCESS;
17420
17421 qdf_print("Dumping chain mask combo data\n");
17422
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017423 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017424
17425 qdf_print("table_id : %d Num valid chainmasks: %d\n",
17426 chain_mask_combo->chainmask_table_id,
17427 chain_mask_combo->num_valid_chainmask
17428 );
17429
17430 param->chainmask_table[i].table_id =
17431 chain_mask_combo->chainmask_table_id;
17432 param->chainmask_table[i].num_valid_chainmasks =
17433 chain_mask_combo->num_valid_chainmask;
17434 chain_mask_combo++;
17435 }
17436 qdf_print("chain mask combo end\n");
17437
Kiran Venkatappa06520822016-08-10 23:55:40 +053017438 return QDF_STATUS_SUCCESS;
17439}
17440
17441/**
17442 * extract_hw_mode_cap_service_ready_ext_tlv() -
17443 * extract HW mode cap from service ready event
17444 * @wmi_handle: wmi handle
17445 * @param evt_buf: pointer to event buffer
17446 * @param param: Pointer to hold evt buf
17447 * @param hw_mode_idx: hw mode idx should be less than num_mode
17448 *
17449 * Return: QDF_STATUS_SUCCESS for success or error code
17450 */
17451static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
17452 wmi_unified_t wmi_handle,
17453 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017454 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017455{
17456 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17457 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17458
17459 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17460 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017461 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017462
17463 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017464 if (!hw_caps)
17465 return QDF_STATUS_E_INVAL;
17466
Kiran Venkatappa06520822016-08-10 23:55:40 +053017467 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017468 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017469
17470 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
17471 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
17472
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017473 param->hw_mode_config_type =
17474 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
17475
Kiran Venkatappa06520822016-08-10 23:55:40 +053017476 return QDF_STATUS_SUCCESS;
17477}
17478
17479/**
17480 * extract_mac_phy_cap_service_ready_ext_tlv() -
17481 * extract MAC phy cap from service ready event
17482 * @wmi_handle: wmi handle
17483 * @param evt_buf: pointer to event buffer
17484 * @param param: Pointer to hold evt buf
17485 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017486 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017487 *
17488 * Return: QDF_STATUS_SUCCESS for success or error code
17489 */
17490static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17491 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017492 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017493 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017494{
17495 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017496 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017497 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17498 uint32_t phy_map;
17499 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017500
17501 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17502 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017503 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017504
17505 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017506 if (!hw_caps)
17507 return QDF_STATUS_E_INVAL;
17508
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017509 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17510 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17511 break;
17512
17513 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17514 while (phy_map) {
17515 phy_map >>= 1;
17516 phy_idx++;
17517 }
17518 }
17519
17520 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017521 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017522
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017523 phy_idx += phy_id;
17524 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017525 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017526
17527 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017528
17529 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017530 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17531 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017532 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017533 param->supports_11b =
17534 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17535 param->supports_11g =
17536 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17537 param->supports_11a =
17538 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17539 param->supports_11n =
17540 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17541 param->supports_11ac =
17542 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17543 param->supports_11ax =
17544 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017545
17546 param->supported_bands = mac_phy_caps->supported_bands;
17547 param->ampdu_density = mac_phy_caps->ampdu_density;
17548 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17549 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17550 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17551 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17552 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17553 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17554 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17555 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17556 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17557 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17558 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17559 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17560 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17561 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17562 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17563 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017564 qdf_mem_copy(&param->he_cap_phy_info_2G,
17565 &mac_phy_caps->he_cap_phy_info_2G,
17566 sizeof(param->he_cap_phy_info_2G));
17567 qdf_mem_copy(&param->he_cap_phy_info_5G,
17568 &mac_phy_caps->he_cap_phy_info_5G,
17569 sizeof(param->he_cap_phy_info_5G));
17570 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17571 sizeof(param->he_ppet2G));
17572 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17573 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017574 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017575
17576 return QDF_STATUS_SUCCESS;
17577}
17578
17579/**
17580 * extract_reg_cap_service_ready_ext_tlv() -
17581 * extract REG cap from service ready event
17582 * @wmi_handle: wmi handle
17583 * @param evt_buf: pointer to event buffer
17584 * @param param: Pointer to hold evt buf
17585 * @param phy_idx: phy idx should be less than num_mode
17586 *
17587 * Return: QDF_STATUS_SUCCESS for success or error code
17588 */
17589static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17590 wmi_unified_t wmi_handle,
17591 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017592 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017593{
17594 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17595 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17596 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17597
17598 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17599 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017600 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017601
17602 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017603 if (!reg_caps)
17604 return QDF_STATUS_E_INVAL;
17605
Kiran Venkatappa06520822016-08-10 23:55:40 +053017606 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017607 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017608
17609 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17610
17611 param->phy_id = ext_reg_cap->phy_id;
17612 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17613 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17614 param->regcap1 = ext_reg_cap->regcap1;
17615 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017616 param->wireless_modes = convert_wireless_modes_tlv(
17617 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017618 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17619 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17620 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17621 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17622
17623 return QDF_STATUS_SUCCESS;
17624}
17625
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017626/**
17627 * extract_dcs_interference_type_tlv() - extract dcs interference type
17628 * from event
17629 * @wmi_handle: wmi handle
17630 * @param evt_buf: pointer to event buffer
17631 * @param param: Pointer to hold dcs interference param
17632 *
17633 * Return: 0 for success or error code
17634 */
17635static QDF_STATUS extract_dcs_interference_type_tlv(
17636 wmi_unified_t wmi_handle,
17637 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17638{
17639 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17640
17641 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17642 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017643 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017644
17645 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017646 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17647 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017648
17649 return QDF_STATUS_SUCCESS;
17650}
17651
17652/*
17653 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17654 * @wmi_handle: wmi handle
17655 * @param evt_buf: pointer to event buffer
17656 * @param cw_int: Pointer to hold cw interference
17657 *
17658 * Return: 0 for success or error code
17659 */
17660static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17661 void *evt_buf,
17662 wmi_host_ath_dcs_cw_int *cw_int)
17663{
17664 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17665 wlan_dcs_cw_int *ev;
17666
17667 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17668 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017669 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017670
17671 ev = param_buf->cw_int;
17672
17673 cw_int->channel = ev->channel;
17674
17675 return QDF_STATUS_SUCCESS;
17676}
17677
17678/**
17679 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17680 * @wmi_handle: wmi handle
17681 * @param evt_buf: pointer to event buffer
17682 * @param wlan_stat: Pointer to hold wlan stats
17683 *
17684 * Return: 0 for success or error code
17685 */
17686static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17687 void *evt_buf,
17688 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17689{
17690 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17691 wlan_dcs_im_tgt_stats_t *ev;
17692
17693 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17694 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017695 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017696
17697 ev = param_buf->wlan_stat;
17698 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17699 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17700 wlan_stat->tx_waste_time = ev->tx_waste_time;
17701 wlan_stat->rx_time = ev->rx_time;
17702 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17703 wlan_stat->mib_stats.listen_time = ev->listen_time;
17704 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17705 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17706 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17707 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17708 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17709 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17710 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17711 wlan_stat->chan_nf = ev->chan_nf;
17712 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17713
17714 return QDF_STATUS_SUCCESS;
17715}
17716
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017717/**
17718 * extract_thermal_stats_tlv() - extract thermal stats from event
17719 * @wmi_handle: wmi handle
17720 * @param evt_buf: Pointer to event buffer
17721 * @param temp: Pointer to hold extracted temperature
17722 * @param level: Pointer to hold extracted level
17723 *
17724 * Return: 0 for success or error code
17725 */
17726static QDF_STATUS
17727extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17728 void *evt_buf, uint32_t *temp,
17729 uint32_t *level, uint32_t *pdev_id)
17730{
17731 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17732 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17733
17734 param_buf =
17735 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17736 if (!param_buf)
17737 return QDF_STATUS_E_INVAL;
17738
17739 tt_stats_event = param_buf->fixed_param;
17740
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017741 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17742 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017743 *temp = tt_stats_event->temp;
17744 *level = tt_stats_event->level;
17745
17746 return QDF_STATUS_SUCCESS;
17747}
17748
17749/**
17750 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17751 * @wmi_handle: wmi handle
17752 * @param evt_buf: pointer to event buffer
17753 * @param idx: Index to level stats
17754 * @param levelcount: Pointer to hold levelcount
17755 * @param dccount: Pointer to hold dccount
17756 *
17757 * Return: 0 for success or error code
17758 */
17759static QDF_STATUS
17760extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17761 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17762 uint32_t *dccount)
17763{
17764 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17765 wmi_therm_throt_level_stats_info *tt_level_info;
17766
17767 param_buf =
17768 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17769 if (!param_buf)
17770 return QDF_STATUS_E_INVAL;
17771
17772 tt_level_info = param_buf->therm_throt_level_stats_info;
17773
17774 if (idx < THERMAL_LEVELS) {
17775 *levelcount = tt_level_info[idx].level_count;
17776 *dccount = tt_level_info[idx].dc_count;
17777 return QDF_STATUS_SUCCESS;
17778 }
17779
17780 return QDF_STATUS_E_FAILURE;
17781}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017782#ifdef BIG_ENDIAN_HOST
17783/**
17784 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17785 * @param data_len - data length
17786 * @param data - pointer to data
17787 *
17788 * Return: QDF_STATUS - success or error status
17789 */
17790static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17791{
17792 uint8_t *data_aligned = NULL;
17793 int c;
17794 unsigned char *data_unaligned;
17795
17796 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17797 FIPS_ALIGN));
17798 /* Assigning unaligned space to copy the data */
17799 /* Checking if kmalloc does succesful allocation */
17800 if (data_unaligned == NULL)
17801 return QDF_STATUS_E_FAILURE;
17802
17803 /* Checking if space is alligned */
17804 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17805 /* align the data space */
17806 data_aligned =
17807 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17808 } else {
17809 data_aligned = (u_int8_t *)data_unaligned;
17810 }
17811
17812 /* memset and copy content from data to data aligned */
17813 OS_MEMSET(data_aligned, 0, data_len);
17814 OS_MEMCPY(data_aligned, data, data_len);
17815 /* Endianness to LE */
17816 for (c = 0; c < data_len/4; c++) {
17817 *((u_int32_t *)data_aligned + c) =
17818 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17819 }
17820
17821 /* Copy content to event->data */
17822 OS_MEMCPY(data, data_aligned, data_len);
17823
17824 /* clean up allocated space */
17825 qdf_mem_free(data_unaligned);
17826 data_aligned = NULL;
17827 data_unaligned = NULL;
17828
17829 /*************************************************************/
17830
17831 return QDF_STATUS_SUCCESS;
17832}
17833#else
17834/**
17835 * fips_conv_data_be() - DUMMY for LE platform
17836 *
17837 * Return: QDF_STATUS - success
17838 */
17839static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17840{
17841 return QDF_STATUS_SUCCESS;
17842}
17843#endif
17844
17845/**
17846 * extract_fips_event_data_tlv() - extract fips event data
17847 * @wmi_handle: wmi handle
17848 * @param evt_buf: pointer to event buffer
17849 * @param param: pointer FIPS event params
17850 *
17851 * Return: 0 for success or error code
17852 */
17853static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17854 void *evt_buf, struct wmi_host_fips_event_param *param)
17855{
17856 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17857 wmi_pdev_fips_event_fixed_param *event;
17858
17859 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17860 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17861
17862 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17863 QDF_STATUS_SUCCESS)
17864 return QDF_STATUS_E_FAILURE;
17865
17866 param->data = (uint32_t *)param_buf->data;
17867 param->data_len = event->data_len;
17868 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017869 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17870 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017871
17872 return QDF_STATUS_SUCCESS;
17873}
17874
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017875/*
17876 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17877 * @wmi_handle: wmi handle
17878 * @param evt_buf: pointer to event buffer
17879 * @param vdev_id: Pointer to hold vdev_id
17880 * @param mac_addr: Pointer to hold peer mac address
17881 *
17882 * Return: QDF_STATUS_SUCCESS for success or error code
17883 */
17884static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17885 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17886{
17887 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17888 wmi_peer_delete_resp_event_fixed_param *ev;
17889
17890 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17891
17892 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17893 if (!ev) {
17894 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17895 return QDF_STATUS_E_FAILURE;
17896 }
17897
17898 param->vdev_id = ev->vdev_id;
17899 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17900 &param->mac_address.bytes[0]);
17901
17902 return QDF_STATUS_SUCCESS;
17903}
17904
Govind Singhecf03cd2016-05-12 12:45:51 +053017905static bool is_management_record_tlv(uint32_t cmd_id)
17906{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017907 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017908 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017909
Govind Singhecf03cd2016-05-12 12:45:51 +053017910 return false;
17911}
17912
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017913static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17914{
17915 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17916
17917 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17918
17919 switch (set_cmd->param_id) {
17920 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17921 case WMI_VDEV_PARAM_DTIM_POLICY:
17922 return HTC_TX_PACKET_TAG_AUTO_PM;
17923 default:
17924 break;
17925 }
17926
17927 return 0;
17928}
17929
17930static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17931{
17932 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17933
17934 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17935
17936 switch (ps_cmd->param) {
17937 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17938 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17939 case WMI_STA_PS_ENABLE_QPOWER:
17940 return HTC_TX_PACKET_TAG_AUTO_PM;
17941 default:
17942 break;
17943 }
17944
17945 return 0;
17946}
17947
17948static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17949 uint32_t cmd_id)
17950{
17951 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17952 return 0;
17953
17954 switch (cmd_id) {
17955 case WMI_VDEV_SET_PARAM_CMDID:
17956 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17957 case WMI_STA_POWERSAVE_PARAM_CMDID:
17958 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17959 default:
17960 break;
17961 }
17962
17963 return 0;
17964}
17965
17966static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17967{
17968 uint16_t tag = 0;
17969
17970 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17971 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17972 __func__);
17973 return tag;
17974 }
17975
17976 if (wmi_handle->tag_crash_inject)
17977 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17978
17979 wmi_handle->tag_crash_inject = false;
17980 return tag;
17981}
17982
17983/**
17984 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17985 * @wmi_handle: WMI handle
17986 * @buf: WMI buffer
17987 * @cmd_id: WMI command Id
17988 *
17989 * Return htc_tx_tag
17990 */
17991static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17992 wmi_buf_t buf,
17993 uint32_t cmd_id)
17994{
17995 uint16_t htc_tx_tag = 0;
17996
17997 switch (cmd_id) {
17998 case WMI_WOW_ENABLE_CMDID:
17999 case WMI_PDEV_SUSPEND_CMDID:
18000 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
18001 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
18002 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
18003 case WMI_PDEV_RESUME_CMDID:
18004 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
18005 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
18006#ifdef FEATURE_WLAN_D0WOW
18007 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
18008#endif
18009 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
18010 break;
18011 case WMI_FORCE_FW_HANG_CMDID:
18012 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
18013 break;
18014 case WMI_VDEV_SET_PARAM_CMDID:
18015 case WMI_STA_POWERSAVE_PARAM_CMDID:
18016 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
18017 default:
18018 break;
18019 }
18020
18021 return htc_tx_tag;
18022}
18023
Sathish Kumard3ab1002017-02-07 17:10:59 +053018024/**
18025 * extract_channel_hopping_event_tlv() - extract channel hopping param
18026 * from event
18027 * @wmi_handle: wmi handle
18028 * @param evt_buf: pointer to event buffer
18029 * @param ch_hopping: Pointer to hold channel hopping param
18030 *
18031 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18032 */
18033static QDF_STATUS extract_channel_hopping_event_tlv(
18034 wmi_unified_t wmi_handle, void *evt_buf,
18035 wmi_host_pdev_channel_hopping_event *ch_hopping)
18036{
18037 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
18038 wmi_pdev_channel_hopping_event_fixed_param *event;
18039
18040 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
18041 event = (wmi_pdev_channel_hopping_event_fixed_param *)
18042 param_buf->fixed_param;
18043
18044 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
18045 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018046 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18047 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053018048
18049 return QDF_STATUS_SUCCESS;
18050}
18051
18052/**
18053 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
18054 * @wmi_handle: wmi handle
18055 * @param evt_buf: pointer to event buffer
18056 * @param param: Pointer to hold tpc param
18057 *
18058 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18059 */
18060static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
18061 void *evt_buf,
18062 wmi_host_pdev_tpc_event *param)
18063{
18064 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
18065 wmi_pdev_tpc_event_fixed_param *event;
18066
18067 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
18068 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
18069
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018070 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18071 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053018072 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
18073
18074 return QDF_STATUS_SUCCESS;
18075}
18076
18077
18078#ifdef BIG_ENDIAN_HOST
18079/**
18080 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
18081 * @param data_len - data length
18082 * @param data - pointer to data
18083 *
18084 * Return: QDF_STATUS - success or error status
18085 */
18086static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
18087{
18088 uint8_t *datap = (uint8_t *)ev;
18089 /* Skip swapping the first word */
18090 datap += sizeof(uint32_t);
18091 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
18092 i++, datap += sizeof(uint32_t)) {
18093 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
18094 }
18095
18096 return QDF_STATUS_SUCCESS;
18097}
18098#else
18099/**
18100 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
18101 * @param data_len - data length
18102 * @param data - pointer to data
18103 *
18104 * Return: QDF_STATUS - success or error status
18105 */
18106static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
18107{
18108 return QDF_STATUS_SUCCESS;
18109}
18110#endif
18111
18112/**
18113 * extract_wds_addr_event_tlv() - extract wds address from event
18114 * @wmi_handle: wmi handle
18115 * @param evt_buf: pointer to event buffer
18116 * @param wds_ev: Pointer to hold wds address
18117 *
18118 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18119 */
18120static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
18121 void *evt_buf,
18122 uint16_t len, wds_addr_event_t *wds_ev)
18123{
18124 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
18125 wmi_wds_addr_event_fixed_param *ev;
18126 int i;
18127
18128 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
18129 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
18130
18131 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
18132 return QDF_STATUS_E_FAILURE;
18133
18134 qdf_mem_copy(wds_ev->event_type, ev->event_type,
18135 sizeof(wds_ev->event_type));
18136 for (i = 0; i < 4; i++) {
18137 wds_ev->peer_mac[i] =
18138 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
18139 wds_ev->dest_mac[i] =
18140 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
18141 }
18142 for (i = 0; i < 2; i++) {
18143 wds_ev->peer_mac[4+i] =
18144 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
18145 wds_ev->dest_mac[4+i] =
18146 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
18147 }
18148 return QDF_STATUS_SUCCESS;
18149}
18150
18151/**
18152 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
18153 * from event
18154 * @wmi_handle: wmi handle
18155 * @param evt_buf: pointer to event buffer
18156 * @param ev: Pointer to hold peer param and ps state
18157 *
18158 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18159 */
18160static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
18161 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
18162{
18163 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
18164 wmi_peer_sta_ps_statechange_event_fixed_param *event;
18165
18166 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
18167 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
18168 param_buf->fixed_param;
18169
18170 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
18171 ev->peer_ps_state = event->peer_ps_state;
18172
18173 return QDF_STATUS_SUCCESS;
18174}
18175
18176/**
18177 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
18178 * @wmi_handle: wmi handle
18179 * @param evt_buf: pointer to event buffer
18180 * @param inst_rssi_resp: Pointer to hold inst rssi response
18181 *
18182 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18183 */
18184static QDF_STATUS extract_inst_rssi_stats_event_tlv(
18185 wmi_unified_t wmi_handle, void *evt_buf,
18186 wmi_host_inst_stats_resp *inst_rssi_resp)
18187{
18188 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
18189 wmi_inst_rssi_stats_resp_fixed_param *event;
18190
18191 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
18192 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
18193
18194 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
18195 &(event->peer_macaddr), sizeof(wmi_mac_addr));
18196 inst_rssi_resp->iRSSI = event->iRSSI;
18197
18198 return QDF_STATUS_SUCCESS;
18199}
18200
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018201static struct cur_reg_rule
18202*create_reg_rules_from_wmi(uint32_t num_reg_rules,
18203 wmi_regulatory_rule_struct *wmi_reg_rule)
18204{
18205 struct cur_reg_rule *reg_rule_ptr;
18206 uint32_t count;
18207
18208 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
18209
18210 if (NULL == reg_rule_ptr) {
18211 WMI_LOGE("memory allocation failure");
18212 return NULL;
18213 }
18214
18215 for (count = 0; count < num_reg_rules; count++) {
18216 reg_rule_ptr[count].start_freq =
18217 WMI_REG_RULE_START_FREQ_GET(
18218 wmi_reg_rule[count].freq_info);
18219 reg_rule_ptr[count].end_freq =
18220 WMI_REG_RULE_END_FREQ_GET(
18221 wmi_reg_rule[count].freq_info);
18222 reg_rule_ptr[count].max_bw =
18223 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018224 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018225 reg_rule_ptr[count].reg_power =
18226 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018227 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053018228 reg_rule_ptr[count].ant_gain =
18229 WMI_REG_RULE_ANTENNA_GAIN_GET(
18230 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018231 reg_rule_ptr[count].flags =
18232 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018233 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018234 }
18235
18236 return reg_rule_ptr;
18237}
18238
18239static QDF_STATUS extract_reg_chan_list_update_event_tlv(
18240 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18241 struct cur_regulatory_info *reg_info, uint32_t len)
18242{
18243 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
18244 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
18245 wmi_regulatory_rule_struct *wmi_reg_rule;
18246 uint32_t num_2g_reg_rules, num_5g_reg_rules;
18247
18248 WMI_LOGD("processing regulatory channel list");
18249
18250 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
18251 if (!param_buf) {
18252 WMI_LOGE("invalid channel list event buf");
18253 return QDF_STATUS_E_FAILURE;
18254 }
18255
18256 chan_list_event_hdr = param_buf->fixed_param;
18257
18258 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
18259 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
18260 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053018261 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018262 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
18263 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070018264 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070018265 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053018266 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070018267 reg_info->ctry_code = chan_list_event_hdr->country_id;
18268 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
18269 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
18270 reg_info->status_code = REG_SET_CC_STATUS_PASS;
18271 else if (chan_list_event_hdr->status_code ==
18272 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
18273 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
18274 else if (chan_list_event_hdr->status_code ==
18275 WMI_REG_INIT_ALPHA2_NOT_FOUND)
18276 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
18277 else if (chan_list_event_hdr->status_code ==
18278 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
18279 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
18280 else if (chan_list_event_hdr->status_code ==
18281 WMI_REG_SET_CC_STATUS_NO_MEMORY)
18282 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
18283 else if (chan_list_event_hdr->status_code ==
18284 WMI_REG_SET_CC_STATUS_FAIL)
18285 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
18286
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018287 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
18288 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
18289 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
18290 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
18291
18292 num_2g_reg_rules = reg_info->num_2g_reg_rules;
18293 num_5g_reg_rules = reg_info->num_5g_reg_rules;
18294
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018295 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
18296 __func__, reg_info->alpha2, reg_info->dfs_region,
18297 reg_info->min_bw_2g, reg_info->max_bw_2g,
18298 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018299
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018300 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
18301 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070018302 wmi_reg_rule =
18303 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
18304 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
18305 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018306 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
18307 wmi_reg_rule);
18308 wmi_reg_rule += num_2g_reg_rules;
18309
18310 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
18311 wmi_reg_rule);
18312
18313 WMI_LOGD("processed regulatory channel list");
18314
18315 return QDF_STATUS_SUCCESS;
18316}
18317
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018318static QDF_STATUS extract_reg_11d_new_country_event_tlv(
18319 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18320 struct reg_11d_new_country *reg_11d_country, uint32_t len)
18321{
18322 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
18323 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
18324
18325 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
18326 if (!param_buf) {
18327 WMI_LOGE("invalid 11d country event buf");
18328 return QDF_STATUS_E_FAILURE;
18329 }
18330
18331 reg_11d_country_event = param_buf->fixed_param;
18332
18333 qdf_mem_copy(reg_11d_country->alpha2,
18334 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
18335
18336 WMI_LOGD("processed 11d country event, new cc %s",
18337 reg_11d_country->alpha2);
18338
18339 return QDF_STATUS_SUCCESS;
18340}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070018341
18342static QDF_STATUS extract_reg_ch_avoid_event_tlv(
18343 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18344 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
18345{
18346 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
18347 wmi_avoid_freq_range_desc *afr_desc;
18348 uint32_t num_freq_ranges, freq_range_idx;
18349 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
18350 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
18351
18352 if (!param_buf) {
18353 WMI_LOGE("Invalid channel avoid event buffer");
18354 return QDF_STATUS_E_INVAL;
18355 }
18356
18357 afr_fixed_param = param_buf->fixed_param;
18358 if (!afr_fixed_param) {
18359 WMI_LOGE("Invalid channel avoid event fixed param buffer");
18360 return QDF_STATUS_E_INVAL;
18361 }
18362
18363 if (!ch_avoid_ind) {
18364 WMI_LOGE("Invalid channel avoid indication buffer");
18365 return QDF_STATUS_E_INVAL;
18366 }
18367 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
18368 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
18369 afr_fixed_param->num_freq_ranges;
18370
18371 WMI_LOGD("Channel avoid event received with %d ranges",
18372 num_freq_ranges);
18373
18374 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
18375 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
18376 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
18377 freq_range_idx++) {
18378 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
18379 afr_desc->start_freq;
18380 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
18381 afr_desc->end_freq;
18382 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
18383 freq_range_idx, afr_desc->tlv_header,
18384 afr_desc->start_freq, afr_desc->end_freq);
18385 afr_desc++;
18386 }
18387
18388 return QDF_STATUS_SUCCESS;
18389}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018390#ifdef DFS_COMPONENT_ENABLE
18391/**
18392 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
18393 * @wmi_handle: wma handle
18394 * @evt_buf: event buffer
18395 * @vdev_id: vdev id
18396 * @len: length of buffer
18397 *
18398 * Return: 0 for success or error code
18399 */
18400static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
18401 uint8_t *evt_buf,
18402 uint32_t *vdev_id,
18403 uint32_t len)
18404{
18405 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
18406 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
18407
18408 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
18409 if (!param_tlvs) {
18410 WMI_LOGE("invalid cac complete event buf");
18411 return QDF_STATUS_E_FAILURE;
18412 }
18413
18414 cac_event = param_tlvs->fixed_param;
18415 *vdev_id = cac_event->vdev_id;
18416 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
18417
18418 return QDF_STATUS_SUCCESS;
18419}
18420
18421/**
18422 * extract_dfs_radar_detection_event_tlv() - extract radar found event
18423 * @wmi_handle: wma handle
18424 * @evt_buf: event buffer
18425 * @radar_found: radar found event info
18426 * @len: length of buffer
18427 *
18428 * Return: 0 for success or error code
18429 */
18430static QDF_STATUS extract_dfs_radar_detection_event_tlv(
18431 wmi_unified_t wmi_handle,
18432 uint8_t *evt_buf,
18433 struct radar_found_info *radar_found,
18434 uint32_t len)
18435{
18436 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
18437 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
18438
18439 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
18440 if (!param_tlv) {
18441 WMI_LOGE("invalid radar detection event buf");
18442 return QDF_STATUS_E_FAILURE;
18443 }
18444
18445 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018446 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18447 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018448 radar_found->detection_mode = radar_event->detection_mode;
18449 radar_found->freq_offset = radar_event->chan_freq;
18450 radar_found->chan_width = radar_event->chan_width;
18451 radar_found->detector_id = radar_event->detector_id;
18452 radar_found->segment_id = radar_event->segment_id;
18453 radar_found->timestamp = radar_event->timestamp;
18454 radar_found->is_chirp = radar_event->is_chirp;
18455
18456 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
18457
18458 return QDF_STATUS_SUCCESS;
18459}
18460#endif
18461
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018462/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018463 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
18464 * host to target defines. For legacy there is not conversion
18465 * required. Just return pdev_id as it is.
18466 * @param pdev_id: host pdev_id to be converted.
18467 * Return: target pdev_id after conversion.
18468 */
18469static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
18470 uint32_t pdev_id)
18471{
18472 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
18473 return WMI_PDEV_ID_SOC;
18474
18475 /*No conversion required*/
18476 return pdev_id;
18477}
18478
18479/**
18480 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
18481 * target to host defines. For legacy there is not conversion
18482 * required. Just return pdev_id as it is.
18483 * @param pdev_id: target pdev_id to be converted.
18484 * Return: host pdev_id after conversion.
18485 */
18486static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
18487 uint32_t pdev_id)
18488{
18489 /*No conversion required*/
18490 return pdev_id;
18491}
18492
18493/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018494 * send_set_country_cmd_tlv() - WMI scan channel list function
18495 * @param wmi_handle : handle to WMI.
18496 * @param param : pointer to hold scan channel list parameter
18497 *
18498 * Return: 0 on success and -ve on failure.
18499 */
18500static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
18501 struct set_country *params)
18502{
18503 wmi_buf_t buf;
18504 QDF_STATUS qdf_status;
18505 wmi_set_current_country_cmd_fixed_param *cmd;
18506 uint16_t len = sizeof(*cmd);
18507
18508 buf = wmi_buf_alloc(wmi_handle, len);
18509 if (!buf) {
18510 WMI_LOGE("Failed to allocate memory");
18511 qdf_status = QDF_STATUS_E_NOMEM;
18512 goto end;
18513 }
18514
18515 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
18516 WMITLV_SET_HDR(&cmd->tlv_header,
18517 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
18518 WMITLV_GET_STRUCT_TLVLEN
18519 (wmi_set_current_country_cmd_fixed_param));
18520
18521 WMI_LOGD("setting cuurnet country to %s", params->country);
18522
18523 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
18524
18525 cmd->pdev_id = params->pdev_id;
18526
18527 qdf_status = wmi_unified_cmd_send(wmi_handle,
18528 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18529
18530 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18531 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18532 wmi_buf_free(buf);
18533 }
18534
18535end:
18536 return qdf_status;
18537}
18538
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018539#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
18540 WMI_SET_BITS(alpha, 0, 8, val0); \
18541 WMI_SET_BITS(alpha, 8, 8, val1); \
18542 WMI_SET_BITS(alpha, 16, 8, val2); \
18543 } while (0)
18544
18545static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
18546 uint8_t pdev_id, struct cc_regdmn_s *rd)
18547{
18548 wmi_set_init_country_cmd_fixed_param *cmd;
18549 uint16_t len;
18550 wmi_buf_t buf;
18551 int ret;
18552
18553 len = sizeof(wmi_set_init_country_cmd_fixed_param);
18554 buf = wmi_buf_alloc(wmi_handle, len);
18555 if (!buf) {
18556 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
18557 return QDF_STATUS_E_NOMEM;
18558 }
18559 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
18560 WMITLV_SET_HDR(&cmd->tlv_header,
18561 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
18562 WMITLV_GET_STRUCT_TLVLEN
18563 (wmi_set_init_country_cmd_fixed_param));
18564
18565 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
18566
18567 if (rd->flags == CC_IS_SET) {
18568 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
18569 cmd->country_code.country_id = rd->cc.country_code;
18570 } else if (rd->flags == ALPHA_IS_SET) {
18571 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
18572 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
18573 rd->cc.alpha[0],
18574 rd->cc.alpha[1],
18575 rd->cc.alpha[2]);
18576 } else if (rd->flags == REGDMN_IS_SET) {
18577 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
18578 cmd->country_code.domain_code = rd->cc.regdmn_id;
18579 }
18580
18581 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
18582 WMI_SET_INIT_COUNTRY_CMDID);
18583 if (ret) {
18584 WMI_LOGE("Failed to config wow wakeup event");
18585 wmi_buf_free(buf);
18586 return QDF_STATUS_E_FAILURE;
18587 }
18588
18589 return QDF_STATUS_SUCCESS;
18590}
18591
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053018592/**
18593 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
18594 * configuration params
18595 * @wmi_handle: wmi handler
18596 * @limit_off_chan_param: pointer to wmi_off_chan_param
18597 *
18598 * Return: 0 for success and non zero for failure
18599 */
18600static
18601QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
18602 struct wmi_limit_off_chan_param *limit_off_chan_param)
18603{
18604 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
18605 wmi_buf_t buf;
18606 uint32_t len = sizeof(*cmd);
18607 int err;
18608
18609 buf = wmi_buf_alloc(wmi_handle, len);
18610 if (!buf) {
18611 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
18612 __func__);
18613 return QDF_STATUS_E_NOMEM;
18614 }
18615
18616 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
18617
18618 WMITLV_SET_HDR(&cmd->tlv_header,
18619 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
18620 WMITLV_GET_STRUCT_TLVLEN(
18621 wmi_vdev_limit_offchan_cmd_fixed_param));
18622
18623 cmd->vdev_id = limit_off_chan_param->vdev_id;
18624
18625 cmd->flags &= 0;
18626 if (limit_off_chan_param->status)
18627 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
18628 if (limit_off_chan_param->skip_dfs_chans)
18629 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
18630
18631 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
18632 cmd->rest_time = limit_off_chan_param->rest_time;
18633
18634 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
18635 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
18636 cmd->rest_time);
18637
18638 err = wmi_unified_cmd_send(wmi_handle, buf,
18639 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
18640 if (QDF_IS_STATUS_ERROR(err)) {
18641 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
18642 wmi_buf_free(buf);
18643 return QDF_STATUS_E_FAILURE;
18644 }
18645
18646 return QDF_STATUS_SUCCESS;
18647}
18648
Govind Singh5eb51532016-03-09 11:34:12 +053018649struct wmi_ops tlv_ops = {
18650 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18651 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18652 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018653 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18654 .send_hidden_ssid_vdev_restart_cmd =
18655 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018656 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18657 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18658 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018659 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018660 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018661 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018662 .send_peer_rx_reorder_queue_setup_cmd =
18663 send_peer_rx_reorder_queue_setup_cmd_tlv,
18664 .send_peer_rx_reorder_queue_remove_cmd =
18665 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018666 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18667 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18668 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018669 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18670 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18671 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18672 .send_suspend_cmd = send_suspend_cmd_tlv,
18673 .send_resume_cmd = send_resume_cmd_tlv,
18674 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18675 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18676 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18677 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18678 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18679 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18680 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18681 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070018682 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018683 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018684 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018685 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18686 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18687 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18688 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018689 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018690 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018691 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18692 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018693 .send_set_sta_uapsd_auto_trig_cmd =
18694 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018695 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18696 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18697 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018698#ifdef CONVERGED_P2P_ENABLE
18699 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18700 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18701#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018702 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18703 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018704 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18705 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18706 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18707 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18708 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18709 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18710 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018711 .send_ocb_start_timing_advert_cmd =
18712 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018713 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18714 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18715 .send_set_mcc_channel_time_latency_cmd =
18716 send_set_mcc_channel_time_latency_cmd_tlv,
18717 .send_set_mcc_channel_time_quota_cmd =
18718 send_set_mcc_channel_time_quota_cmd_tlv,
18719 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18720 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018721 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018722 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18723 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18724 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018725 .send_probe_rsp_tmpl_send_cmd =
18726 send_probe_rsp_tmpl_send_cmd_tlv,
18727 .send_p2p_go_set_beacon_ie_cmd =
18728 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018729 .send_setup_install_key_cmd =
18730 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018731 .send_set_gateway_params_cmd =
18732 send_set_gateway_params_cmd_tlv,
18733 .send_set_rssi_monitoring_cmd =
18734 send_set_rssi_monitoring_cmd_tlv,
18735 .send_scan_probe_setoui_cmd =
18736 send_scan_probe_setoui_cmd_tlv,
18737 .send_reset_passpoint_network_list_cmd =
18738 send_reset_passpoint_network_list_cmd_tlv,
18739 .send_set_passpoint_network_list_cmd =
18740 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018741 .send_roam_scan_offload_rssi_thresh_cmd =
18742 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070018743 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018744 .send_roam_scan_filter_cmd =
18745 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018746 .send_set_epno_network_list_cmd =
18747 send_set_epno_network_list_cmd_tlv,
18748 .send_ipa_offload_control_cmd =
18749 send_ipa_offload_control_cmd_tlv,
18750 .send_extscan_get_capabilities_cmd =
18751 send_extscan_get_capabilities_cmd_tlv,
18752 .send_extscan_get_cached_results_cmd =
18753 send_extscan_get_cached_results_cmd_tlv,
18754 .send_extscan_stop_change_monitor_cmd =
18755 send_extscan_stop_change_monitor_cmd_tlv,
18756 .send_extscan_start_change_monitor_cmd =
18757 send_extscan_start_change_monitor_cmd_tlv,
18758 .send_extscan_stop_hotlist_monitor_cmd =
18759 send_extscan_stop_hotlist_monitor_cmd_tlv,
18760 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18761 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18762 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18763 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18764 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18765 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070018766 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018767 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18768 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18769 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18770 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18771 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018772 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018773 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18774 .send_snr_cmd = send_snr_cmd_tlv,
18775 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018776#ifdef WLAN_PMO_ENABLE
18777 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18778 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18779 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18780 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018781 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018782 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18783 .send_process_gtk_offload_getinfo_cmd =
18784 send_process_gtk_offload_getinfo_cmd_tlv,
18785 .send_enable_enhance_multicast_offload_cmd =
18786 send_enable_enhance_multicast_offload_tlv,
18787 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18788#ifdef FEATURE_WLAN_RA_FILTERING
18789 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18790#endif
18791 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018792 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18793 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018794 .send_lphb_config_tcp_pkt_filter_cmd =
18795 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018796 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18797 .send_lphb_config_udp_pkt_filter_cmd =
18798 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018799 .send_enable_disable_packet_filter_cmd =
18800 send_enable_disable_packet_filter_cmd_tlv,
18801 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018802#endif /* End of WLAN_PMO_ENABLE */
18803#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018804 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18805 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18806 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018807 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
18808 .send_process_update_edca_param_cmd =
18809 send_process_update_edca_param_cmd_tlv,
18810 .send_roam_scan_offload_mode_cmd =
18811 send_roam_scan_offload_mode_cmd_tlv,
18812 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18813 .send_roam_scan_offload_ap_profile_cmd =
18814 send_roam_scan_offload_ap_profile_cmd_tlv,
18815#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018816 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18817 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018818 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18819 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018820#ifdef WLAN_FEATURE_CIF_CFR
18821 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18822#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018823 .send_dfs_phyerr_filter_offload_en_cmd =
18824 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018825 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18826 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18827 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18828 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18829 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018830 .send_process_add_periodic_tx_ptrn_cmd =
18831 send_process_add_periodic_tx_ptrn_cmd_tlv,
18832 .send_process_del_periodic_tx_ptrn_cmd =
18833 send_process_del_periodic_tx_ptrn_cmd_tlv,
18834 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18835 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18836 .send_set_app_type2_params_in_fw_cmd =
18837 send_set_app_type2_params_in_fw_cmd_tlv,
18838 .send_set_auto_shutdown_timer_cmd =
18839 send_set_auto_shutdown_timer_cmd_tlv,
18840 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18841 .send_process_dhcpserver_offload_cmd =
18842 send_process_dhcpserver_offload_cmd_tlv,
18843 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18844 .send_process_ch_avoid_update_cmd =
18845 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018846 .send_pdev_set_regdomain_cmd =
18847 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018848 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18849 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18850 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18851 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18852 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18853 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018854#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018855 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018856#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018857 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018858 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018859 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018860 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018861 .send_set_base_macaddr_indicate_cmd =
18862 send_set_base_macaddr_indicate_cmd_tlv,
18863 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18864 .send_enable_specific_fw_logs_cmd =
18865 send_enable_specific_fw_logs_cmd_tlv,
18866 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018867 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018868 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018869 .send_pdev_set_dual_mac_config_cmd =
18870 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018871 .send_app_type1_params_in_fw_cmd =
18872 send_app_type1_params_in_fw_cmd_tlv,
18873 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18874 .send_process_roam_synch_complete_cmd =
18875 send_process_roam_synch_complete_cmd_tlv,
18876 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18877 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18878 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018879 .send_roam_scan_offload_scan_period_cmd =
18880 send_roam_scan_offload_scan_period_cmd_tlv,
18881 .send_roam_scan_offload_chan_list_cmd =
18882 send_roam_scan_offload_chan_list_cmd_tlv,
18883 .send_roam_scan_offload_rssi_change_cmd =
18884 send_roam_scan_offload_rssi_change_cmd_tlv,
18885 .send_get_buf_extscan_hotlist_cmd =
18886 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018887 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018888 .send_adapt_dwelltime_params_cmd =
18889 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018890 .send_dbs_scan_sel_params_cmd =
18891 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018892 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018893 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18894 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18895 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18896 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18897 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18898 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18899 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18900 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18901 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018902 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18903 .send_smart_ant_set_training_info_cmd =
18904 send_smart_ant_set_training_info_cmd_tlv,
18905 .send_smart_ant_set_node_config_cmd =
18906 send_smart_ant_set_node_config_cmd_tlv,
18907 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18908 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18909 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018910 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18911 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18912 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18913 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18914 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18915 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18916 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018917 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18918 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18919 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18920 .send_vdev_spectral_configure_cmd =
18921 send_vdev_spectral_configure_cmd_tlv,
18922 .send_vdev_spectral_enable_cmd =
18923 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018924 .send_thermal_mitigation_param_cmd =
18925 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018926 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18927 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018928 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018929 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018930 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18931 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18932 .extract_host_mem_req = extract_host_mem_req_tlv,
18933 .save_service_bitmap = save_service_bitmap_tlv,
18934 .is_service_enabled = is_service_enabled_tlv,
18935 .save_fw_version = save_fw_version_in_service_ready_tlv,
18936 .ready_extract_init_status = ready_extract_init_status_tlv,
18937 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
18938 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18939 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18940 .extract_tbttoffset_update_params =
18941 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018942 .extract_ext_tbttoffset_update_params =
18943 extract_ext_tbttoffset_update_params_tlv,
18944 .extract_tbttoffset_num_vdevs =
18945 extract_tbttoffset_num_vdevs_tlv,
18946 .extract_ext_tbttoffset_num_vdevs =
18947 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018948 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18949 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18950 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18951 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018952#ifdef CONVERGED_TDLS_ENABLE
18953 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18954#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018955 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018956 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018957 .extract_swba_tim_info = extract_swba_tim_info_tlv,
18958 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018959#ifdef CONVERGED_P2P_ENABLE
18960 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
18961 .extract_p2p_lo_stop_ev_param =
18962 extract_p2p_lo_stop_ev_param_tlv,
18963#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018964 .extract_offchan_data_tx_compl_param =
18965 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018966 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
18967 .extract_all_stats_count = extract_all_stats_counts_tlv,
18968 .extract_pdev_stats = extract_pdev_stats_tlv,
18969 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
18970 .extract_vdev_stats = extract_vdev_stats_tlv,
18971 .extract_peer_stats = extract_peer_stats_tlv,
18972 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
18973 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
18974 .extract_chan_stats = extract_chan_stats_tlv,
18975 .extract_profile_ctx = extract_profile_ctx_tlv,
18976 .extract_profile_data = extract_profile_data_tlv,
18977 .extract_chan_info_event = extract_chan_info_event_tlv,
18978 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053018979 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053018980 .send_encrypt_decrypt_send_cmd =
18981 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080018982 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053018983 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018984 .send_multiple_vdev_restart_req_cmd =
18985 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053018986 .extract_service_ready_ext = extract_service_ready_ext_tlv,
18987 .extract_hw_mode_cap_service_ready_ext =
18988 extract_hw_mode_cap_service_ready_ext_tlv,
18989 .extract_mac_phy_cap_service_ready_ext =
18990 extract_mac_phy_cap_service_ready_ext_tlv,
18991 .extract_reg_cap_service_ready_ext =
18992 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018993 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053018994 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018995 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
18996 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
18997 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053018998 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018999 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019000 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053019001 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019002 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053019003 .extract_pdev_csa_switch_count_status =
19004 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053019005 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
19006 .extract_wds_addr_event = extract_wds_addr_event_tlv,
19007 .extract_peer_sta_ps_statechange_ev =
19008 extract_peer_sta_ps_statechange_ev_tlv,
19009 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053019010 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080019011 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
19012 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019013 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019014 extract_reg_chan_list_update_event_tlv,
19015 .extract_chainmask_tables =
19016 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019017 .extract_thermal_stats = extract_thermal_stats_tlv,
19018 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019019#ifdef DFS_COMPONENT_ENABLE
19020 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
19021 .extract_dfs_radar_detection_event =
19022 extract_dfs_radar_detection_event_tlv,
19023#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019024 .convert_pdev_id_host_to_target =
19025 convert_host_pdev_id_to_target_pdev_id_legacy,
19026 .convert_pdev_id_target_to_host =
19027 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070019028
19029 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
19030 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
19031 .extract_reg_11d_new_country_event =
19032 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053019033 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053019034 .send_limit_off_chan_cmd =
19035 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070019036 .extract_reg_ch_avoid_event =
19037 extract_reg_ch_avoid_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053019038};
19039
Govind Singhe7f2f342016-05-23 12:12:52 +053019040/**
19041 * populate_tlv_event_id() - populates wmi event ids
19042 *
19043 * @param event_ids: Pointer to hold event ids
19044 * Return: None
19045 */
19046static void populate_tlv_events_id(uint32_t *event_ids)
19047{
19048 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
19049 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
19050 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
19051 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
19052 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
19053 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
19054 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
19055 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
19056 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
19057 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
19058 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
19059 event_ids[wmi_service_ready_ext_event_id] =
19060 WMI_SERVICE_READY_EXT_EVENTID;
19061 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
19062 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
19063 event_ids[wmi_vdev_install_key_complete_event_id] =
19064 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
19065 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
19066 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
19067
19068 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
19069 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
19070 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
19071 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
19072 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
19073 event_ids[wmi_peer_estimated_linkspeed_event_id] =
19074 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
19075 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019076 event_ids[wmi_peer_delete_response_event_id] =
19077 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019078 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
19079 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
19080 event_ids[wmi_tbttoffset_update_event_id] =
19081 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019082 event_ids[wmi_ext_tbttoffset_update_event_id] =
19083 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019084 event_ids[wmi_offload_bcn_tx_status_event_id] =
19085 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
19086 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
19087 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
19088 event_ids[wmi_mgmt_tx_completion_event_id] =
19089 WMI_MGMT_TX_COMPLETION_EVENTID;
19090
19091 event_ids[wmi_tx_delba_complete_event_id] =
19092 WMI_TX_DELBA_COMPLETE_EVENTID;
19093 event_ids[wmi_tx_addba_complete_event_id] =
19094 WMI_TX_ADDBA_COMPLETE_EVENTID;
19095 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
19096
19097 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
19098
19099 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
19100 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
19101
19102 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
19103
19104 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
19105
19106 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080019107 event_ids[wmi_p2p_lo_stop_event_id] =
19108 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019109 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
19110 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
19111 event_ids[wmi_do_wow_disable_ack_event_id] =
19112 WMI_D0_WOW_DISABLE_ACK_EVENTID;
19113 event_ids[wmi_wow_initial_wakeup_event_id] =
19114 WMI_WOW_INITIAL_WAKEUP_EVENTID;
19115
19116 event_ids[wmi_rtt_meas_report_event_id] =
19117 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
19118 event_ids[wmi_tsf_meas_report_event_id] =
19119 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
19120 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
19121 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
19122 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
19123 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
19124 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
19125 event_ids[wmi_update_fw_mem_dump_event_id] =
19126 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
19127 event_ids[wmi_diag_event_id_log_supported_event_id] =
19128 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
19129 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
19130 event_ids[wmi_nlo_scan_complete_event_id] =
19131 WMI_NLO_SCAN_COMPLETE_EVENTID;
19132 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
19133 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
19134
19135 event_ids[wmi_gtk_offload_status_event_id] =
19136 WMI_GTK_OFFLOAD_STATUS_EVENTID;
19137 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
19138 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
19139 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
19140
19141 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
19142
19143 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
19144
19145 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
19146 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
19147 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
19148 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
19149 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
19150 event_ids[wmi_wlan_profile_data_event_id] =
19151 WMI_WLAN_PROFILE_DATA_EVENTID;
19152 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
19153 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
19154 event_ids[wmi_vdev_get_keepalive_event_id] =
19155 WMI_VDEV_GET_KEEPALIVE_EVENTID;
19156 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
19157
19158 event_ids[wmi_diag_container_event_id] =
19159 WMI_DIAG_DATA_CONTAINER_EVENTID;
19160
19161 event_ids[wmi_host_auto_shutdown_event_id] =
19162 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
19163
19164 event_ids[wmi_update_whal_mib_stats_event_id] =
19165 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
19166
19167 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
19168 event_ids[wmi_update_vdev_rate_stats_event_id] =
19169 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
19170
19171 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
19172
19173 /** Set OCB Sched Response, deprecated */
19174 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
19175
19176 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
19177 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
19178 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
19179
19180 /* GPIO Event */
19181 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
19182 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
19183
19184 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
19185 event_ids[wmi_rfkill_state_change_event_id] =
19186 WMI_RFKILL_STATE_CHANGE_EVENTID;
19187
19188 /* TDLS Event */
19189 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
19190
19191 event_ids[wmi_batch_scan_enabled_event_id] =
19192 WMI_BATCH_SCAN_ENABLED_EVENTID;
19193 event_ids[wmi_batch_scan_result_event_id] =
19194 WMI_BATCH_SCAN_RESULT_EVENTID;
19195 /* OEM Event */
19196 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
19197 event_ids[wmi_oem_meas_report_event_id] =
19198 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
19199 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
19200
19201 /* NAN Event */
19202 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
19203
19204 /* LPI Event */
19205 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
19206 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
19207 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
19208
19209 /* ExtScan events */
19210 event_ids[wmi_extscan_start_stop_event_id] =
19211 WMI_EXTSCAN_START_STOP_EVENTID;
19212 event_ids[wmi_extscan_operation_event_id] =
19213 WMI_EXTSCAN_OPERATION_EVENTID;
19214 event_ids[wmi_extscan_table_usage_event_id] =
19215 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
19216 event_ids[wmi_extscan_cached_results_event_id] =
19217 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
19218 event_ids[wmi_extscan_wlan_change_results_event_id] =
19219 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
19220 event_ids[wmi_extscan_hotlist_match_event_id] =
19221 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
19222 event_ids[wmi_extscan_capabilities_event_id] =
19223 WMI_EXTSCAN_CAPABILITIES_EVENTID;
19224 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
19225 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
19226
19227 /* mDNS offload events */
19228 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
19229
19230 /* SAP Authentication offload events */
19231 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
19232 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
19233
19234 /** Out-of-context-of-bss (OCB) events */
19235 event_ids[wmi_ocb_set_config_resp_event_id] =
19236 WMI_OCB_SET_CONFIG_RESP_EVENTID;
19237 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
19238 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
19239 event_ids[wmi_dcc_get_stats_resp_event_id] =
19240 WMI_DCC_GET_STATS_RESP_EVENTID;
19241 event_ids[wmi_dcc_update_ndl_resp_event_id] =
19242 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
19243 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
19244 /* System-On-Chip events */
19245 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
19246 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
19247 event_ids[wmi_soc_hw_mode_transition_event_id] =
19248 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
19249 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
19250 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053019251 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053019252 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
19253 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019254 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053019255 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
19256 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
19257 event_ids[wmi_peer_sta_ps_statechg_event_id] =
19258 WMI_PEER_STA_PS_STATECHG_EVENTID;
19259 event_ids[wmi_pdev_channel_hopping_event_id] =
19260 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053019261 event_ids[wmi_offchan_data_tx_completion_event] =
19262 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019263 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
19264 event_ids[wmi_dfs_radar_detection_event_id] =
19265 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019266 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070019267 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019268}
19269
Soumya Bhat488092d2017-03-22 14:41:01 +053019270#ifndef CONFIG_MCL
19271/**
19272 * populate_tlv_service() - populates wmi services
19273 *
19274 * @param wmi_service: Pointer to hold wmi_service
19275 * Return: None
19276 */
19277static void populate_tlv_service(uint32_t *wmi_service)
19278{
19279 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
19280 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
19281 wmi_service[wmi_service_roam_scan_offload] =
19282 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
19283 wmi_service[wmi_service_bcn_miss_offload] =
19284 WMI_SERVICE_BCN_MISS_OFFLOAD;
19285 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
19286 wmi_service[wmi_service_sta_advanced_pwrsave] =
19287 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
19288 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
19289 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
19290 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
19291 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
19292 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
19293 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
19294 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
19295 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
19296 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
19297 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
19298 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
19299 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
19300 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
19301 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
19302 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
19303 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
19304 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
19305 wmi_service[wmi_service_packet_power_save] =
19306 WMI_SERVICE_PACKET_POWER_SAVE;
19307 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
19308 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
19309 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
19310 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
19311 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
19312 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
19313 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
19314 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
19315 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
19316 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
19317 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
19318 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
19319 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
19320 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
19321 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
19322 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
19323 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
19324 wmi_service[wmi_service_mcc_bcn_interval_change] =
19325 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
19326 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
19327 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
19328 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
19329 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
19330 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
19331 wmi_service[wmi_service_lte_ant_share_support] =
19332 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
19333 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
19334 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
19335 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
19336 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
19337 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
19338 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
19339 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
19340 wmi_service[wmi_service_bcn_txrate_override] =
19341 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
19342 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
19343 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
19344 wmi_service[wmi_service_estimate_linkspeed] =
19345 WMI_SERVICE_ESTIMATE_LINKSPEED;
19346 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
19347 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
19348 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
19349 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
19350 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
19351 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
19352 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
19353 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
19354 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
19355 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
19356 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
19357 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
19358 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
19359 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
19360 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
19361 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
19362 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
19363 wmi_service[wmi_service_sap_auth_offload] =
19364 WMI_SERVICE_SAP_AUTH_OFFLOAD;
19365 wmi_service[wmi_service_dual_band_simultaneous_support] =
19366 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
19367 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
19368 wmi_service[wmi_service_ap_arpns_offload] =
19369 WMI_SERVICE_AP_ARPNS_OFFLOAD;
19370 wmi_service[wmi_service_per_band_chainmask_support] =
19371 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
19372 wmi_service[wmi_service_packet_filter_offload] =
19373 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
19374 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
19375 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
19376 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
19377 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
19378 wmi_service[wmi_service_multiple_vdev_restart] =
19379 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
19380
19381 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
19382 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
19383 wmi_service[wmi_service_smart_antenna_sw_support] =
19384 WMI_SERVICE_UNAVAILABLE;
19385 wmi_service[wmi_service_smart_antenna_hw_support] =
19386 WMI_SERVICE_UNAVAILABLE;
19387 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
19388 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019389 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053019390 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
19391 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
19392 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
19393 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
19394 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
19395 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
19396 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
19397 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053019398 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
19399 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
19400 wmi_service[wmi_service_periodic_chan_stat_support] =
19401 WMI_SERVICE_UNAVAILABLE;
19402 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
19403 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
19404 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
19405 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
19406 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
19407 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053019408 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
19409 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
19410 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
19411 wmi_service[wmi_service_unified_wow_capability] =
19412 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
19413 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
19414 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
19415 wmi_service[wmi_service_sync_delete_cmds] =
19416 WMI_SERVICE_SYNC_DELETE_CMDS;
19417 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
19418 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
19419 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
19420 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
19421 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
19422 wmi_service[wmi_service_deprecated_replace] =
19423 WMI_SERVICE_DEPRECATED_REPLACE;
19424 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
19425 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
19426 wmi_service[wmi_service_enhanced_mcast_filter] =
19427 WMI_SERVICE_ENHANCED_MCAST_FILTER;
19428 wmi_service[wmi_service_half_rate_quarter_rate_support] =
19429 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
19430 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
19431 wmi_service[wmi_service_p2p_listen_offload_support] =
19432 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
19433 wmi_service[wmi_service_mark_first_wakeup_packet] =
19434 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
19435 wmi_service[wmi_service_multiple_mcast_filter_set] =
19436 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
19437 wmi_service[wmi_service_host_managed_rx_reorder] =
19438 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
19439 wmi_service[wmi_service_flash_rdwr_support] =
19440 WMI_SERVICE_FLASH_RDWR_SUPPORT;
19441 wmi_service[wmi_service_wlan_stats_report] =
19442 WMI_SERVICE_WLAN_STATS_REPORT;
19443 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
19444 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
19445 wmi_service[wmi_service_dfs_phyerr_offload] =
19446 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
19447 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
19448 wmi_service[wmi_service_fw_mem_dump_support] =
19449 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
19450 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
19451 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
19452 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
19453 wmi_service[wmi_service_hw_data_filtering] =
19454 WMI_SERVICE_HW_DATA_FILTERING;
19455 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
19456 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053019457 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat488092d2017-03-22 14:41:01 +053019458}
19459
Govind Singhe7f2f342016-05-23 12:12:52 +053019460/**
19461 * populate_pdev_param_tlv() - populates pdev params
19462 *
19463 * @param pdev_param: Pointer to hold pdev params
19464 * Return: None
19465 */
19466static void populate_pdev_param_tlv(uint32_t *pdev_param)
19467{
19468 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
19469 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
19470 pdev_param[wmi_pdev_param_txpower_limit2g] =
19471 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
19472 pdev_param[wmi_pdev_param_txpower_limit5g] =
19473 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
19474 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
19475 pdev_param[wmi_pdev_param_beacon_gen_mode] =
19476 WMI_PDEV_PARAM_BEACON_GEN_MODE;
19477 pdev_param[wmi_pdev_param_beacon_tx_mode] =
19478 WMI_PDEV_PARAM_BEACON_TX_MODE;
19479 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
19480 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
19481 pdev_param[wmi_pdev_param_protection_mode] =
19482 WMI_PDEV_PARAM_PROTECTION_MODE;
19483 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
19484 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
19485 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
19486 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
19487 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
19488 pdev_param[wmi_pdev_param_sta_kickout_th] =
19489 WMI_PDEV_PARAM_STA_KICKOUT_TH;
19490 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
19491 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
19492 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
19493 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
19494 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
19495 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
19496 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
19497 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
19498 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
19499 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
19500 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
19501 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
19502 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
19503 pdev_param[wmi_pdev_param_ltr_sleep_override] =
19504 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
19505 pdev_param[wmi_pdev_param_ltr_rx_override] =
19506 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
19507 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
19508 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
19509 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
19510 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
19511 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
19512 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
19513 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
19514 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
19515 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
19516 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
19517 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
19518 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
19519 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
19520 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
19521 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
19522 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
19523 pdev_param[wmi_pdev_param_peer_stats_update_period] =
19524 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
19525 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
19526 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
19527 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
19528 pdev_param[wmi_pdev_param_arp_ac_override] =
19529 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
19530 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
19531 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
19532 pdev_param[wmi_pdev_param_ani_poll_period] =
19533 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
19534 pdev_param[wmi_pdev_param_ani_listen_period] =
19535 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
19536 pdev_param[wmi_pdev_param_ani_ofdm_level] =
19537 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
19538 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
19539 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
19540 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
19541 pdev_param[wmi_pdev_param_idle_ps_config] =
19542 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
19543 pdev_param[wmi_pdev_param_power_gating_sleep] =
19544 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
19545 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
19546 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
19547 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
19548 pdev_param[wmi_pdev_param_hw_rfkill_config] =
19549 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
19550 pdev_param[wmi_pdev_param_low_power_rf_enable] =
19551 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
19552 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
19553 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
19554 pdev_param[wmi_pdev_param_power_collapse_enable] =
19555 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
19556 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
19557 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
19558 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
19559 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
19560 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
19561 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
19562 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
19563 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
19564 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
19565 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
19566 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
19567 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
19568 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
19569 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
19570 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
19571 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
19572 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
19573 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
19574 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
19575 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
19576 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
19577 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
19578 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
19579 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
19580 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
19581 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
19582 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
19583 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
19584 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
19585 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
19586 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
19587 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
19588 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
19589 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
19590 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
19591 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
19592 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
19593 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
19594 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
19595 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
19596 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
19597 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
19598 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
19599 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
19600 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
19601 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumard99852a2017-07-08 12:32:27 +053019602 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
19603 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053019604 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
19605 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
19606 WMI_UNAVAILABLE_PARAM;
19607 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
19608 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
19609 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
19610 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
19611 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
19612 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019613 pdev_param[wmi_pdev_param_atf_strict_sch] =
19614 WMI_PDEV_PARAM_ATF_STRICT_SCH;
19615 pdev_param[wmi_pdev_param_atf_sched_duration] =
19616 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053019617 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
19618 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
19619 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
19620 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070019621 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
19622 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
19623 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
19624 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Govind Singhe7f2f342016-05-23 12:12:52 +053019625 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
19626 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
19627 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
19628 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
19629 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
19630 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
19631 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
19632 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
19633 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
19634 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019635 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
19636 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053019637 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019638 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053019639 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019640 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
19641 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019642 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
19643 WMI_UNAVAILABLE_PARAM;
19644 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
19645 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
19646 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
19647 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
19648 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
19649 WMI_UNAVAILABLE_PARAM;
19650 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
19651 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
19652 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019653 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19654 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019655 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019656 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19657 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019658 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19659 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19660 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19661 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19662 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19663 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19664 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19665 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19666 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19667 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19668 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19669 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19670 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19671 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19672 pdev_param[wmi_pdev_param_fast_channel_reset] =
19673 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19674 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019675}
19676
19677/**
19678 * populate_vdev_param_tlv() - populates vdev params
19679 *
19680 * @param vdev_param: Pointer to hold vdev params
19681 * Return: None
19682 */
19683static void populate_vdev_param_tlv(uint32_t *vdev_param)
19684{
19685 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19686 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19687 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19688 vdev_param[wmi_vdev_param_beacon_interval] =
19689 WMI_VDEV_PARAM_BEACON_INTERVAL;
19690 vdev_param[wmi_vdev_param_listen_interval] =
19691 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19692 vdev_param[wmi_vdev_param_multicast_rate] =
19693 WMI_VDEV_PARAM_MULTICAST_RATE;
19694 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19695 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19696 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19697 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19698 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19699 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19700 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19701 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19702 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19703 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19704 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19705 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19706 vdev_param[wmi_vdev_param_bmiss_count_max] =
19707 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19708 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19709 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19710 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19711 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19712 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19713 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19714 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19715 vdev_param[wmi_vdev_param_disable_htprotection] =
19716 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19717 vdev_param[wmi_vdev_param_sta_quickkickout] =
19718 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19719 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19720 vdev_param[wmi_vdev_param_protection_mode] =
19721 WMI_VDEV_PARAM_PROTECTION_MODE;
19722 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19723 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19724 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19725 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19726 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19727 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19728 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19729 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19730 vdev_param[wmi_vdev_param_bcast_data_rate] =
19731 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19732 vdev_param[wmi_vdev_param_mcast_data_rate] =
19733 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19734 vdev_param[wmi_vdev_param_mcast_indicate] =
19735 WMI_VDEV_PARAM_MCAST_INDICATE;
19736 vdev_param[wmi_vdev_param_dhcp_indicate] =
19737 WMI_VDEV_PARAM_DHCP_INDICATE;
19738 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19739 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19740 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19741 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19742 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19743 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19744 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19745 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19746 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19747 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19748 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19749 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19750 vdev_param[wmi_vdev_param_packet_powersave] =
19751 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19752 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19753 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19754 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19755 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19756 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19757 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19758 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19759 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19760 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19761 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19762 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19763 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19764 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19765 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19766 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19767 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19768 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19769 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19770 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19771 vdev_param[wmi_vdev_param_roam_fw_offload] =
19772 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19773 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19774 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19775 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19776 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19777 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19778 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19779 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19780 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19781 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19782 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19783 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19784 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19785 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19786 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19787 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19788 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19789 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19790 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19791 vdev_param[wmi_vdev_param_inactivity_cnt] =
19792 WMI_VDEV_PARAM_INACTIVITY_CNT;
19793 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19794 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19795 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19796 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19797 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19798 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19799 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19800 vdev_param[wmi_vdev_param_rx_leak_window] =
19801 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19802 vdev_param[wmi_vdev_param_stats_avg_factor] =
19803 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19804 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19805 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19806 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19807 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19808 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19809 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019810 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19811 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019812 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019813 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19814 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19815 WMI_VDEV_PARAM_HE_RANGE_EXT;
19816 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19817 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019818 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19819 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19820 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19821 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19822 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19823 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19824 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019825 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19826 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19827 vdev_param[wmi_vdev_param_rc_num_retries] =
19828 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19829 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19830 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19831 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19832 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19833 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19834 vdev_param[wmi_vdev_param_vht80_ratemask] =
19835 WMI_VDEV_PARAM_VHT80_RATEMASK;
19836 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19837 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19838 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019839}
19840#endif
19841
Govind Singh5eb51532016-03-09 11:34:12 +053019842/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019843 * populate_target_defines_tlv() - Populate target defines and params
19844 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019845 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019846 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019847 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019848#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019849static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019850{
Govind Singhe7f2f342016-05-23 12:12:52 +053019851 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019852 populate_pdev_param_tlv(wmi_handle->pdev_param);
19853 populate_vdev_param_tlv(wmi_handle->vdev_param);
19854}
19855#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019856static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19857{ }
19858#endif
19859
19860/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019861 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19862 * host to target defines.
19863 * @param pdev_id: host pdev_id to be converted.
19864 * Return: target pdev_id after conversion.
19865 */
19866static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19867{
19868 switch (pdev_id) {
19869 case WMI_HOST_PDEV_ID_SOC:
19870 return WMI_PDEV_ID_SOC;
19871 case WMI_HOST_PDEV_ID_0:
19872 return WMI_PDEV_ID_1ST;
19873 case WMI_HOST_PDEV_ID_1:
19874 return WMI_PDEV_ID_2ND;
19875 case WMI_HOST_PDEV_ID_2:
19876 return WMI_PDEV_ID_3RD;
19877 }
19878
19879 QDF_ASSERT(0);
19880
19881 return WMI_PDEV_ID_SOC;
19882}
19883
19884/**
19885 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19886 * target to host defines.
19887 * @param pdev_id: target pdev_id to be converted.
19888 * Return: host pdev_id after conversion.
19889 */
19890static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19891{
19892 switch (pdev_id) {
19893 case WMI_PDEV_ID_SOC:
19894 return WMI_HOST_PDEV_ID_SOC;
19895 case WMI_PDEV_ID_1ST:
19896 return WMI_HOST_PDEV_ID_0;
19897 case WMI_PDEV_ID_2ND:
19898 return WMI_HOST_PDEV_ID_1;
19899 case WMI_PDEV_ID_3RD:
19900 return WMI_HOST_PDEV_ID_2;
19901 }
19902
19903 QDF_ASSERT(0);
19904
19905 return WMI_HOST_PDEV_ID_SOC;
19906}
19907
19908/**
19909 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19910 *
19911 * Return None.
19912 */
19913void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19914{
19915 wmi_handle->ops->convert_pdev_id_host_to_target =
19916 convert_host_pdev_id_to_target_pdev_id;
19917 wmi_handle->ops->convert_pdev_id_target_to_host =
19918 convert_target_pdev_id_to_host_pdev_id;
19919}
19920/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019921 * wmi_tlv_attach() - Attach TLV APIs
19922 *
19923 * Return: None
19924 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019925void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019926{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019927 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019928#ifdef WMI_INTERFACE_EVENT_LOGGING
19929 wmi_handle->log_info.buf_offset_command = 2;
19930 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019931#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019932 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019933 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019934}