blob: cd57476506751565816432808864452033aa593e [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
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530367 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 cmd->preferred_rx_streams = req->preferred_rx_streams;
369 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700370 cmd->cac_duration_ms = req->cac_duration_ms;
371 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700372 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530373
374 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
375 sizeof(wmi_channel));
376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
377 cmd->num_noa_descriptors *
378 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800379 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
381 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700382 "Tx SS %d, Rx SS %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800383 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530384 req->is_dfs, req->beacon_intval, cmd->dtim_period,
385 chan->band_center_freq1, chan->band_center_freq2,
386 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700387 req->preferred_tx_streams, req->preferred_rx_streams,
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700388 req->cac_duration_ms, req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530390 if (req->is_restart)
391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
392 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530393 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
395 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530396 if (ret) {
397 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530398 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530399 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530400 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401
402 return QDF_STATUS_SUCCESS;
403}
404
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530405/**
406 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
407 * @wmi_handle: wmi handle
408 * @restart_params: vdev restart params
409 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530410 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530411 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530412static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 struct hidden_ssid_vdev_restart_params *restart_params)
414{
415 wmi_vdev_start_request_cmd_fixed_param *cmd;
416 wmi_buf_t buf;
417 wmi_channel *chan;
418 int32_t len;
419 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530420 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421
422 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
423 buf = wmi_buf_alloc(wmi_handle, len);
424 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530425 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 return QDF_STATUS_E_NOMEM;
427 }
428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
429 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
430 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
431
432 WMITLV_SET_HDR(&cmd->tlv_header,
433 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
434 WMITLV_GET_STRUCT_TLVLEN
435 (wmi_vdev_start_request_cmd_fixed_param));
436
437 WMITLV_SET_HDR(&chan->tlv_header,
438 WMITLV_TAG_STRUC_wmi_channel,
439 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
440
441 cmd->vdev_id = restart_params->session_id;
442 cmd->ssid.ssid_len = restart_params->ssid_len;
443 qdf_mem_copy(cmd->ssid.ssid,
444 restart_params->ssid,
445 cmd->ssid.ssid_len);
446 cmd->flags = restart_params->flags;
447 cmd->requestor_id = restart_params->requestor_id;
448 cmd->disable_hw_ack = restart_params->disable_hw_ack;
449
450 chan->mhz = restart_params->mhz;
451 chan->band_center_freq1 =
452 restart_params->band_center_freq1;
453 chan->band_center_freq2 =
454 restart_params->band_center_freq2;
455 chan->info = restart_params->info;
456 chan->reg_info_1 = restart_params->reg_info_1;
457 chan->reg_info_2 = restart_params->reg_info_2;
458
459 cmd->num_noa_descriptors = 0;
460 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
461 sizeof(wmi_channel));
462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
463 cmd->num_noa_descriptors *
464 sizeof(wmi_p2p_noa_descriptor));
465
466 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
467 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530468 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530469 wmi_buf_free(buf);
470 return QDF_STATUS_E_FAILURE;
471 }
472 return QDF_STATUS_SUCCESS;
473}
474
475
476/**
Govind Singh5eb51532016-03-09 11:34:12 +0530477 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
478 * @wmi: wmi handle
479 * @peer_addr: peer mac address
480 * @param: pointer to hold peer flush tid parameter
481 *
482 * Return: 0 for sucess or error code
483 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530484static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530485 uint8_t peer_addr[IEEE80211_ADDR_LEN],
486 struct peer_flush_params *param)
487{
488 wmi_peer_flush_tids_cmd_fixed_param *cmd;
489 wmi_buf_t buf;
490 int32_t len = sizeof(*cmd);
491
492 buf = wmi_buf_alloc(wmi, len);
493 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530494 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530495 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530496 }
497 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
498 WMITLV_SET_HDR(&cmd->tlv_header,
499 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
500 WMITLV_GET_STRUCT_TLVLEN
501 (wmi_peer_flush_tids_cmd_fixed_param));
502 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
503 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
504 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530505 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530506 peer_addr, param->vdev_id,
507 param->peer_tid_bitmap);
508 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530509 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530510 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530511 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530512 }
513
514 return 0;
515}
516
517/**
518 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
519 * @wmi: wmi handle
520 * @peer_addr: peer mac addr
521 * @vdev_id: vdev id
522 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530523 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530524 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530525static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530526 uint8_t peer_addr[IEEE80211_ADDR_LEN],
527 uint8_t vdev_id)
528{
529 wmi_peer_delete_cmd_fixed_param *cmd;
530 wmi_buf_t buf;
531 int32_t len = sizeof(*cmd);
532 buf = wmi_buf_alloc(wmi, len);
533 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530534 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530535 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530536 }
537 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
538 WMITLV_SET_HDR(&cmd->tlv_header,
539 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
540 WMITLV_GET_STRUCT_TLVLEN
541 (wmi_peer_delete_cmd_fixed_param));
542 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
543 cmd->vdev_id = vdev_id;
544
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800545 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530546 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530547 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530548 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530549 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530550 }
Govind Singh5eb51532016-03-09 11:34:12 +0530551
552 return 0;
553}
554
555/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530556 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
557 * to target id.
558 * @targ_paramid: Target parameter id to hold the result.
559 * @peer_param_id: host param id.
560 *
561 * Return: QDF_STATUS_SUCCESS for success
562 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
563 */
564#ifdef CONFIG_MCL
565static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
566 uint32_t *targ_paramid,
567 uint32_t peer_param_id)
568{
569 *targ_paramid = peer_param_id;
570 return QDF_STATUS_SUCCESS;
571}
572#else
573static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
574 uint32_t *targ_paramid,
575 uint32_t peer_param_id)
576{
577 switch (peer_param_id) {
578 case WMI_HOST_PEER_MIMO_PS_STATE:
579 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
580 break;
581 case WMI_HOST_PEER_AMPDU:
582 *targ_paramid = WMI_PEER_AMPDU;
583 break;
584 case WMI_HOST_PEER_AUTHORIZE:
585 *targ_paramid = WMI_PEER_AUTHORIZE;
586 break;
587 case WMI_HOST_PEER_CHWIDTH:
588 *targ_paramid = WMI_PEER_CHWIDTH;
589 break;
590 case WMI_HOST_PEER_NSS:
591 *targ_paramid = WMI_PEER_NSS;
592 break;
593 case WMI_HOST_PEER_USE_4ADDR:
594 *targ_paramid = WMI_PEER_USE_4ADDR;
595 break;
596 case WMI_HOST_PEER_MEMBERSHIP:
597 *targ_paramid = WMI_PEER_MEMBERSHIP;
598 break;
599 case WMI_HOST_PEER_USERPOS:
600 *targ_paramid = WMI_PEER_USERPOS;
601 break;
602 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
603 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
604 break;
605 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
606 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
607 break;
608 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
609 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
610 break;
611 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
612 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
613 break;
614 case WMI_HOST_PEER_PHYMODE:
615 *targ_paramid = WMI_PEER_PHYMODE;
616 break;
617 case WMI_HOST_PEER_USE_FIXED_PWR:
618 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
619 break;
620 case WMI_HOST_PEER_PARAM_FIXED_RATE:
621 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
622 break;
623 case WMI_HOST_PEER_SET_MU_WHITELIST:
624 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
625 break;
626 case WMI_HOST_PEER_SET_MAC_TX_RATE:
627 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
628 break;
629 case WMI_HOST_PEER_SET_MIN_TX_RATE:
630 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
631 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530632 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
633 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
634 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530635 default:
636 return QDF_STATUS_E_NOSUPPORT;
637 }
638
639 return QDF_STATUS_SUCCESS;
640}
641#endif
642/**
Govind Singh5eb51532016-03-09 11:34:12 +0530643 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530644 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530645 * @peer_addr: peer mac address
646 * @param : pointer to hold peer set parameter
647 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530648 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530649 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530650static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530651 uint8_t peer_addr[IEEE80211_ADDR_LEN],
652 struct peer_set_params *param)
653{
654 wmi_peer_set_param_cmd_fixed_param *cmd;
655 wmi_buf_t buf;
656 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530657 uint32_t param_id;
658
659 if (convert_host_peer_id_to_target_id_tlv(&param_id,
660 param->param_id) != QDF_STATUS_SUCCESS)
661 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530662
663 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530665 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530666 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530667 }
668 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
669 WMITLV_SET_HDR(&cmd->tlv_header,
670 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
671 WMITLV_GET_STRUCT_TLVLEN
672 (wmi_peer_set_param_cmd_fixed_param));
673 cmd->vdev_id = param->vdev_id;
674 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530675 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530676 cmd->param_value = param->param_value;
677 err = wmi_unified_cmd_send(wmi, buf,
678 sizeof(wmi_peer_set_param_cmd_fixed_param),
679 WMI_PEER_SET_PARAM_CMDID);
680 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530681 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530682 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530683 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530684 }
685
686 return 0;
687}
688
689/**
690 * send_vdev_up_cmd_tlv() - send vdev up command in fw
691 * @wmi: wmi handle
692 * @bssid: bssid
693 * @vdev_up_params: pointer to hold vdev up parameter
694 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530695 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530696 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530697static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530698 uint8_t bssid[IEEE80211_ADDR_LEN],
699 struct vdev_up_params *params)
700{
701 wmi_vdev_up_cmd_fixed_param *cmd;
702 wmi_buf_t buf;
703 int32_t len = sizeof(*cmd);
704
Govind Singhb53420c2016-03-09 14:32:57 +0530705 WMI_LOGD("%s: VDEV_UP", __func__);
706 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530707 params->vdev_id, params->assoc_id, bssid);
708 buf = wmi_buf_alloc(wmi, len);
709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530710 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530711 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530712 }
713 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
714 WMITLV_SET_HDR(&cmd->tlv_header,
715 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
716 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
717 cmd->vdev_id = params->vdev_id;
718 cmd->vdev_assoc_id = params->assoc_id;
719 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
720 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530721 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530722 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530723 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530724 }
725
726 return 0;
727}
728
729/**
730 * send_peer_create_cmd_tlv() - send peer create command to fw
731 * @wmi: wmi handle
732 * @peer_addr: peer mac address
733 * @peer_type: peer type
734 * @vdev_id: vdev id
735 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530736 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530737 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530738static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530739 struct peer_create_params *param)
740{
741 wmi_peer_create_cmd_fixed_param *cmd;
742 wmi_buf_t buf;
743 int32_t len = sizeof(*cmd);
744
745 buf = wmi_buf_alloc(wmi, len);
746 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530747 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530748 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530749 }
750 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
751 WMITLV_SET_HDR(&cmd->tlv_header,
752 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
753 WMITLV_GET_STRUCT_TLVLEN
754 (wmi_peer_create_cmd_fixed_param));
755 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
756 cmd->peer_type = param->peer_type;
757 cmd->vdev_id = param->vdev_id;
758
759 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530760 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530761 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530762 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530763 }
Govind Singhb53420c2016-03-09 14:32:57 +0530764 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530765 param->vdev_id);
766
767 return 0;
768}
769
770/**
Leo Changeee40872016-09-28 13:43:36 -0700771 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
772 * command to fw
773 * @wmi: wmi handle
774 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
775 *
776 * Return: 0 for success or error code
777 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700778static
Leo Changeee40872016-09-28 13:43:36 -0700779QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
780 struct rx_reorder_queue_setup_params *param)
781{
782 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
783 wmi_buf_t buf;
784 int32_t len = sizeof(*cmd);
785
786 buf = wmi_buf_alloc(wmi, len);
787 if (!buf) {
788 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
789 return QDF_STATUS_E_NOMEM;
790 }
791 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
792 WMITLV_SET_HDR(&cmd->tlv_header,
793 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
794 WMITLV_GET_STRUCT_TLVLEN
795 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
796 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
797 cmd->vdev_id = param->vdev_id;
798 cmd->tid = param->tid;
799 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
800 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
801 cmd->queue_no = param->queue_no;
802
803 if (wmi_unified_cmd_send(wmi, buf, len,
804 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
805 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
806 __func__);
807 qdf_nbuf_free(buf);
808 return QDF_STATUS_E_FAILURE;
809 }
810 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
811 param->peer_macaddr, param->vdev_id, param->tid);
812
813 return QDF_STATUS_SUCCESS;
814}
815
816/**
817 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
818 * command to fw
819 * @wmi: wmi handle
820 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
821 *
822 * Return: 0 for success or error code
823 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700824static
Leo Changeee40872016-09-28 13:43:36 -0700825QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
826 struct rx_reorder_queue_remove_params *param)
827{
828 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
829 wmi_buf_t buf;
830 int32_t len = sizeof(*cmd);
831
832 buf = wmi_buf_alloc(wmi, len);
833 if (!buf) {
834 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
835 return QDF_STATUS_E_NOMEM;
836 }
837 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
838 wmi_buf_data(buf);
839 WMITLV_SET_HDR(&cmd->tlv_header,
840 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
841 WMITLV_GET_STRUCT_TLVLEN
842 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
843 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
844 cmd->vdev_id = param->vdev_id;
845 cmd->tid_mask = param->peer_tid_bitmap;
846
847 if (wmi_unified_cmd_send(wmi, buf, len,
848 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
849 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
850 __func__);
851 qdf_nbuf_free(buf);
852 return QDF_STATUS_E_FAILURE;
853 }
854 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
855 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
856
857 return QDF_STATUS_SUCCESS;
858}
859
860/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530861 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
862 * @wmi_handle: wmi handle
863 * @param: pointer holding peer details
864 *
865 * Return: 0 for success or error code
866 */
867static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
868 struct peer_add_wds_entry_params *param)
869{
870 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
871 wmi_buf_t buf;
872 int len = sizeof(*cmd);
873
874 buf = wmi_buf_alloc(wmi_handle, len);
875 if (!buf) {
876 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
877 return QDF_STATUS_E_FAILURE;
878 }
879 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
880 WMITLV_SET_HDR(&cmd->tlv_header,
881 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
882 WMITLV_GET_STRUCT_TLVLEN
883 (wmi_peer_add_wds_entry_cmd_fixed_param));
884 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
885 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
886 cmd->flags = param->flags;
887
888 return wmi_unified_cmd_send(wmi_handle, buf, len,
889 WMI_PEER_ADD_WDS_ENTRY_CMDID);
890}
891
892/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530893 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530894 * @wmi_handle: wmi handle
895 * @param: pointer holding peer details
896 *
897 * Return: 0 for success or error code
898 */
899static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
900 struct peer_del_wds_entry_params *param)
901{
902 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
903 wmi_buf_t buf;
904 int len = sizeof(*cmd);
905
906 buf = wmi_buf_alloc(wmi_handle, len);
907 if (!buf) {
908 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
909 return QDF_STATUS_E_NOMEM;
910 }
911 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
912 WMITLV_SET_HDR(&cmd->tlv_header,
913 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
914 WMITLV_GET_STRUCT_TLVLEN
915 (wmi_peer_remove_wds_entry_cmd_fixed_param));
916 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
917 return wmi_unified_cmd_send(wmi_handle, buf, len,
918 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
919}
920
921/**
922 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
923 * @wmi_handle: wmi handle
924 * @param: pointer holding peer details
925 *
926 * Return: 0 for success or error code
927 */
928static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
929 struct peer_update_wds_entry_params *param)
930{
931 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
932 wmi_buf_t buf;
933 int len = sizeof(*cmd);
934
935 buf = wmi_buf_alloc(wmi_handle, len);
936 if (!buf) {
937 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
938 return QDF_STATUS_E_NOMEM;
939 }
940
941 /* wmi_buf_alloc returns zeroed command buffer */
942 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
943 WMITLV_SET_HDR(&cmd->tlv_header,
944 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
945 WMITLV_GET_STRUCT_TLVLEN
946 (wmi_peer_update_wds_entry_cmd_fixed_param));
947 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
948 if (param->wds_macaddr)
949 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
950 &cmd->wds_macaddr);
951 if (param->peer_macaddr)
952 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
953 &cmd->peer_macaddr);
954 return wmi_unified_cmd_send(wmi_handle, buf, len,
955 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
956}
957
958
959
960/**
Govind Singh5eb51532016-03-09 11:34:12 +0530961 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
962 * @wmi_handle: wmi handle
963 * @value: value
964 * @mac_id: mac id to have radio context
965 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530966 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530967 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530968static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530969 uint32_t value, uint8_t mac_id)
970{
971 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
972 wmi_buf_t buf;
973 int32_t len = sizeof(*cmd);
974
Govind Singhb53420c2016-03-09 14:32:57 +0530975 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530976
977 buf = wmi_buf_alloc(wmi_handle, len);
978 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530979 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530980 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530981 }
982
983 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
984 WMITLV_SET_HDR(&cmd->tlv_header,
985 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
986 WMITLV_GET_STRUCT_TLVLEN
987 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530988 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530989 cmd->enable = value;
990
991 if (wmi_unified_cmd_send(wmi_handle, buf, len,
992 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530993 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530994 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530995 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530996 }
997
998 return 0;
999}
1000
1001/**
1002 * send_pdev_utf_cmd_tlv() - send utf command to fw
1003 * @wmi_handle: wmi handle
1004 * @param: pointer to pdev_utf_params
1005 * @mac_id: mac id to have radio context
1006 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301007 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301008 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301009static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301010send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1011 struct pdev_utf_params *param,
1012 uint8_t mac_id)
1013{
1014 wmi_buf_t buf;
1015 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001016 /* if param->len is 0 no data is sent, return error */
1017 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301018 static uint8_t msgref = 1;
1019 uint8_t segNumber = 0, segInfo, numSegments;
1020 uint16_t chunk_len, total_bytes;
1021 uint8_t *bufpos;
1022 struct seg_hdr_info segHdrInfo;
1023
1024 bufpos = param->utf_payload;
1025 total_bytes = param->len;
1026 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1027 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1028 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1029
1030 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1031 numSegments++;
1032
1033 while (param->len) {
1034 if (param->len > MAX_WMI_UTF_LEN)
1035 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1036 else
1037 chunk_len = param->len;
1038
1039 buf = wmi_buf_alloc(wmi_handle,
1040 (chunk_len + sizeof(segHdrInfo) +
1041 WMI_TLV_HDR_SIZE));
1042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301043 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301044 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301045 }
1046
1047 cmd = (uint8_t *) wmi_buf_data(buf);
1048
1049 segHdrInfo.len = total_bytes;
1050 segHdrInfo.msgref = msgref;
1051 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1052 segHdrInfo.segmentInfo = segInfo;
1053 segHdrInfo.pad = 0;
1054
Govind Singhb53420c2016-03-09 14:32:57 +05301055 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301056 " segHdrInfo.segmentInfo = %d",
1057 __func__, segHdrInfo.len, segHdrInfo.msgref,
1058 segHdrInfo.segmentInfo);
1059
Govind Singhb53420c2016-03-09 14:32:57 +05301060 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301061 "chunk len %d", __func__, total_bytes, segNumber,
1062 numSegments, chunk_len);
1063
1064 segNumber++;
1065
1066 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1067 (chunk_len + sizeof(segHdrInfo)));
1068 cmd += WMI_TLV_HDR_SIZE;
1069 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1070 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1071
1072 ret = wmi_unified_cmd_send(wmi_handle, buf,
1073 (chunk_len + sizeof(segHdrInfo) +
1074 WMI_TLV_HDR_SIZE),
1075 WMI_PDEV_UTF_CMDID);
1076
Govind Singh67922e82016-04-01 16:48:57 +05301077 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301078 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301079 wmi_buf_free(buf);
1080 break;
1081 }
1082
1083 param->len -= chunk_len;
1084 bufpos += chunk_len;
1085 }
1086
1087 msgref++;
1088
1089 return ret;
1090}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301091#ifdef CONFIG_MCL
1092static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1093 uint32_t host_param)
1094{
1095 return host_param;
1096}
1097#else
1098static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1099 uint32_t host_param)
1100{
1101 if (host_param < wmi_pdev_param_max)
1102 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301103
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301104 return WMI_UNAVAILABLE_PARAM;
1105}
1106#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301107/**
1108 * send_pdev_param_cmd_tlv() - set pdev parameters
1109 * @wmi_handle: wmi handle
1110 * @param: pointer to pdev parameter
1111 * @mac_id: radio context
1112 *
1113 * Return: 0 on success, errno on failure
1114 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301115static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301116send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1117 struct pdev_params *param,
1118 uint8_t mac_id)
1119{
Govind Singh67922e82016-04-01 16:48:57 +05301120 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301121 wmi_pdev_set_param_cmd_fixed_param *cmd;
1122 wmi_buf_t buf;
1123 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301124 uint32_t pdev_param;
1125
1126 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1127 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1128 WMI_LOGW("%s: Unavailable param %d\n",
1129 __func__, param->param_id);
1130 return QDF_STATUS_E_INVAL;
1131 }
Govind Singh5eb51532016-03-09 11:34:12 +05301132
1133 buf = wmi_buf_alloc(wmi_handle, len);
1134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301135 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301136 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301137 }
1138 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1139 WMITLV_SET_HDR(&cmd->tlv_header,
1140 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1141 WMITLV_GET_STRUCT_TLVLEN
1142 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301143 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301144 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301145 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301146 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301147 param->param_value);
1148 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1149 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301150 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301151 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301152 wmi_buf_free(buf);
1153 }
1154 return ret;
1155}
1156
1157/**
1158 * send_suspend_cmd_tlv() - WMI suspend function
1159 * @param wmi_handle : handle to WMI.
1160 * @param param : pointer to hold suspend parameter
1161 * @mac_id: radio context
1162 *
1163 * Return 0 on success and -ve on failure.
1164 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301165static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301166 struct suspend_params *param,
1167 uint8_t mac_id)
1168{
1169 wmi_pdev_suspend_cmd_fixed_param *cmd;
1170 wmi_buf_t wmibuf;
1171 uint32_t len = sizeof(*cmd);
1172 int32_t ret;
1173
1174 /*
1175 * send the comand to Target to ignore the
1176 * PCIE reset so as to ensure that Host and target
1177 * states are in sync
1178 */
1179 wmibuf = wmi_buf_alloc(wmi_handle, len);
1180 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301181 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301182
1183 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1184 WMITLV_SET_HDR(&cmd->tlv_header,
1185 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1186 WMITLV_GET_STRUCT_TLVLEN
1187 (wmi_pdev_suspend_cmd_fixed_param));
1188 if (param->disable_target_intr)
1189 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1190 else
1191 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301192
1193 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1194
Govind Singh5eb51532016-03-09 11:34:12 +05301195 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1196 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301197 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301198 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301199 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301200 }
1201
1202 return ret;
1203}
1204
1205/**
1206 * send_resume_cmd_tlv() - WMI resume function
1207 * @param wmi_handle : handle to WMI.
1208 * @mac_id: radio context
1209 *
1210 * Return: 0 on success and -ve on failure.
1211 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301212static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301213 uint8_t mac_id)
1214{
1215 wmi_buf_t wmibuf;
1216 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301217 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301218
1219 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1220 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301221 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301222 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1223 WMITLV_SET_HDR(&cmd->tlv_header,
1224 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1225 WMITLV_GET_STRUCT_TLVLEN
1226 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301227 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301228 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1229 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301231 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301232 wmi_buf_free(wmibuf);
1233 }
1234
1235 return ret;
1236}
1237
1238/**
1239 * send_wow_enable_cmd_tlv() - WMI wow enable function
1240 * @param wmi_handle : handle to WMI.
1241 * @param param : pointer to hold wow enable parameter
1242 * @mac_id: radio context
1243 *
1244 * Return: 0 on success and -ve on failure.
1245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301246static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301247 struct wow_cmd_params *param,
1248 uint8_t mac_id)
1249{
1250 wmi_wow_enable_cmd_fixed_param *cmd;
1251 wmi_buf_t buf;
1252 int32_t len;
1253 int32_t ret;
1254
1255 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1256
1257 buf = wmi_buf_alloc(wmi_handle, len);
1258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301259 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1260 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301261 }
1262 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1263 WMITLV_SET_HDR(&cmd->tlv_header,
1264 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1265 WMITLV_GET_STRUCT_TLVLEN
1266 (wmi_wow_enable_cmd_fixed_param));
1267 cmd->enable = param->enable;
1268 if (param->can_suspend_link)
1269 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1270 else
1271 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001272 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301273
Govind Singhb53420c2016-03-09 14:32:57 +05301274 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301275 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1276 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1277
1278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1279 WMI_WOW_ENABLE_CMDID);
1280 if (ret)
1281 wmi_buf_free(buf);
1282
1283 return ret;
1284}
1285
1286/**
1287 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301288 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301289 * @peer_addr: peer mac address
1290 * @param: pointer to ap_ps parameter structure
1291 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301292 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301293 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301294static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301295 uint8_t *peer_addr,
1296 struct ap_ps_params *param)
1297{
1298 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1299 wmi_buf_t buf;
1300 int32_t err;
1301
1302 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301304 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301305 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301306 }
1307 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1308 WMITLV_SET_HDR(&cmd->tlv_header,
1309 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1310 WMITLV_GET_STRUCT_TLVLEN
1311 (wmi_ap_ps_peer_cmd_fixed_param));
1312 cmd->vdev_id = param->vdev_id;
1313 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1314 cmd->param = param->param;
1315 cmd->value = param->value;
1316 err = wmi_unified_cmd_send(wmi_handle, buf,
1317 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1318 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301319 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301320 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301321 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301322 }
1323
1324 return 0;
1325}
1326
1327/**
1328 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301329 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301330 * @peer_addr: peer mac address
1331 * @param: pointer to sta_ps parameter structure
1332 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301333 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301334 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301335static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301336 struct sta_ps_params *param)
1337{
1338 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1339 wmi_buf_t buf;
1340 int32_t len = sizeof(*cmd);
1341
1342 buf = wmi_buf_alloc(wmi_handle, len);
1343 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301344 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301345 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301346 }
1347
1348 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1349 WMITLV_SET_HDR(&cmd->tlv_header,
1350 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1351 WMITLV_GET_STRUCT_TLVLEN
1352 (wmi_sta_powersave_param_cmd_fixed_param));
1353 cmd->vdev_id = param->vdev_id;
1354 cmd->param = param->param;
1355 cmd->value = param->value;
1356
1357 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1358 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301359 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301360 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301361 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301362 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301363 }
1364
1365 return 0;
1366}
1367
1368/**
1369 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301370 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301371 * @param: ponirt to crash inject paramter structure
1372 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301373 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301375static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301376 struct crash_inject *param)
1377{
1378 int32_t ret = 0;
1379 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1380 uint16_t len = sizeof(*cmd);
1381 wmi_buf_t buf;
1382
1383 buf = wmi_buf_alloc(wmi_handle, len);
1384 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301385 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301386 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301387 }
1388
1389 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1390 WMITLV_SET_HDR(&cmd->tlv_header,
1391 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1392 WMITLV_GET_STRUCT_TLVLEN
1393 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1394 cmd->type = param->type;
1395 cmd->delay_time_ms = param->delay_time_ms;
1396
1397 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1398 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301399 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301400 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301401 __func__, ret);
1402 wmi_buf_free(buf);
1403 }
1404
1405 return ret;
1406}
1407
1408/**
1409 * send_dbglog_cmd_tlv() - set debug log level
1410 * @param wmi_handle : handle to WMI.
1411 * @param param : pointer to hold dbglog level parameter
1412 *
1413 * Return: 0 on success and -ve on failure.
1414 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301415 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301416send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1417 struct dbglog_params *dbglog_param)
1418{
1419 wmi_buf_t buf;
1420 wmi_debug_log_config_cmd_fixed_param *configmsg;
1421 A_STATUS status = A_OK;
1422 int32_t i;
1423 int32_t len;
1424 int8_t *buf_ptr;
1425 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1426
1427 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1428
1429 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1430 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1431 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1432 buf = wmi_buf_alloc(wmi_handle, len);
1433 if (buf == NULL)
1434 return A_NO_MEMORY;
1435
1436 configmsg =
1437 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1438 buf_ptr = (int8_t *) configmsg;
1439 WMITLV_SET_HDR(&configmsg->tlv_header,
1440 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1441 WMITLV_GET_STRUCT_TLVLEN
1442 (wmi_debug_log_config_cmd_fixed_param));
1443 configmsg->dbg_log_param = dbglog_param->param;
1444 configmsg->value = dbglog_param->val;
1445 /* Filling in the data part of second tlv -- should
1446 * follow first tlv _ WMI_TLV_HDR_SIZE */
1447 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1448 sizeof
1449 (wmi_debug_log_config_cmd_fixed_param)
1450 + WMI_TLV_HDR_SIZE);
1451 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1452 WMITLV_TAG_ARRAY_UINT32,
1453 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1454 if (dbglog_param->module_id_bitmap) {
1455 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1456 module_id_bitmap_array[i] =
1457 dbglog_param->module_id_bitmap[i];
1458 }
1459 }
1460
1461 status = wmi_unified_cmd_send(wmi_handle, buf,
1462 len, WMI_DBGLOG_CFG_CMDID);
1463
1464 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301465 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301466
1467 return status;
1468}
1469
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301470#ifdef CONFIG_MCL
1471static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1472 uint32_t host_param)
1473{
1474 return host_param;
1475}
1476#else
1477static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1478 uint32_t host_param)
1479{
1480 if (host_param < wmi_vdev_param_max)
1481 return wmi_handle->vdev_param[host_param];
1482
1483 return WMI_UNAVAILABLE_PARAM;
1484}
1485#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301486/**
1487 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1488 * @param wmi_handle : handle to WMI.
1489 * @param macaddr : MAC address
1490 * @param param : pointer to hold vdev set parameter
1491 *
1492 * Return: 0 on success and -ve on failure.
1493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301494static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301495 struct vdev_set_params *param)
1496{
Govind Singh67922e82016-04-01 16:48:57 +05301497 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301498 wmi_vdev_set_param_cmd_fixed_param *cmd;
1499 wmi_buf_t buf;
1500 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301501 uint32_t vdev_param;
1502
1503 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1504 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1505 WMI_LOGW("%s:Vdev param %d not available", __func__,
1506 param->param_id);
1507 return QDF_STATUS_E_INVAL;
1508
1509 }
Govind Singh5eb51532016-03-09 11:34:12 +05301510
1511 buf = wmi_buf_alloc(wmi_handle, len);
1512 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301513 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301514 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301515 }
1516 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1517 WMITLV_SET_HDR(&cmd->tlv_header,
1518 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1519 WMITLV_GET_STRUCT_TLVLEN
1520 (wmi_vdev_set_param_cmd_fixed_param));
1521 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301522 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301523 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301524 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301525 param->if_id, param->param_id, param->param_value);
1526 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1527 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301528 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301529 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301530 wmi_buf_free(buf);
1531 }
1532
1533 return ret;
1534}
1535
1536/**
1537 * send_stats_request_cmd_tlv() - WMI request stats function
1538 * @param wmi_handle : handle to WMI.
1539 * @param macaddr : MAC address
1540 * @param param : pointer to hold stats request parameter
1541 *
1542 * Return: 0 on success and -ve on failure.
1543 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301544static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301545 uint8_t macaddr[IEEE80211_ADDR_LEN],
1546 struct stats_request_params *param)
1547{
Govind Singhd3156eb2016-02-26 17:50:39 +05301548 int32_t ret;
1549 wmi_request_stats_cmd_fixed_param *cmd;
1550 wmi_buf_t buf;
1551 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1552
1553 buf = wmi_buf_alloc(wmi_handle, len);
1554 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301555 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1556 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301557 }
1558
1559 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1560 WMITLV_SET_HDR(&cmd->tlv_header,
1561 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1562 WMITLV_GET_STRUCT_TLVLEN
1563 (wmi_request_stats_cmd_fixed_param));
1564 cmd->stats_id = param->stats_id;
1565 cmd->vdev_id = param->vdev_id;
1566 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1567 WMI_REQUEST_STATS_CMDID);
1568 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301569 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301570 wmi_buf_free(buf);
1571 }
1572
1573 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301574}
1575
Govind Singh87542482016-06-08 19:40:11 +05301576#ifdef CONFIG_WIN
1577/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001578 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301579 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001580 * @param PKTLOG_EVENT : packet log event
1581 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301582 *
1583 * Return: 0 on success and -ve on failure.
1584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301585static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001586 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301587{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001588 int32_t ret;
1589 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1590 wmi_buf_t buf;
1591 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1592
1593 buf = wmi_buf_alloc(wmi_handle, len);
1594 if (!buf) {
1595 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1596 return -QDF_STATUS_E_NOMEM;
1597 }
1598
1599 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1600 WMITLV_SET_HDR(&cmd->tlv_header,
1601 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1602 WMITLV_GET_STRUCT_TLVLEN
1603 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1604 cmd->evlist = PKTLOG_EVENT;
1605 cmd->pdev_id = mac_id;
1606 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1607 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1608 if (ret) {
1609 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1610 wmi_buf_free(buf);
1611 }
1612
1613 return ret;
1614}
1615
1616/**
1617 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1618 * @param wmi_handle : handle to WMI.
1619 * @mac_id: mac id to have radio context
1620 *
1621 * Return: 0 on success and -ve on failure.
1622 */
1623static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1624 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
1625{
1626 int32_t ret;
1627 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1628 wmi_buf_t buf;
1629 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1630
1631 buf = wmi_buf_alloc(wmi_handle, len);
1632 if (!buf) {
1633 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1634 return -QDF_STATUS_E_NOMEM;
1635 }
1636
1637 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1638 WMITLV_SET_HDR(&cmd->tlv_header,
1639 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1640 WMITLV_GET_STRUCT_TLVLEN
1641 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1642 cmd->pdev_id = mac_id;
1643 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1644 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1645 if (ret) {
1646 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1647 wmi_buf_free(buf);
1648 }
1649
1650 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301651}
1652#else
Govind Singh5eb51532016-03-09 11:34:12 +05301653/**
1654 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1655 * @param wmi_handle : handle to WMI.
1656 * @param macaddr : MAC address
1657 * @param param : pointer to hold stats request parameter
1658 *
1659 * Return: 0 on success and -ve on failure.
1660 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301661static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301662 uint8_t macaddr[IEEE80211_ADDR_LEN],
1663 struct packet_enable_params *param)
1664{
1665 return 0;
1666}
Govind Singh87542482016-06-08 19:40:11 +05301667#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301668
Sathish Kumarfd347372017-02-13 12:29:09 +05301669static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301670 struct beacon_params *param)
1671{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301672 QDF_STATUS ret;
1673 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1674 wmi_buf_t wmi_buf;
1675 qdf_dma_addr_t dma_addr;
1676 uint32_t dtim_flag = 0;
1677
1678 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1679 if (!wmi_buf) {
1680 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1681 return QDF_STATUS_E_NOMEM;
1682 }
1683 if (param->is_dtim_count_zero) {
1684 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1685 if (param->is_bitctl_reqd) {
1686 /* deliver CAB traffic in next DTIM beacon */
1687 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1688 }
1689 }
1690 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1691 WMITLV_SET_HDR(&cmd->tlv_header,
1692 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1693 WMITLV_GET_STRUCT_TLVLEN
1694 (wmi_bcn_send_from_host_cmd_fixed_param));
1695 cmd->vdev_id = param->vdev_id;
1696 cmd->data_len = qdf_nbuf_len(param->wbuf);
1697 cmd->frame_ctrl = param->frame_ctrl;
1698 cmd->dtim_flag = dtim_flag;
1699 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1700 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1701#if defined(HTT_PADDR64)
1702 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1703#endif
1704 cmd->bcn_antenna = param->bcn_txant;
1705
1706 ret = wmi_unified_cmd_send(wmi_handle,
1707 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1708 if (ret != QDF_STATUS_SUCCESS) {
1709 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1710 wmi_buf_free(wmi_buf);
1711 }
1712
1713 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301714}
1715
1716/**
1717 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1718 * @param wmi_handle : handle to WMI.
1719 * @param param : pointer to hold beacon send cmd parameter
1720 *
1721 * Return: 0 on success and -ve on failure.
1722 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301723static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301724 struct beacon_tmpl_params *param)
1725{
1726 int32_t ret;
1727 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1728 wmi_bcn_prb_info *bcn_prb_info;
1729 wmi_buf_t wmi_buf;
1730 uint8_t *buf_ptr;
1731 uint32_t wmi_buf_len;
1732
Sathish Kumar45e991b2017-02-27 10:35:40 +05301733 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301734 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1735 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1736 param->tmpl_len_aligned;
1737 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1738 if (!wmi_buf) {
1739 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1740 return QDF_STATUS_E_NOMEM;
1741 }
1742 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1743 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1744 WMITLV_SET_HDR(&cmd->tlv_header,
1745 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1746 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1747 cmd->vdev_id = param->vdev_id;
1748 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301749 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1750 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301751 cmd->buf_len = param->tmpl_len;
1752 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1753
1754 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1755 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1756 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1757 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1758 bcn_prb_info->caps = 0;
1759 bcn_prb_info->erp = 0;
1760 buf_ptr += sizeof(wmi_bcn_prb_info);
1761
1762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1763 buf_ptr += WMI_TLV_HDR_SIZE;
1764 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1765
1766 ret = wmi_unified_cmd_send(wmi_handle,
1767 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1768 if (ret) {
1769 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1770 wmi_buf_free(wmi_buf);
1771 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301772
Govind Singh87542482016-06-08 19:40:11 +05301773 return 0;
1774}
Govind Singh5eb51532016-03-09 11:34:12 +05301775
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301776#ifdef CONFIG_MCL
1777static inline void copy_peer_flags_tlv(
1778 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1779 struct peer_assoc_params *param)
1780{
1781 cmd->peer_flags = param->peer_flags;
1782}
1783#else
1784static inline void copy_peer_flags_tlv(
1785 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1786 struct peer_assoc_params *param)
1787{
1788 /*
1789 * The target only needs a subset of the flags maintained in the host.
1790 * Just populate those flags and send it down
1791 */
1792 cmd->peer_flags = 0;
1793
1794 /*
1795 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1796 */
1797 if (param->is_wme_set) {
1798
1799 if (param->qos_flag)
1800 cmd->peer_flags |= WMI_PEER_QOS;
1801 if (param->apsd_flag)
1802 cmd->peer_flags |= WMI_PEER_APSD;
1803 if (param->ht_flag)
1804 cmd->peer_flags |= WMI_PEER_HT;
1805 if (param->bw_40)
1806 cmd->peer_flags |= WMI_PEER_40MHZ;
1807 if (param->bw_80)
1808 cmd->peer_flags |= WMI_PEER_80MHZ;
1809 if (param->bw_160)
1810 cmd->peer_flags |= WMI_PEER_160MHZ;
1811
1812 /* Typically if STBC is enabled for VHT it should be enabled
1813 * for HT as well
1814 **/
1815 if (param->stbc_flag)
1816 cmd->peer_flags |= WMI_PEER_STBC;
1817
1818 /* Typically if LDPC is enabled for VHT it should be enabled
1819 * for HT as well
1820 **/
1821 if (param->ldpc_flag)
1822 cmd->peer_flags |= WMI_PEER_LDPC;
1823
1824 if (param->static_mimops_flag)
1825 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1826 if (param->dynamic_mimops_flag)
1827 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1828 if (param->spatial_mux_flag)
1829 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1830 if (param->vht_flag)
1831 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001832 if (param->he_flag)
1833 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301834 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001835
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301836 if (param->is_pmf_enabled)
1837 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301838 /*
1839 * Suppress authorization for all AUTH modes that need 4-way handshake
1840 * (during re-association).
1841 * Authorization will be done for these modes on key installation.
1842 */
1843 if (param->auth_flag)
1844 cmd->peer_flags |= WMI_PEER_AUTH;
1845 if (param->need_ptk_4_way)
1846 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1847 else
1848 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1849 if (param->need_gtk_2_way)
1850 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1851 /* safe mode bypass the 4-way handshake */
1852 if (param->safe_mode_enabled)
1853 cmd->peer_flags &=
1854 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1855 /* Disable AMSDU for station transmit, if user configures it */
1856 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1857 * it
1858 * if (param->amsdu_disable) Add after FW support
1859 **/
1860
1861 /* Target asserts if node is marked HT and all MCS is set to 0.
1862 * Mark the node as non-HT if all the mcs rates are disabled through
1863 * iwpriv
1864 **/
1865 if (param->peer_ht_rates.num_rates == 0)
1866 cmd->peer_flags &= ~WMI_PEER_HT;
1867}
1868#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301869
1870#ifdef CONFIG_MCL
1871static inline void copy_peer_mac_addr_tlv(
1872 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1873 struct peer_assoc_params *param)
1874{
1875 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1876 sizeof(param->peer_macaddr));
1877}
1878#else
1879static inline void copy_peer_mac_addr_tlv(
1880 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1881 struct peer_assoc_params *param)
1882{
1883 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1884}
1885#endif
1886
Govind Singh5eb51532016-03-09 11:34:12 +05301887/**
1888 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1889 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301890 * @param param : pointer to peer assoc parameter
1891 *
1892 * Return: 0 on success and -ve on failure.
1893 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301894static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301895 struct peer_assoc_params *param)
1896{
Govind Singhd3156eb2016-02-26 17:50:39 +05301897 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1898 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001899 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 wmi_buf_t buf;
1901 int32_t len;
1902 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301903 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301904 uint32_t peer_legacy_rates_align;
1905 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001906 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301907
1908
1909 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1910 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301911
1912 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001913 (peer_legacy_rates_align * sizeof(uint8_t)) +
1914 WMI_TLV_HDR_SIZE +
1915 (peer_ht_rates_align * sizeof(uint8_t)) +
1916 sizeof(wmi_vht_rate_set) +
1917 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1918 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301919
1920 buf = wmi_buf_alloc(wmi_handle, len);
1921 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301922 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301923 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301924 }
1925
1926 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1927 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1928 WMITLV_SET_HDR(&cmd->tlv_header,
1929 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1930 WMITLV_GET_STRUCT_TLVLEN
1931 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301932
Govind Singhd3156eb2016-02-26 17:50:39 +05301933 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301934
Govind Singhd3156eb2016-02-26 17:50:39 +05301935 cmd->peer_new_assoc = param->peer_new_assoc;
1936 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301937
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301938 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301939 copy_peer_mac_addr_tlv(cmd, param);
1940
Govind Singhd3156eb2016-02-26 17:50:39 +05301941 cmd->peer_rate_caps = param->peer_rate_caps;
1942 cmd->peer_caps = param->peer_caps;
1943 cmd->peer_listen_intval = param->peer_listen_intval;
1944 cmd->peer_ht_caps = param->peer_ht_caps;
1945 cmd->peer_max_mpdu = param->peer_max_mpdu;
1946 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301947 cmd->peer_vht_caps = param->peer_vht_caps;
1948 cmd->peer_phymode = param->peer_phymode;
1949
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001950 /* Update 11ax capabilities */
1951 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1952 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001953 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1954 sizeof(param->peer_he_cap_phyinfo));
1955 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1956 sizeof(param->peer_ppet));
1957
Govind Singhd3156eb2016-02-26 17:50:39 +05301958 /* Update peer legacy rate information */
1959 buf_ptr += sizeof(*cmd);
1960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301961 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301962 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301963 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301964 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301965 param->peer_legacy_rates.num_rates);
1966
1967 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001968 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301970 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301971 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301972 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301973 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301974 param->peer_ht_rates.num_rates);
1975
1976 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001977 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1979 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1980
1981 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301982
1983 /* Update bandwidth-NSS mapping */
1984 cmd->peer_bw_rxnss_override = 0;
1985 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1986
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 mcs = (wmi_vht_rate_set *) buf_ptr;
1988 if (param->vht_capable) {
1989 mcs->rx_max_rate = param->rx_max_rate;
1990 mcs->rx_mcs_set = param->rx_mcs_set;
1991 mcs->tx_max_rate = param->tx_max_rate;
1992 mcs->tx_mcs_set = param->tx_mcs_set;
1993 }
1994
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001995 /* HE Rates */
1996 cmd->peer_he_mcs = param->peer_he_mcs_count;
1997 buf_ptr += sizeof(wmi_vht_rate_set);
1998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1999 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2000 buf_ptr += WMI_TLV_HDR_SIZE;
2001
2002 /* Loop through the HE rate set */
2003 for (i = 0; i < param->peer_he_mcs_count; i++) {
2004 he_mcs = (wmi_he_rate_set *) buf_ptr;
2005 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2006 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2007
2008 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2009 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2010 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2011 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2012 buf_ptr += sizeof(wmi_he_rate_set);
2013 }
2014
2015
Govind Singhb53420c2016-03-09 14:32:57 +05302016 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302017 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2018 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002019 "cmd->peer_vht_caps %x "
2020 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302021 "HE phy %x %x %x "
2022 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302023 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2024 cmd->peer_rate_caps, cmd->peer_caps,
2025 cmd->peer_listen_intval, cmd->peer_ht_caps,
2026 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2027 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002028 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2029 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302030 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2031 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302032
2033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2034 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302035 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302036 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302038 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302039 }
2040
2041 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302042}
2043
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302044/* copy_scan_notify_events() - Helper routine to copy scan notify events
2045 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302046static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302047 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302048 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302049{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302050
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302051 /* Scan events subscription */
2052 if (param->scan_ev_started)
2053 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2054 if (param->scan_ev_completed)
2055 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2056 if (param->scan_ev_bss_chan)
2057 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2058 if (param->scan_ev_foreign_chan)
2059 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2060 if (param->scan_ev_dequeued)
2061 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2062 if (param->scan_ev_preempted)
2063 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2064 if (param->scan_ev_start_failed)
2065 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2066 if (param->scan_ev_restarted)
2067 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2068 if (param->scan_ev_foreign_chn_exit)
2069 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2070 if (param->scan_ev_suspended)
2071 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2072 if (param->scan_ev_resumed)
2073 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302074
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302075 /** Set scan control flags */
2076 cmd->scan_ctrl_flags = 0;
2077 if (param->scan_f_passive)
2078 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2079 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302080 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302081 if (param->scan_f_promisc_mode)
2082 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2083 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302084 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302085 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302086 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302087 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302088 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302089 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302090 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302091 if (param->scan_f_ofdm_rates)
2092 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2093 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302094 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302095 if (param->scan_f_filter_prb_req)
2096 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2097 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302098 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302099 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302100 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302101 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302102 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302103 if (param->scan_f_force_active_dfs_chn)
2104 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2105 if (param->scan_f_add_tpc_ie_in_probe)
2106 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2107 if (param->scan_f_add_ds_ie_in_probe)
2108 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2109 if (param->scan_f_add_spoofed_mac_in_probe)
2110 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2111 if (param->scan_f_add_rand_seq_in_probe)
2112 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2113 if (param->scan_f_en_ie_whitelist_in_probe)
2114 cmd->scan_ctrl_flags |=
2115 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302116
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302117 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2118 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2119 param->adaptive_dwell_time_mode);
2120}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302121
2122/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302123static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302124 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302125{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302126 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302127}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302128
Anish Natarajdd855152017-03-20 12:49:08 +05302129/*
2130 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2131 * @param wmi_handle : Handle to WMI
2132 * @param vdev_id : vdev identifier
2133 *
2134 * Return : void *
2135 */
2136static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2137{
2138 struct wlan_objmgr_vdev *vdev = NULL;
2139 struct wlan_objmgr_pdev *pdev = NULL;
2140 uint8_t pdev_id = 0;
2141
2142 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2143 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2144 vdev_id, WLAN_SCAN_ID);
2145 if (vdev) {
2146 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2147 pdev = wlan_vdev_get_pdev(vdev);
2148 if (pdev)
2149 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2150 else {
2151 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2152 }
2153 } else {
2154 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2155 }
2156
2157 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2158}
2159
Govind Singh5eb51532016-03-09 11:34:12 +05302160/**
2161 * send_scan_start_cmd_tlv() - WMI scan start function
2162 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302163 * @param param : pointer to hold scan start cmd parameter
2164 *
2165 * Return: 0 on success and -ve on failure.
2166 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302167static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302168 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302169{
Govind Singhd3156eb2016-02-26 17:50:39 +05302170 int32_t ret = 0;
2171 int32_t i;
2172 wmi_buf_t wmi_buf;
2173 wmi_start_scan_cmd_fixed_param *cmd;
2174 uint8_t *buf_ptr;
2175 uint32_t *tmp_ptr;
2176 wmi_ssid *ssid = NULL;
2177 wmi_mac_addr *bssid;
2178 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302179 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302180
2181 /* Length TLV placeholder for array of uint32_t */
2182 len += WMI_TLV_HDR_SIZE;
2183 /* calculate the length of buffer required */
2184 if (params->num_chan)
2185 len += params->num_chan * sizeof(uint32_t);
2186
2187 /* Length TLV placeholder for array of wmi_ssid structures */
2188 len += WMI_TLV_HDR_SIZE;
2189 if (params->num_ssids)
2190 len += params->num_ssids * sizeof(wmi_ssid);
2191
2192 /* Length TLV placeholder for array of wmi_mac_addr structures */
2193 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302194 if (params->num_bssid)
2195 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302196
2197 /* Length TLV placeholder for array of bytes */
2198 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302199 if (params->extraie.len)
2200 extraie_len_with_pad =
2201 roundup(params->extraie.len, sizeof(uint32_t));
2202 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302203
2204 /* Allocate the memory */
2205 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2206 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302207 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302208 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302209 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302210 }
2211 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2212 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2213 WMITLV_SET_HDR(&cmd->tlv_header,
2214 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2215 WMITLV_GET_STRUCT_TLVLEN
2216 (wmi_start_scan_cmd_fixed_param));
2217
2218 cmd->scan_id = params->scan_id;
2219 cmd->scan_req_id = params->scan_req_id;
2220 cmd->vdev_id = params->vdev_id;
2221 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302222
2223 copy_scan_event_cntrl_flags(cmd, params);
2224
Govind Singhd3156eb2016-02-26 17:50:39 +05302225 cmd->dwell_time_active = params->dwell_time_active;
2226 cmd->dwell_time_passive = params->dwell_time_passive;
2227 cmd->min_rest_time = params->min_rest_time;
2228 cmd->max_rest_time = params->max_rest_time;
2229 cmd->repeat_probe_time = params->repeat_probe_time;
2230 cmd->probe_spacing_time = params->probe_spacing_time;
2231 cmd->idle_time = params->idle_time;
2232 cmd->max_scan_time = params->max_scan_time;
2233 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302234 cmd->burst_duration = params->burst_duration;
2235 cmd->num_chan = params->num_chan;
2236 cmd->num_bssid = params->num_bssid;
2237 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302238 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302239 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302240 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2241
2242 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2243
Govind Singhd3156eb2016-02-26 17:50:39 +05302244 buf_ptr += sizeof(*cmd);
2245 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2246 for (i = 0; i < params->num_chan; ++i)
2247 tmp_ptr[i] = params->chan_list[i];
2248
2249 WMITLV_SET_HDR(buf_ptr,
2250 WMITLV_TAG_ARRAY_UINT32,
2251 (params->num_chan * sizeof(uint32_t)));
2252 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302253 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302254 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302255 goto error;
2256 }
2257
2258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2259 (params->num_ssids * sizeof(wmi_ssid)));
2260
2261 if (params->num_ssids) {
2262 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2263 for (i = 0; i < params->num_ssids; ++i) {
2264 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302265 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302266 params->ssid[i].length);
2267 ssid++;
2268 }
2269 }
2270 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2271
2272 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2273 (params->num_bssid * sizeof(wmi_mac_addr)));
2274 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302275
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302276 if (params->num_bssid) {
2277 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302278 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2279 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302280 bssid++;
2281 }
2282 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302283
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302284 buf_ptr += WMI_TLV_HDR_SIZE +
2285 (params->num_bssid * sizeof(wmi_mac_addr));
2286
2287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2288 if (params->extraie.len)
2289 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2290 params);
2291
2292 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302293
Anish Natarajdd855152017-03-20 12:49:08 +05302294 ret = wmi_unified_cmd_send(
2295 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302296 len, WMI_START_SCAN_CMDID);
2297 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302298 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302299 wmi_buf_free(wmi_buf);
2300 }
2301 return ret;
2302error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302303 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302304 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302305}
2306
2307/**
2308 * send_scan_stop_cmd_tlv() - WMI scan start function
2309 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302310 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302311 *
2312 * Return: 0 on success and -ve on failure.
2313 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302314static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302315 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302316{
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 wmi_stop_scan_cmd_fixed_param *cmd;
2318 int ret;
2319 int len = sizeof(*cmd);
2320 wmi_buf_t wmi_buf;
2321
2322 /* Allocate the memory */
2323 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2324 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302325 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302327 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302328 goto error;
2329 }
2330
2331 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2332 WMITLV_SET_HDR(&cmd->tlv_header,
2333 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2334 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2335 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302336 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302337 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302338 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2339 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302340 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302341 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2342 /* Cancelling all scans */
2343 cmd->req_type = WMI_SCAN_STOP_ALL;
2344 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2345 /* Cancelling VAP scans */
2346 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2347 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2348 /* Cancelling specific scan */
2349 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302350 } else {
2351 WMI_LOGE("%s: Invalid Command : ", __func__);
2352 wmi_buf_free(wmi_buf);
2353 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302354 }
2355
Anish Natarajdd855152017-03-20 12:49:08 +05302356 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302357 len, WMI_STOP_SCAN_CMDID);
2358 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302359 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302360 wmi_buf_free(wmi_buf);
2361 }
2362
2363error:
2364 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302365}
2366
Govind Singh87542482016-06-08 19:40:11 +05302367#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302368/**
2369 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2370 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302371 * @param param : pointer to hold scan channel list parameter
2372 *
2373 * Return: 0 on success and -ve on failure.
2374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302375static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302376 struct scan_chan_list_params *chan_list)
2377{
2378 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302379 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302381 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302383 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302384 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2385
2386 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2387 buf = wmi_buf_alloc(wmi_handle, len);
2388 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302389 WMI_LOGE("Failed to allocate memory");
2390 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302391 goto end;
2392 }
2393
2394 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2395 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2396 WMITLV_SET_HDR(&cmd->tlv_header,
2397 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2398 WMITLV_GET_STRUCT_TLVLEN
2399 (wmi_scan_chan_list_cmd_fixed_param));
2400
Govind Singhb53420c2016-03-09 14:32:57 +05302401 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302402
2403 cmd->num_scan_chans = chan_list->num_scan_chans;
2404 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2405 WMITLV_TAG_ARRAY_STRUC,
2406 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302407 chan_info = (wmi_channel_param *)
2408 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302409 tchan_info = chan_list->chan_info;
2410
2411 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2412 WMITLV_SET_HDR(&chan_info->tlv_header,
2413 WMITLV_TAG_STRUC_wmi_channel,
2414 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2415 chan_info->mhz = tchan_info->mhz;
2416 chan_info->band_center_freq1 =
2417 tchan_info->band_center_freq1;
2418 chan_info->band_center_freq2 =
2419 tchan_info->band_center_freq2;
2420 chan_info->info = tchan_info->info;
2421 chan_info->reg_info_1 = tchan_info->reg_info_1;
2422 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302423 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302424
2425 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2426 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2427 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2428 tchan_info++;
2429 chan_info++;
2430 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302431 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2432 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302433
Anish Natarajdd855152017-03-20 12:49:08 +05302434 qdf_status = wmi_unified_cmd_send(wmi_handle,
2435 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302436
Govind Singh67922e82016-04-01 16:48:57 +05302437 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302438 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302439 wmi_buf_free(buf);
2440 }
Govind Singh67922e82016-04-01 16:48:57 +05302441
Govind Singhd3156eb2016-02-26 17:50:39 +05302442end:
Govind Singhb53420c2016-03-09 14:32:57 +05302443 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302444}
Govind Singh87542482016-06-08 19:40:11 +05302445#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302446static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302447 struct scan_chan_list_params *chan_list)
2448{
2449 wmi_buf_t buf;
2450 QDF_STATUS qdf_status;
2451 wmi_scan_chan_list_cmd_fixed_param *cmd;
2452 int i;
2453 uint8_t *buf_ptr;
2454 wmi_channel *chan_info;
2455 struct channel_param *tchan_info;
2456 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302457
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302458 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302459 buf = wmi_buf_alloc(wmi_handle, len);
2460 if (!buf) {
2461 WMI_LOGE("Failed to allocate memory");
2462 qdf_status = QDF_STATUS_E_NOMEM;
2463 goto end;
2464 }
2465
2466 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2467 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2468 WMITLV_SET_HDR(&cmd->tlv_header,
2469 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2470 WMITLV_GET_STRUCT_TLVLEN
2471 (wmi_scan_chan_list_cmd_fixed_param));
2472
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302473 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302474
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302475 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2476 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302477 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302478 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2479 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302480 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302481 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2482 tchan_info = &(chan_list->ch_param[0]);
2483
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302484 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302485 WMITLV_SET_HDR(&chan_info->tlv_header,
2486 WMITLV_TAG_STRUC_wmi_channel,
2487 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2488 chan_info->mhz = tchan_info->mhz;
2489 chan_info->band_center_freq1 =
2490 tchan_info->cfreq1;
2491 chan_info->band_center_freq2 =
2492 tchan_info->cfreq2;
2493
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302494 if (tchan_info->is_chan_passive)
2495 WMI_SET_CHANNEL_FLAG(chan_info,
2496 WMI_CHAN_FLAG_PASSIVE);
2497
2498 if (tchan_info->allow_vht)
2499 WMI_SET_CHANNEL_FLAG(chan_info,
2500 WMI_CHAN_FLAG_ALLOW_VHT);
2501 else if (tchan_info->allow_ht)
2502 WMI_SET_CHANNEL_FLAG(chan_info,
2503 WMI_CHAN_FLAG_ALLOW_HT);
2504 WMI_SET_CHANNEL_MODE(chan_info,
2505 tchan_info->phy_mode);
2506
2507 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2508 * after FW support
2509 */
2510
2511 /* also fill in power information */
2512 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2513 tchan_info->minpower);
2514 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2515 tchan_info->maxpower);
2516 WMI_SET_CHANNEL_REG_POWER(chan_info,
2517 tchan_info->maxregpower);
2518 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2519 tchan_info->antennamax);
2520 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2521 tchan_info->reg_class_id);
2522
Govind Singh87542482016-06-08 19:40:11 +05302523 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2524
Govind Singh87542482016-06-08 19:40:11 +05302525 tchan_info++;
2526 chan_info++;
2527 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302528 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2529 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302530
Anish Natarajdd855152017-03-20 12:49:08 +05302531 qdf_status = wmi_unified_cmd_send(
2532 wmi_handle,
2533 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302534
2535 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2536 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2537 wmi_buf_free(buf);
2538 }
2539
2540end:
2541 return qdf_status;
2542}
2543#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302544
2545/**
2546 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2547 *
2548 * @bufp: Pointer to buffer
2549 * @param: Pointer to tx param
2550 *
2551 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2552 */
2553static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2554 struct tx_send_params param)
2555{
2556 wmi_tx_send_params *tx_param;
2557 QDF_STATUS status = QDF_STATUS_SUCCESS;
2558
2559 if (!bufp) {
2560 status = QDF_STATUS_E_FAILURE;
2561 return status;
2562 }
2563 tx_param = (wmi_tx_send_params *)bufp;
2564 WMITLV_SET_HDR(&tx_param->tlv_header,
2565 WMITLV_TAG_STRUC_wmi_tx_send_params,
2566 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2567 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2568 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2569 param.mcs_mask);
2570 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2571 param.nss_mask);
2572 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2573 param.retry_limit);
2574 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2575 param.chain_mask);
2576 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2577 param.bw_mask);
2578 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2579 param.preamble_type);
2580 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2581 param.frame_type);
2582
2583 return status;
2584}
2585
Govind Singhd3156eb2016-02-26 17:50:39 +05302586/**
2587 * send_mgmt_cmd_tlv() - WMI scan start function
2588 * @wmi_handle : handle to WMI.
2589 * @param : pointer to hold mgmt cmd parameter
2590 *
2591 * Return: 0 on success and -ve on failure.
2592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302593static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302594 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302595{
Govind Singh427ee5a2016-02-26 18:09:36 +05302596 wmi_buf_t buf;
2597 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2598 int32_t cmd_len;
2599 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302600 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302601 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302602 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302603 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2604 mgmt_tx_dl_frm_len;
2605
2606 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302607 WMI_TLV_HDR_SIZE +
2608 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302609
Sathish Kumar5b636932017-06-28 14:40:32 +05302610 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302612 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2613 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302614 }
2615
2616 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2617 bufp = (uint8_t *) cmd;
2618 WMITLV_SET_HDR(&cmd->tlv_header,
2619 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2620 WMITLV_GET_STRUCT_TLVLEN
2621 (wmi_mgmt_tx_send_cmd_fixed_param));
2622
2623 cmd->vdev_id = param->vdev_id;
2624
Govind Singh224a7312016-06-21 14:33:26 +05302625 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302626 cmd->chanfreq = param->chanfreq;
2627 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2628 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2629 sizeof(uint32_t)));
2630 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302631 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302632
2633 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2634 QDF_DMA_TO_DEVICE);
2635 if (status != QDF_STATUS_SUCCESS) {
2636 WMI_LOGE("%s: wmi buf map failed", __func__);
2637 goto err1;
2638 }
2639
Govind Singhb53420c2016-03-09 14:32:57 +05302640 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302641 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002642#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302643 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2644#endif
2645 cmd->frame_len = param->frm_len;
2646 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302647 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302648
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002649 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002650 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002651
Sathish Kumar5b636932017-06-28 14:40:32 +05302652 bufp += roundup(bufp_len, sizeof(uint32_t));
2653 if (param->tx_params_valid) {
2654 status = populate_tx_send_params(bufp, param->tx_param);
2655 if (status != QDF_STATUS_SUCCESS) {
2656 WMI_LOGE("%s: Populate TX send params failed",
2657 __func__);
2658 goto err1;
2659 }
2660 cmd_len += sizeof(wmi_tx_send_params);
2661 }
2662
Govind Singh427ee5a2016-02-26 18:09:36 +05302663 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2664 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302665 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302666 goto err1;
2667 }
Govind Singhb53420c2016-03-09 14:32:57 +05302668 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302669
2670err1:
2671 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302672 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302673}
2674
2675/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302676 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2677 * @wmi_handle : handle to WMI.
2678 * @param : pointer to offchan data tx cmd parameter
2679 *
2680 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2681 */
2682static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2683 struct wmi_offchan_data_tx_params *param)
2684{
2685 wmi_buf_t buf;
2686 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2687 int32_t cmd_len;
2688 uint64_t dma_addr;
2689 void *qdf_ctx = param->qdf_ctx;
2690 uint8_t *bufp;
2691 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2692 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302693 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302694
2695 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302696 WMI_TLV_HDR_SIZE +
2697 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302698
Sathish Kumar5b636932017-06-28 14:40:32 +05302699 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302700 if (!buf) {
2701 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2702 return QDF_STATUS_E_NOMEM;
2703 }
2704
2705 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2706 bufp = (uint8_t *) cmd;
2707 WMITLV_SET_HDR(&cmd->tlv_header,
2708 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2709 WMITLV_GET_STRUCT_TLVLEN
2710 (wmi_offchan_data_tx_send_cmd_fixed_param));
2711
2712 cmd->vdev_id = param->vdev_id;
2713
2714 cmd->desc_id = param->desc_id;
2715 cmd->chanfreq = param->chanfreq;
2716 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2717 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2718 sizeof(uint32_t)));
2719 bufp += WMI_TLV_HDR_SIZE;
2720 qdf_mem_copy(bufp, param->pdata, bufp_len);
2721 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2722 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2723 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2724#if defined(HTT_PADDR64)
2725 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2726#endif
2727 cmd->frame_len = param->frm_len;
2728 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302729 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302730
2731 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2732 bufp, cmd->vdev_id, cmd->chanfreq);
2733
Sathish Kumar5b636932017-06-28 14:40:32 +05302734 bufp += roundup(bufp_len, sizeof(uint32_t));
2735 if (param->tx_params_valid) {
2736 status = populate_tx_send_params(bufp, param->tx_param);
2737 if (status != QDF_STATUS_SUCCESS) {
2738 WMI_LOGE("%s: Populate TX send params failed",
2739 __func__);
2740 goto err1;
2741 }
2742 cmd_len += sizeof(wmi_tx_send_params);
2743 }
2744
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302745 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2746 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2747 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05302748 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302749 }
2750
2751 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05302752
2753err1:
2754 wmi_buf_free(buf);
2755 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302756}
2757
2758/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302759 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2760 * @wmi_handle: wmi handle
2761 * @param_value: parameter value
2762 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302763 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302764 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302765static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302766 uint32_t param_value)
2767{
Govind Singh67922e82016-04-01 16:48:57 +05302768 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302769 wmi_modem_power_state_cmd_param *cmd;
2770 wmi_buf_t buf;
2771 uint16_t len = sizeof(*cmd);
2772
2773 buf = wmi_buf_alloc(wmi_handle, len);
2774 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302775 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302776 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302777 }
2778 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2779 WMITLV_SET_HDR(&cmd->tlv_header,
2780 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2781 WMITLV_GET_STRUCT_TLVLEN
2782 (wmi_modem_power_state_cmd_param));
2783 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302784 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302785 param_value);
2786 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2787 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302788 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302789 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302790 wmi_buf_free(buf);
2791 }
Govind Singh67922e82016-04-01 16:48:57 +05302792
Govind Singh427ee5a2016-02-26 18:09:36 +05302793 return ret;
2794}
2795
2796/**
2797 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2798 * @wmi_handle: wmi handle
2799 * @vdev_id: vdev id
2800 * @val: value
2801 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302802 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302803 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302804static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302805 uint32_t vdev_id, uint8_t val)
2806{
2807 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2808 wmi_buf_t buf;
2809 int32_t len = sizeof(*cmd);
2810
Govind Singhb53420c2016-03-09 14:32:57 +05302811 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302812
2813 buf = wmi_buf_alloc(wmi_handle, len);
2814 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302815 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302816 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302817 }
2818 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2819 WMITLV_SET_HDR(&cmd->tlv_header,
2820 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2821 WMITLV_GET_STRUCT_TLVLEN
2822 (wmi_sta_powersave_mode_cmd_fixed_param));
2823 cmd->vdev_id = vdev_id;
2824 if (val)
2825 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2826 else
2827 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2828
2829 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2830 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302831 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302832 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302833 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302834 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302835 }
Govind Singh5eb51532016-03-09 11:34:12 +05302836 return 0;
2837}
2838
Govind Singh427ee5a2016-02-26 18:09:36 +05302839/**
2840 * send_set_mimops_cmd_tlv() - set MIMO powersave
2841 * @wmi_handle: wmi handle
2842 * @vdev_id: vdev id
2843 * @value: value
2844 *
Govind Singhb53420c2016-03-09 14:32:57 +05302845 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302846 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302847static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302848 uint8_t vdev_id, int value)
2849{
Govind Singh67922e82016-04-01 16:48:57 +05302850 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302851 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2852 wmi_buf_t buf;
2853 uint16_t len = sizeof(*cmd);
2854
2855 buf = wmi_buf_alloc(wmi_handle, len);
2856 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302857 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302858 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302859 }
2860 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2861 WMITLV_SET_HDR(&cmd->tlv_header,
2862 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2863 WMITLV_GET_STRUCT_TLVLEN
2864 (wmi_sta_smps_force_mode_cmd_fixed_param));
2865
2866 cmd->vdev_id = vdev_id;
2867
Houston Hoffmanb5168052016-04-14 02:18:01 -07002868 /* WMI_SMPS_FORCED_MODE values do not directly map
2869 * to SM power save values defined in the specification.
2870 * Make sure to send the right mapping.
2871 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302872 switch (value) {
2873 case 0:
2874 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2875 break;
2876 case 1:
2877 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2878 break;
2879 case 2:
2880 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2881 break;
2882 case 3:
2883 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2884 break;
2885 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302886 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2887 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302888 }
2889
Govind Singhb53420c2016-03-09 14:32:57 +05302890 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302891
2892 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2893 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302894 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302895 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302896 wmi_buf_free(buf);
2897 }
2898
2899 return ret;
2900}
2901
2902/**
2903 * send_set_smps_params_cmd_tlv() - set smps params
2904 * @wmi_handle: wmi handle
2905 * @vdev_id: vdev id
2906 * @value: value
2907 *
Govind Singhb53420c2016-03-09 14:32:57 +05302908 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302909 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302910static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302911 int value)
2912{
Govind Singh67922e82016-04-01 16:48:57 +05302913 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302914 wmi_sta_smps_param_cmd_fixed_param *cmd;
2915 wmi_buf_t buf;
2916 uint16_t len = sizeof(*cmd);
2917
2918 buf = wmi_buf_alloc(wmi_handle, len);
2919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302920 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302921 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302922 }
2923 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2924 WMITLV_SET_HDR(&cmd->tlv_header,
2925 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2926 WMITLV_GET_STRUCT_TLVLEN
2927 (wmi_sta_smps_param_cmd_fixed_param));
2928
2929 cmd->vdev_id = vdev_id;
2930 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2931 cmd->param =
2932 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2933
Govind Singhb53420c2016-03-09 14:32:57 +05302934 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302935 cmd->param);
2936
2937 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2938 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302939 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302940 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302941 wmi_buf_free(buf);
2942 }
2943
2944 return ret;
2945}
2946
2947/**
2948 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2949 * @wmi_handle: wmi handle
2950 * @noa: p2p power save parameters
2951 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302952 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302953 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302954static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302955 struct p2p_ps_params *noa)
2956{
2957 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2958 wmi_p2p_noa_descriptor *noa_discriptor;
2959 wmi_buf_t buf;
2960 uint8_t *buf_ptr;
2961 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302962 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302963 uint32_t duration;
2964
Govind Singhb53420c2016-03-09 14:32:57 +05302965 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302966 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2967 buf = wmi_buf_alloc(wmi_handle, len);
2968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302969 WMI_LOGE("Failed to allocate memory");
2970 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302971 goto end;
2972 }
2973
2974 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2975 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2976 WMITLV_SET_HDR(&cmd->tlv_header,
2977 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2978 WMITLV_GET_STRUCT_TLVLEN
2979 (wmi_p2p_set_noa_cmd_fixed_param));
2980 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2981 cmd->vdev_id = noa->session_id;
2982 cmd->enable = (duration) ? true : false;
2983 cmd->num_noa = 1;
2984
2985 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2986 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2987 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2988 sizeof
2989 (wmi_p2p_set_noa_cmd_fixed_param)
2990 + WMI_TLV_HDR_SIZE);
2991 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2992 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2993 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2994 noa_discriptor->type_count = noa->count;
2995 noa_discriptor->duration = duration;
2996 noa_discriptor->interval = noa->interval;
2997 noa_discriptor->start_time = 0;
2998
Govind Singhb53420c2016-03-09 14:32:57 +05302999 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303000 cmd->vdev_id, noa->count, noa_discriptor->duration,
3001 noa->interval);
3002 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3003 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303004 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303005 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303006 wmi_buf_free(buf);
3007 }
3008
3009end:
Govind Singhb53420c2016-03-09 14:32:57 +05303010 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303011 return status;
3012}
3013
3014
3015/**
3016 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3017 * @wmi_handle: wmi handle
3018 * @noa: p2p opp power save parameters
3019 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303020 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303021 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303022static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303023 struct p2p_ps_params *oppps)
3024{
3025 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3026 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303027 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303028
Govind Singhb53420c2016-03-09 14:32:57 +05303029 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303030 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3031 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303032 WMI_LOGE("Failed to allocate memory");
3033 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303034 goto end;
3035 }
3036
3037 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3038 WMITLV_SET_HDR(&cmd->tlv_header,
3039 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3040 WMITLV_GET_STRUCT_TLVLEN
3041 (wmi_p2p_set_oppps_cmd_fixed_param));
3042 cmd->vdev_id = oppps->session_id;
3043 if (oppps->ctwindow)
3044 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3045
3046 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303047 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303048 cmd->vdev_id, oppps->ctwindow);
3049 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3050 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303051 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303052 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303053 wmi_buf_free(buf);
3054 }
3055
3056end:
Govind Singhb53420c2016-03-09 14:32:57 +05303057 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303058 return status;
3059}
3060
Wu Gaocd3a8512017-03-13 20:17:34 +08003061#ifdef CONVERGED_P2P_ENABLE
3062/**
3063 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3064 * @wmi_handle: wmi handle
3065 * @param: p2p listen offload start parameters
3066 *
3067 * Return: QDF status
3068 */
3069static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3070 struct p2p_lo_start *param)
3071{
3072 wmi_buf_t buf;
3073 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3074 int32_t len = sizeof(*cmd);
3075 uint8_t *buf_ptr;
3076 QDF_STATUS status;
3077 int device_types_len_aligned;
3078 int probe_resp_len_aligned;
3079
3080 if (!param) {
3081 WMI_LOGE("lo start param is null");
3082 return QDF_STATUS_E_INVAL;
3083 }
3084
3085 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3086
3087 device_types_len_aligned =
3088 qdf_roundup(param->dev_types_len,
3089 sizeof(A_UINT32));
3090 probe_resp_len_aligned =
3091 qdf_roundup(param->probe_resp_len,
3092 sizeof(A_UINT32));
3093
3094 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3095 probe_resp_len_aligned;
3096
3097 buf = wmi_buf_alloc(wmi_handle, len);
3098 if (!buf) {
3099 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3100 __func__);
3101 return QDF_STATUS_E_NOMEM;
3102 }
3103
3104 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3105 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3106
3107 WMITLV_SET_HDR(&cmd->tlv_header,
3108 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3109 WMITLV_GET_STRUCT_TLVLEN(
3110 wmi_p2p_lo_start_cmd_fixed_param));
3111
3112 cmd->vdev_id = param->vdev_id;
3113 cmd->ctl_flags = param->ctl_flags;
3114 cmd->channel = param->freq;
3115 cmd->period = param->period;
3116 cmd->interval = param->interval;
3117 cmd->count = param->count;
3118 cmd->device_types_len = param->dev_types_len;
3119 cmd->prob_resp_len = param->probe_resp_len;
3120
3121 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3123 device_types_len_aligned);
3124 buf_ptr += WMI_TLV_HDR_SIZE;
3125 qdf_mem_copy(buf_ptr, param->device_types,
3126 param->dev_types_len);
3127
3128 buf_ptr += device_types_len_aligned;
3129 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3130 probe_resp_len_aligned);
3131 buf_ptr += WMI_TLV_HDR_SIZE;
3132 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3133 param->probe_resp_len);
3134
3135 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3136 cmd->channel, cmd->period, cmd->interval, cmd->count);
3137
3138 status = wmi_unified_cmd_send(wmi_handle,
3139 buf, len,
3140 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3141 if (status != QDF_STATUS_SUCCESS) {
3142 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3143 __func__, status);
3144 wmi_buf_free(buf);
3145 return status;
3146 }
3147
3148 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3149
3150 return QDF_STATUS_SUCCESS;
3151}
3152
3153/**
3154 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3155 * @wmi_handle: wmi handle
3156 * @param: p2p listen offload stop parameters
3157 *
3158 * Return: QDF status
3159 */
3160static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3161 uint8_t vdev_id)
3162{
3163 wmi_buf_t buf;
3164 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3165 int32_t len;
3166 QDF_STATUS status;
3167
3168 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3169
3170 len = sizeof(*cmd);
3171 buf = wmi_buf_alloc(wmi_handle, len);
3172 if (!buf) {
3173 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3174 __func__);
3175 return QDF_STATUS_E_NOMEM;
3176 }
3177 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3178
3179 WMITLV_SET_HDR(&cmd->tlv_header,
3180 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3181 WMITLV_GET_STRUCT_TLVLEN(
3182 wmi_p2p_lo_stop_cmd_fixed_param));
3183
3184 cmd->vdev_id = vdev_id;
3185
3186 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3187
3188 status = wmi_unified_cmd_send(wmi_handle,
3189 buf, len,
3190 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3191 if (status != QDF_STATUS_SUCCESS) {
3192 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3193 __func__, status);
3194 wmi_buf_free(buf);
3195 return status;
3196 }
3197
3198 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3199
3200 return QDF_STATUS_SUCCESS;
3201}
3202#endif /* End of CONVERGED_P2P_ENABLE */
3203
Govind Singh427ee5a2016-02-26 18:09:36 +05303204/**
3205 * send_get_temperature_cmd_tlv() - get pdev temperature req
3206 * @wmi_handle: wmi handle
3207 *
Govind Singhb53420c2016-03-09 14:32:57 +05303208 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303210static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303211{
3212 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3213 wmi_buf_t wmi_buf;
3214 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3215 uint8_t *buf_ptr;
3216
3217 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303218 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3219 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303220 }
3221
3222 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3223 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303224 WMI_LOGE(FL("wmi_buf_alloc failed"));
3225 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303226 }
3227
3228 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3229
3230 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3231 WMITLV_SET_HDR(&cmd->tlv_header,
3232 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3233 WMITLV_GET_STRUCT_TLVLEN
3234 (wmi_pdev_get_temperature_cmd_fixed_param));
3235
3236 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3237 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303238 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303239 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303240 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303241 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303242
Govind Singhb53420c2016-03-09 14:32:57 +05303243 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303244}
3245
3246/**
3247 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3248 * @wmi_handle: wmi handle
3249 * @vdevid: vdev id
3250 * @peer_addr: peer mac address
3251 * @auto_triggerparam: auto trigger parameters
3252 * @num_ac: number of access category
3253 *
3254 * This function sets the trigger
3255 * uapsd params such as service interval, delay interval
3256 * and suspend interval which will be used by the firmware
3257 * to send trigger frames periodically when there is no
3258 * traffic on the transmit side.
3259 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303260 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303261 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303262static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303263 struct sta_uapsd_trig_params *param)
3264{
3265 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303266 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303267 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3268 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3269 uint32_t i;
3270 wmi_buf_t buf;
3271 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003272 struct sta_uapsd_params *uapsd_param;
3273 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303274
3275 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3276 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303277 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303278 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303279 }
3280
3281 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3282 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3283 WMITLV_SET_HDR(&cmd->tlv_header,
3284 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3285 WMITLV_GET_STRUCT_TLVLEN
3286 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3287 cmd->vdev_id = param->vdevid;
3288 cmd->num_ac = param->num_ac;
3289 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3290
3291 /* TLV indicating array of structures to follow */
3292 buf_ptr += sizeof(*cmd);
3293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3294
3295 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303296
3297 /*
3298 * Update tag and length for uapsd auto trigger params (this will take
3299 * care of updating tag and length if it is not pre-filled by caller).
3300 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003301 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3302 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303303 for (i = 0; i < param->num_ac; i++) {
3304 WMITLV_SET_HDR((buf_ptr +
3305 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3306 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3307 WMITLV_GET_STRUCT_TLVLEN
3308 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003309 trig_param->wmm_ac = uapsd_param->wmm_ac;
3310 trig_param->user_priority = uapsd_param->user_priority;
3311 trig_param->service_interval = uapsd_param->service_interval;
3312 trig_param->suspend_interval = uapsd_param->suspend_interval;
3313 trig_param->delay_interval = uapsd_param->delay_interval;
3314 trig_param++;
3315 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303316 }
3317
3318 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3319 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303320 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303321 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303322 wmi_buf_free(buf);
3323 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303324
Govind Singh427ee5a2016-02-26 18:09:36 +05303325 return ret;
3326}
3327
Govind Singh2edc80f2016-03-01 15:30:53 +05303328/**
3329 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3330 * @wmi_handle: pointer to the wmi handle
3331 * @utc: pointer to the UTC time struct
3332 *
3333 * Return: 0 on succes
3334 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303335static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303336 struct ocb_utc_param *utc)
3337{
Govind Singh67922e82016-04-01 16:48:57 +05303338 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303339 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3340 uint8_t *buf_ptr;
3341 uint32_t len, i;
3342 wmi_buf_t buf;
3343
3344 len = sizeof(*cmd);
3345 buf = wmi_buf_alloc(wmi_handle, len);
3346 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303347 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303348 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303349 }
3350
3351 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3352 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3353 WMITLV_SET_HDR(&cmd->tlv_header,
3354 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3355 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3356 cmd->vdev_id = utc->vdev_id;
3357
3358 for (i = 0; i < SIZE_UTC_TIME; i++)
3359 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3360
3361 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3362 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3363
3364 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3365 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303366 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303367 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303368 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303369 }
3370
Govind Singh67922e82016-04-01 16:48:57 +05303371 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303372}
3373
3374/**
3375 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3376 * frames on a channel
3377 * @wmi_handle: pointer to the wmi handle
3378 * @timing_advert: pointer to the timing advertisement struct
3379 *
3380 * Return: 0 on succes
3381 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303382static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303383 struct ocb_timing_advert_param *timing_advert)
3384{
Govind Singh67922e82016-04-01 16:48:57 +05303385 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303386 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3387 uint8_t *buf_ptr;
3388 uint32_t len, len_template;
3389 wmi_buf_t buf;
3390
3391 len = sizeof(*cmd) +
3392 WMI_TLV_HDR_SIZE;
3393
3394 len_template = timing_advert->template_length;
3395 /* Add padding to the template if needed */
3396 if (len_template % 4 != 0)
3397 len_template += 4 - (len_template % 4);
3398 len += len_template;
3399
3400 buf = wmi_buf_alloc(wmi_handle, len);
3401 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303402 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303403 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303404 }
3405
3406 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3407 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3408 WMITLV_SET_HDR(&cmd->tlv_header,
3409 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3410 WMITLV_GET_STRUCT_TLVLEN(
3411 wmi_ocb_start_timing_advert_cmd_fixed_param));
3412 cmd->vdev_id = timing_advert->vdev_id;
3413 cmd->repeat_rate = timing_advert->repeat_rate;
3414 cmd->channel_freq = timing_advert->chan_freq;
3415 cmd->timestamp_offset = timing_advert->timestamp_offset;
3416 cmd->time_value_offset = timing_advert->time_value_offset;
3417 cmd->timing_advert_template_length = timing_advert->template_length;
3418 buf_ptr += sizeof(*cmd);
3419
3420 /* Add the timing advert template */
3421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3422 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303423 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303424 (uint8_t *)timing_advert->template_value,
3425 timing_advert->template_length);
3426
3427 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3428 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303429 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303430 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303431 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303432 }
3433
Govind Singh67922e82016-04-01 16:48:57 +05303434 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303435}
3436
3437/**
3438 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3439 * on a channel
3440 * @wmi_handle: pointer to the wmi handle
3441 * @timing_advert: pointer to the timing advertisement struct
3442 *
3443 * Return: 0 on succes
3444 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303445static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303446 struct ocb_timing_advert_param *timing_advert)
3447{
Govind Singh67922e82016-04-01 16:48:57 +05303448 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303449 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3450 uint8_t *buf_ptr;
3451 uint32_t len;
3452 wmi_buf_t buf;
3453
3454 len = sizeof(*cmd);
3455 buf = wmi_buf_alloc(wmi_handle, len);
3456 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303457 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303458 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303459 }
3460
3461 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3462 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3463 WMITLV_SET_HDR(&cmd->tlv_header,
3464 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3465 WMITLV_GET_STRUCT_TLVLEN(
3466 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3467 cmd->vdev_id = timing_advert->vdev_id;
3468 cmd->channel_freq = timing_advert->chan_freq;
3469
3470 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3471 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303472 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303473 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303474 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303475 }
3476
Govind Singh67922e82016-04-01 16:48:57 +05303477 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303478}
3479
3480/**
3481 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3482 * @wmi_handle: pointer to the wmi handle
3483 * @request: pointer to the request
3484 *
3485 * Return: 0 on succes
3486 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303487static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303488 uint8_t vdev_id)
3489{
Govind Singhb53420c2016-03-09 14:32:57 +05303490 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303491 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3492 uint8_t *buf_ptr;
3493 wmi_buf_t buf;
3494 int32_t len;
3495
3496 len = sizeof(*cmd);
3497 buf = wmi_buf_alloc(wmi_handle, len);
3498 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303499 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303500 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303501 }
3502 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3503
3504 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303505 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303506 WMITLV_SET_HDR(&cmd->tlv_header,
3507 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3508 WMITLV_GET_STRUCT_TLVLEN(
3509 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3510 cmd->vdev_id = vdev_id;
3511
3512 /* Send the WMI command */
3513 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3514 WMI_OCB_GET_TSF_TIMER_CMDID);
3515 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303516 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303517 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303518 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303519 }
3520
Govind Singh67922e82016-04-01 16:48:57 +05303521 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303522}
3523
3524/**
3525 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3526 * @wmi_handle: pointer to the wmi handle
3527 * @get_stats_param: pointer to the dcc stats
3528 *
3529 * Return: 0 on succes
3530 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303531static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303532 struct dcc_get_stats_param *get_stats_param)
3533{
Govind Singh67922e82016-04-01 16:48:57 +05303534 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303535 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3536 wmi_dcc_channel_stats_request *channel_stats_array;
3537 wmi_buf_t buf;
3538 uint8_t *buf_ptr;
3539 uint32_t len;
3540 uint32_t i;
3541
3542 /* Validate the input */
3543 if (get_stats_param->request_array_len !=
3544 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303545 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303546 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303547 }
3548
3549 /* Allocate memory for the WMI command */
3550 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3551 get_stats_param->request_array_len;
3552
3553 buf = wmi_buf_alloc(wmi_handle, len);
3554 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303555 WMI_LOGE(FL("wmi_buf_alloc failed"));
3556 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303557 }
3558
3559 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303560 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303561
3562 /* Populate the WMI command */
3563 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3564 buf_ptr += sizeof(*cmd);
3565
3566 WMITLV_SET_HDR(&cmd->tlv_header,
3567 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3568 WMITLV_GET_STRUCT_TLVLEN(
3569 wmi_dcc_get_stats_cmd_fixed_param));
3570 cmd->vdev_id = get_stats_param->vdev_id;
3571 cmd->num_channels = get_stats_param->channel_count;
3572
3573 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3574 get_stats_param->request_array_len);
3575 buf_ptr += WMI_TLV_HDR_SIZE;
3576
3577 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303578 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303579 get_stats_param->request_array_len);
3580 for (i = 0; i < cmd->num_channels; i++)
3581 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3582 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3583 WMITLV_GET_STRUCT_TLVLEN(
3584 wmi_dcc_channel_stats_request));
3585
3586 /* Send the WMI command */
3587 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3588 WMI_DCC_GET_STATS_CMDID);
3589
Govind Singh67922e82016-04-01 16:48:57 +05303590 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303591 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303592 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303593 }
3594
Govind Singh67922e82016-04-01 16:48:57 +05303595 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303596}
3597
3598/**
3599 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3600 * @wmi_handle: pointer to the wmi handle
3601 * @vdev_id: vdev id
3602 * @dcc_stats_bitmap: dcc status bitmap
3603 *
3604 * Return: 0 on succes
3605 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303606static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303607 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3608{
Govind Singh67922e82016-04-01 16:48:57 +05303609 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303610 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3611 wmi_buf_t buf;
3612 uint8_t *buf_ptr;
3613 uint32_t len;
3614
3615 /* Allocate memory for the WMI command */
3616 len = sizeof(*cmd);
3617
3618 buf = wmi_buf_alloc(wmi_handle, len);
3619 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303620 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303621 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303622 }
3623
3624 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303625 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303626
3627 /* Populate the WMI command */
3628 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3629
3630 WMITLV_SET_HDR(&cmd->tlv_header,
3631 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3632 WMITLV_GET_STRUCT_TLVLEN(
3633 wmi_dcc_clear_stats_cmd_fixed_param));
3634 cmd->vdev_id = vdev_id;
3635 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3636
3637 /* Send the WMI command */
3638 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3639 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303640 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303641 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303642 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303643 }
3644
Govind Singh67922e82016-04-01 16:48:57 +05303645 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303646}
3647
3648/**
3649 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3650 * @wmi_handle: pointer to the wmi handle
3651 * @update_ndl_param: pointer to the request parameters
3652 *
3653 * Return: 0 on success
3654 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303655static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303656 struct dcc_update_ndl_param *update_ndl_param)
3657{
Govind Singhb53420c2016-03-09 14:32:57 +05303658 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303659 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3660 wmi_dcc_ndl_chan *ndl_chan_array;
3661 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3662 uint32_t active_state_count;
3663 wmi_buf_t buf;
3664 uint8_t *buf_ptr;
3665 uint32_t len;
3666 uint32_t i;
3667
3668 /* validate the input */
3669 if (update_ndl_param->dcc_ndl_chan_list_len !=
3670 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303671 WMI_LOGE(FL("Invalid parameter"));
3672 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303673 }
3674 active_state_count = 0;
3675 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3676 for (i = 0; i < update_ndl_param->channel_count; i++)
3677 active_state_count +=
3678 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3679 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3680 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303681 WMI_LOGE(FL("Invalid parameter"));
3682 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303683 }
3684
3685 /* Allocate memory for the WMI command */
3686 len = sizeof(*cmd) +
3687 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3688 WMI_TLV_HDR_SIZE +
3689 update_ndl_param->dcc_ndl_active_state_list_len;
3690
3691 buf = wmi_buf_alloc(wmi_handle, len);
3692 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303693 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303694 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303695 }
3696
3697 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303698 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303699
3700 /* Populate the WMI command */
3701 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3702 buf_ptr += sizeof(*cmd);
3703
3704 WMITLV_SET_HDR(&cmd->tlv_header,
3705 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3706 WMITLV_GET_STRUCT_TLVLEN(
3707 wmi_dcc_update_ndl_cmd_fixed_param));
3708 cmd->vdev_id = update_ndl_param->vdev_id;
3709 cmd->num_channel = update_ndl_param->channel_count;
3710
3711 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3712 update_ndl_param->dcc_ndl_chan_list_len);
3713 buf_ptr += WMI_TLV_HDR_SIZE;
3714
3715 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303716 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303717 update_ndl_param->dcc_ndl_chan_list_len);
3718 for (i = 0; i < cmd->num_channel; i++)
3719 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3720 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3721 WMITLV_GET_STRUCT_TLVLEN(
3722 wmi_dcc_ndl_chan));
3723 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3724
3725 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3726 update_ndl_param->dcc_ndl_active_state_list_len);
3727 buf_ptr += WMI_TLV_HDR_SIZE;
3728
3729 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303730 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303731 update_ndl_param->dcc_ndl_active_state_list,
3732 update_ndl_param->dcc_ndl_active_state_list_len);
3733 for (i = 0; i < active_state_count; i++) {
3734 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3735 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3736 WMITLV_GET_STRUCT_TLVLEN(
3737 wmi_dcc_ndl_active_state_config));
3738 }
3739 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3740
3741 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303742 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303743 WMI_DCC_UPDATE_NDL_CMDID);
3744 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303745 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303747 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303748 }
3749
Govind Singh67922e82016-04-01 16:48:57 +05303750 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303751}
3752
3753/**
3754 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3755 * @wmi_handle: pointer to the wmi handle
3756 * @config: the OCB configuration
3757 *
3758 * Return: 0 on success
3759 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303760static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303761 struct ocb_config_param *config, uint32_t *ch_mhz)
3762{
Govind Singh67922e82016-04-01 16:48:57 +05303763 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303764 wmi_ocb_set_config_cmd_fixed_param *cmd;
3765 wmi_channel *chan;
3766 wmi_ocb_channel *ocb_chan;
3767 wmi_qos_parameter *qos_param;
3768 wmi_dcc_ndl_chan *ndl_chan;
3769 wmi_dcc_ndl_active_state_config *ndl_active_config;
3770 wmi_ocb_schedule_element *sched_elem;
3771 uint8_t *buf_ptr;
3772 wmi_buf_t buf;
3773 int32_t len;
3774 int32_t i, j, active_state_count;
3775
3776 /*
3777 * Validate the dcc_ndl_chan_list_len and count the number of active
3778 * states. Validate dcc_ndl_active_state_list_len.
3779 */
3780 active_state_count = 0;
3781 if (config->dcc_ndl_chan_list_len) {
3782 if (!config->dcc_ndl_chan_list ||
3783 config->dcc_ndl_chan_list_len !=
3784 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303785 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303786 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303787 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303788 }
3789
3790 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3791 i < config->channel_count; ++i, ++ndl_chan)
3792 active_state_count +=
3793 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3794
3795 if (active_state_count) {
3796 if (!config->dcc_ndl_active_state_list ||
3797 config->dcc_ndl_active_state_list_len !=
3798 active_state_count *
3799 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303800 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303801 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303802 }
3803 }
3804 }
3805
3806 len = sizeof(*cmd) +
3807 WMI_TLV_HDR_SIZE + config->channel_count *
3808 sizeof(wmi_channel) +
3809 WMI_TLV_HDR_SIZE + config->channel_count *
3810 sizeof(wmi_ocb_channel) +
3811 WMI_TLV_HDR_SIZE + config->channel_count *
3812 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3813 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3814 WMI_TLV_HDR_SIZE + active_state_count *
3815 sizeof(wmi_dcc_ndl_active_state_config) +
3816 WMI_TLV_HDR_SIZE + config->schedule_size *
3817 sizeof(wmi_ocb_schedule_element);
3818 buf = wmi_buf_alloc(wmi_handle, len);
3819 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303820 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303821 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303822 }
3823
3824 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3825 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3826 WMITLV_SET_HDR(&cmd->tlv_header,
3827 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3828 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3829 cmd->vdev_id = config->session_id;
3830 cmd->channel_count = config->channel_count;
3831 cmd->schedule_size = config->schedule_size;
3832 cmd->flags = config->flags;
3833 buf_ptr += sizeof(*cmd);
3834
3835 /* Add the wmi_channel info */
3836 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3837 config->channel_count*sizeof(wmi_channel));
3838 buf_ptr += WMI_TLV_HDR_SIZE;
3839 for (i = 0; i < config->channel_count; i++) {
3840 chan = (wmi_channel *)buf_ptr;
3841 WMITLV_SET_HDR(&chan->tlv_header,
3842 WMITLV_TAG_STRUC_wmi_channel,
3843 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3844 chan->mhz = config->channels[i].chan_freq;
3845 chan->band_center_freq1 = config->channels[i].chan_freq;
3846 chan->band_center_freq2 = 0;
3847 chan->info = 0;
3848
3849 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3850 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3851 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3852 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3853 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3854 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3855 config->channels[i].antenna_max);
3856
3857 if (config->channels[i].bandwidth < 10)
3858 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3859 else if (config->channels[i].bandwidth < 20)
3860 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3861 buf_ptr += sizeof(*chan);
3862 }
3863
3864 /* Add the wmi_ocb_channel info */
3865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3866 config->channel_count*sizeof(wmi_ocb_channel));
3867 buf_ptr += WMI_TLV_HDR_SIZE;
3868 for (i = 0; i < config->channel_count; i++) {
3869 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3870 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3871 WMITLV_TAG_STRUC_wmi_ocb_channel,
3872 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3873 ocb_chan->bandwidth = config->channels[i].bandwidth;
3874 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3875 config->channels[i].mac_address.bytes,
3876 &ocb_chan->mac_address);
3877 buf_ptr += sizeof(*ocb_chan);
3878 }
3879
3880 /* Add the wmi_qos_parameter info */
3881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3882 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3883 buf_ptr += WMI_TLV_HDR_SIZE;
3884 /* WMI_MAX_NUM_AC parameters for each channel */
3885 for (i = 0; i < config->channel_count; i++) {
3886 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3887 qos_param = (wmi_qos_parameter *)buf_ptr;
3888 WMITLV_SET_HDR(&qos_param->tlv_header,
3889 WMITLV_TAG_STRUC_wmi_qos_parameter,
3890 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3891 qos_param->aifsn =
3892 config->channels[i].qos_params[j].aifsn;
3893 qos_param->cwmin =
3894 config->channels[i].qos_params[j].cwmin;
3895 qos_param->cwmax =
3896 config->channels[i].qos_params[j].cwmax;
3897 buf_ptr += sizeof(*qos_param);
3898 }
3899 }
3900
3901 /* Add the wmi_dcc_ndl_chan (per channel) */
3902 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3903 config->dcc_ndl_chan_list_len);
3904 buf_ptr += WMI_TLV_HDR_SIZE;
3905 if (config->dcc_ndl_chan_list_len) {
3906 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303907 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303908 config->dcc_ndl_chan_list_len);
3909 for (i = 0; i < config->channel_count; i++)
3910 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3911 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3912 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3913 buf_ptr += config->dcc_ndl_chan_list_len;
3914 }
3915
3916 /* Add the wmi_dcc_ndl_active_state_config */
3917 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3918 sizeof(wmi_dcc_ndl_active_state_config));
3919 buf_ptr += WMI_TLV_HDR_SIZE;
3920 if (active_state_count) {
3921 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303922 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303923 config->dcc_ndl_active_state_list,
3924 active_state_count * sizeof(*ndl_active_config));
3925 for (i = 0; i < active_state_count; ++i)
3926 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3927 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3928 WMITLV_GET_STRUCT_TLVLEN(
3929 wmi_dcc_ndl_active_state_config));
3930 buf_ptr += active_state_count *
3931 sizeof(*ndl_active_config);
3932 }
3933
3934 /* Add the wmi_ocb_schedule_element info */
3935 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3936 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3937 buf_ptr += WMI_TLV_HDR_SIZE;
3938 for (i = 0; i < config->schedule_size; i++) {
3939 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3940 WMITLV_SET_HDR(&sched_elem->tlv_header,
3941 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3942 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3943 sched_elem->channel_freq = config->schedule[i].chan_freq;
3944 sched_elem->total_duration = config->schedule[i].total_duration;
3945 sched_elem->guard_interval = config->schedule[i].guard_interval;
3946 buf_ptr += sizeof(*sched_elem);
3947 }
3948
3949
3950 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3951 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303952 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303953 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303954 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303955 }
3956
Govind Singh67922e82016-04-01 16:48:57 +05303957 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303958}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303959
3960/**
3961 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3962 * @wmi_handle: wmi handle
3963 * @mcc_adaptive_scheduler: enable/disable
3964 *
3965 * This function enable/disable mcc adaptive scheduler in fw.
3966 *
Govind Singhb53420c2016-03-09 14:32:57 +05303967 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303968 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303969static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003970 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3971 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303972{
Govind Singh67922e82016-04-01 16:48:57 +05303973 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303974 wmi_buf_t buf = 0;
3975 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3976 uint16_t len =
3977 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3978
3979 buf = wmi_buf_alloc(wmi_handle, len);
3980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303981 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3982 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303983 }
3984 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3985 wmi_buf_data(buf);
3986
3987 WMITLV_SET_HDR(&cmd->tlv_header,
3988 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3989 WMITLV_GET_STRUCT_TLVLEN
3990 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3991 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303992 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303993
3994 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3995 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303996 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303997 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303998 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303999 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304000 }
Govind Singh67922e82016-04-01 16:48:57 +05304001
4002 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304003}
4004
4005/**
4006 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4007 * @wmi: wmi handle
4008 * @mcc_channel: mcc channel
4009 * @mcc_channel_time_latency: MCC channel time latency.
4010 *
4011 * Currently used to set time latency for an MCC vdev/adapter using operating
4012 * channel of it and channel number. The info is provided run time using
4013 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4014 *
4015 * Return: CDF status
4016 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304017static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304018 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4019{
Govind Singh67922e82016-04-01 16:48:57 +05304020 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304021 wmi_buf_t buf = 0;
4022 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4023 uint16_t len = 0;
4024 uint8_t *buf_ptr = NULL;
4025 wmi_resmgr_chan_latency chan_latency;
4026 /* Note: we only support MCC time latency for a single channel */
4027 uint32_t num_channels = 1;
4028 uint32_t chan1_freq = mcc_channel_freq;
4029 uint32_t latency_chan1 = mcc_channel_time_latency;
4030
4031
4032 /* If 0ms latency is provided, then FW will set to a default.
4033 * Otherwise, latency must be at least 30ms.
4034 */
4035 if ((latency_chan1 > 0) &&
4036 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304037 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304038 "Minimum is 30ms (or 0 to use default value by "
4039 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304040 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304041 }
4042
4043 /* Set WMI CMD for channel time latency here */
4044 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4045 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4046 num_channels * sizeof(wmi_resmgr_chan_latency);
4047 buf = wmi_buf_alloc(wmi_handle, len);
4048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304049 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4050 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304051 }
4052 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4053 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4054 wmi_buf_data(buf);
4055 WMITLV_SET_HDR(&cmdTL->tlv_header,
4056 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4057 WMITLV_GET_STRUCT_TLVLEN
4058 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4059 cmdTL->num_chans = num_channels;
4060 /* Update channel time latency information for home channel(s) */
4061 buf_ptr += sizeof(*cmdTL);
4062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4063 num_channels * sizeof(wmi_resmgr_chan_latency));
4064 buf_ptr += WMI_TLV_HDR_SIZE;
4065 chan_latency.chan_mhz = chan1_freq;
4066 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304067 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304068 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4069 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304070 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304071 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304072 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304073 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304074 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304075 }
Govind Singh67922e82016-04-01 16:48:57 +05304076
4077 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304078}
4079
4080/**
4081 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4082 * @wmi: wmi handle
4083 * @adapter_1_chan_number: adapter 1 channel number
4084 * @adapter_1_quota: adapter 1 quota
4085 * @adapter_2_chan_number: adapter 2 channel number
4086 *
4087 * Return: CDF status
4088 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304089static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304090 uint32_t adapter_1_chan_freq,
4091 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4092{
Govind Singh67922e82016-04-01 16:48:57 +05304093 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304094 wmi_buf_t buf = 0;
4095 uint16_t len = 0;
4096 uint8_t *buf_ptr = NULL;
4097 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4098 wmi_resmgr_chan_time_quota chan_quota;
4099 uint32_t quota_chan1 = adapter_1_quota;
4100 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4101 uint32_t quota_chan2 = 100 - quota_chan1;
4102 /* Note: setting time quota for MCC requires info for 2 channels */
4103 uint32_t num_channels = 2;
4104 uint32_t chan1_freq = adapter_1_chan_freq;
4105 uint32_t chan2_freq = adapter_2_chan_freq;
4106
Govind Singhb53420c2016-03-09 14:32:57 +05304107 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304108 "freq2:%dMHz, Quota2:%dms", __func__,
4109 chan1_freq, quota_chan1, chan2_freq,
4110 quota_chan2);
4111
4112 /*
4113 * Perform sanity check on time quota values provided.
4114 */
4115 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4116 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304117 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304118 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304119 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304120 }
4121 /* Set WMI CMD for channel time quota here */
4122 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4123 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4124 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4125 buf = wmi_buf_alloc(wmi_handle, len);
4126 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304127 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4128 QDF_ASSERT(0);
4129 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304130 }
4131 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4132 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4133 wmi_buf_data(buf);
4134 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4135 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4136 WMITLV_GET_STRUCT_TLVLEN
4137 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4138 cmdTQ->num_chans = num_channels;
4139
4140 /* Update channel time quota information for home channel(s) */
4141 buf_ptr += sizeof(*cmdTQ);
4142 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4143 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4144 buf_ptr += WMI_TLV_HDR_SIZE;
4145 chan_quota.chan_mhz = chan1_freq;
4146 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304147 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304148 /* Construct channel and quota record for the 2nd MCC mode. */
4149 buf_ptr += sizeof(chan_quota);
4150 chan_quota.chan_mhz = chan2_freq;
4151 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304152 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304153
4154 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4155 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304156 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304158 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304159 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304160 }
Govind Singh67922e82016-04-01 16:48:57 +05304161
4162 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304163}
4164
4165/**
4166 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4167 * @wmi_handle: Pointer to wmi handle
4168 * @thermal_info: Thermal command information
4169 *
4170 * This function sends the thermal management command
4171 * to the firmware
4172 *
Govind Singhb53420c2016-03-09 14:32:57 +05304173 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304174 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304175static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304176 struct thermal_cmd_params *thermal_info)
4177{
4178 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4179 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304180 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304181 uint32_t len = 0;
4182
4183 len = sizeof(*cmd);
4184
4185 buf = wmi_buf_alloc(wmi_handle, len);
4186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304187 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4188 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304189 }
4190
4191 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4192
4193 WMITLV_SET_HDR(&cmd->tlv_header,
4194 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4195 WMITLV_GET_STRUCT_TLVLEN
4196 (wmi_thermal_mgmt_cmd_fixed_param));
4197
4198 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4199 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4200 cmd->enable = thermal_info->thermal_enable;
4201
Govind Singhb53420c2016-03-09 14:32:57 +05304202 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304203 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4204
4205 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4206 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304207 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304208 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304209 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304210 }
4211
Govind Singh67922e82016-04-01 16:48:57 +05304212 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304213}
4214
4215
4216/**
4217 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304218 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304219 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4220 *
4221 * This function sends down the LRO configuration parameters to
4222 * the firmware to enable LRO, sets the TCP flags and sets the
4223 * seed values for the toeplitz hash generation
4224 *
Govind Singhb53420c2016-03-09 14:32:57 +05304225 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304226 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304227static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304228 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4229{
4230 wmi_lro_info_cmd_fixed_param *cmd;
4231 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304232 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304233
4234
4235 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304237 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4238 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304239 }
4240
4241 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4242
4243 WMITLV_SET_HDR(&cmd->tlv_header,
4244 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4245 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4246
4247 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4248 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4249 wmi_lro_cmd->tcp_flag);
4250 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4251 wmi_lro_cmd->tcp_flag_mask);
4252 cmd->toeplitz_hash_ipv4_0_3 =
4253 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4254 cmd->toeplitz_hash_ipv4_4_7 =
4255 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4256 cmd->toeplitz_hash_ipv4_8_11 =
4257 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4258 cmd->toeplitz_hash_ipv4_12_15 =
4259 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4260 cmd->toeplitz_hash_ipv4_16 =
4261 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4262
4263 cmd->toeplitz_hash_ipv6_0_3 =
4264 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4265 cmd->toeplitz_hash_ipv6_4_7 =
4266 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4267 cmd->toeplitz_hash_ipv6_8_11 =
4268 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4269 cmd->toeplitz_hash_ipv6_12_15 =
4270 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4271 cmd->toeplitz_hash_ipv6_16_19 =
4272 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4273 cmd->toeplitz_hash_ipv6_20_23 =
4274 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4275 cmd->toeplitz_hash_ipv6_24_27 =
4276 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4277 cmd->toeplitz_hash_ipv6_28_31 =
4278 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4279 cmd->toeplitz_hash_ipv6_32_35 =
4280 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4281 cmd->toeplitz_hash_ipv6_36_39 =
4282 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4283 cmd->toeplitz_hash_ipv6_40 =
4284 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4285
Govind Singhb53420c2016-03-09 14:32:57 +05304286 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304287 cmd->lro_enable, cmd->tcp_flag_u32);
4288
4289 status = wmi_unified_cmd_send(wmi_handle, buf,
4290 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304291 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304292 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304293 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304294 }
4295
Govind Singh67922e82016-04-01 16:48:57 +05304296 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304297}
4298
Govind Singh4eacd2b2016-03-07 14:24:22 +05304299/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304300 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4301 * @wmi_handle: Pointer to wmi handle
4302 * @rate_report_params: Pointer to peer rate report parameters
4303 *
4304 *
4305 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4306 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304307static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304308 struct wmi_peer_rate_report_params *rate_report_params)
4309{
4310 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4311 wmi_buf_t buf = NULL;
4312 QDF_STATUS status = 0;
4313 uint32_t len = 0;
4314 uint32_t i, j;
4315
4316 len = sizeof(*cmd);
4317
4318 buf = wmi_buf_alloc(wmi_handle, len);
4319 if (!buf) {
4320 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4321 return QDF_STATUS_E_FAILURE;
4322 }
4323
4324 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4325 wmi_buf_data(buf);
4326
4327 WMITLV_SET_HDR(
4328 &cmd->tlv_header,
4329 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4330 WMITLV_GET_STRUCT_TLVLEN(
4331 wmi_peer_set_rate_report_condition_fixed_param));
4332
4333 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4334 cmd->report_backoff_time = rate_report_params->backoff_time;
4335 cmd->report_timer_period = rate_report_params->timer_period;
4336 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4337 cmd->cond_per_phy[i].val_cond_flags =
4338 rate_report_params->report_per_phy[i].cond_flags;
4339 cmd->cond_per_phy[i].rate_delta.min_delta =
4340 rate_report_params->report_per_phy[i].delta.delta_min;
4341 cmd->cond_per_phy[i].rate_delta.percentage =
4342 rate_report_params->report_per_phy[i].delta.percent;
4343 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4344 cmd->cond_per_phy[i].rate_threshold[j] =
4345 rate_report_params->report_per_phy[i].
4346 report_rate_threshold[j];
4347 }
4348 }
4349
4350 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4351 cmd->enable_rate_report,
4352 cmd->report_backoff_time, cmd->report_timer_period);
4353
4354 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4355 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4356 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304357 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304358 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4359 __func__);
4360 }
4361 return status;
4362}
4363
4364/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304365 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4366 * @wmi_handle: wmi handle
4367 * @param: bcn ll cmd parameter
4368 *
Govind Singhb53420c2016-03-09 14:32:57 +05304369 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304370 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304371static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304372 wmi_bcn_send_from_host_cmd_fixed_param *param)
4373{
4374 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4375 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304376 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304377
4378 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4379 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304380 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4381 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304382 }
4383
4384 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4385 WMITLV_SET_HDR(&cmd->tlv_header,
4386 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4387 WMITLV_GET_STRUCT_TLVLEN
4388 (wmi_bcn_send_from_host_cmd_fixed_param));
4389 cmd->vdev_id = param->vdev_id;
4390 cmd->data_len = param->data_len;
4391 cmd->frame_ctrl = param->frame_ctrl;
4392 cmd->frag_ptr = param->frag_ptr;
4393 cmd->dtim_flag = param->dtim_flag;
4394
4395 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4396 WMI_PDEV_SEND_BCN_CMDID);
4397
Govind Singh67922e82016-04-01 16:48:57 +05304398 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304399 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304400 wmi_buf_free(wmi_buf);
4401 }
4402
4403 return ret;
4404}
4405
4406/**
4407 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4408 * @wmi_handle: wmi handle
4409 * @vdev_id: vdev id
4410 * @max_retries: max retries
4411 * @retry_interval: retry interval
4412 * This function sets sta query related parameters in fw.
4413 *
Govind Singhb53420c2016-03-09 14:32:57 +05304414 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415 */
4416
Sathish Kumarfd347372017-02-13 12:29:09 +05304417static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304418 uint8_t vdev_id, uint32_t max_retries,
4419 uint32_t retry_interval)
4420{
4421 wmi_buf_t buf;
4422 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4423 int len;
4424
4425 len = sizeof(*cmd);
4426 buf = wmi_buf_alloc(wmi_handle, len);
4427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304428 WMI_LOGE(FL("wmi_buf_alloc failed"));
4429 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304430 }
4431
4432 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4433 WMITLV_SET_HDR(&cmd->tlv_header,
4434 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4435 WMITLV_GET_STRUCT_TLVLEN
4436 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4437
4438
4439 cmd->vdev_id = vdev_id;
4440 cmd->sa_query_max_retry_count = max_retries;
4441 cmd->sa_query_retry_interval = retry_interval;
4442
Govind Singhb53420c2016-03-09 14:32:57 +05304443 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304444 vdev_id, retry_interval, max_retries);
4445
4446 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4447 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304448 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304449 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304450 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304451 }
4452
Govind Singhb53420c2016-03-09 14:32:57 +05304453 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304454 return 0;
4455}
4456
4457/**
4458 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4459 * @wmi_handle: wmi handle
4460 * @params: sta keep alive parameter
4461 *
4462 * This function sets keep alive related parameters in fw.
4463 *
4464 * Return: CDF status
4465 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304466static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304467 struct sta_params *params)
4468{
4469 wmi_buf_t buf;
4470 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4471 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4472 uint8_t *buf_ptr;
4473 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304474 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304475
Govind Singhb53420c2016-03-09 14:32:57 +05304476 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304477
Govind Singh4eacd2b2016-03-07 14:24:22 +05304478 len = sizeof(*cmd) + sizeof(*arp_rsp);
4479 buf = wmi_buf_alloc(wmi_handle, len);
4480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304481 WMI_LOGE("wmi_buf_alloc failed");
4482 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304483 }
4484
4485 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4486 buf_ptr = (uint8_t *) cmd;
4487 WMITLV_SET_HDR(&cmd->tlv_header,
4488 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4489 WMITLV_GET_STRUCT_TLVLEN
4490 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4491 cmd->interval = params->timeperiod;
4492 cmd->enable = (params->timeperiod) ? 1 : 0;
4493 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304494 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304495 params->timeperiod, params->method);
4496 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4497 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4498 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4499 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4500
4501 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4502 if ((NULL == params->hostv4addr) ||
4503 (NULL == params->destv4addr) ||
4504 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304505 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304506 "destv4addr:%p destmac:%p ", __func__,
4507 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304508 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304509 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304510 }
4511 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304512 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304513 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304514 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304515 WMI_IPV4_ADDR_LEN);
4516 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4517 } else {
4518 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4519 }
4520
Govind Singh67922e82016-04-01 16:48:57 +05304521 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4522 WMI_STA_KEEPALIVE_CMDID);
4523 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304524 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304525 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304526 }
4527
Govind Singhb53420c2016-03-09 14:32:57 +05304528 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304529 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304530}
4531
4532/**
4533 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4534 * @wmi_handle: wmi handle
4535 * @if_id: vdev id
4536 * @gtx_info: GTX config params
4537 *
4538 * This function set GTX related params in firmware.
4539 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304540 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304542static 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 +05304543 struct wmi_gtx_config *gtx_info)
4544{
4545 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4546 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304547 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304548 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304549
Govind Singh4eacd2b2016-03-07 14:24:22 +05304550 buf = wmi_buf_alloc(wmi_handle, len);
4551 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304552 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304553 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304554 }
4555 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4556 WMITLV_SET_HDR(&cmd->tlv_header,
4557 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4558 WMITLV_GET_STRUCT_TLVLEN
4559 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4560 cmd->vdev_id = if_id;
4561
4562 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4563 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4564 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4565 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4566 cmd->gtxPERMargin = gtx_info->gtx_margin;
4567 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4568 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4569 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4570
Govind Singhb53420c2016-03-09 14:32:57 +05304571 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304572 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4573 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4574 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4575 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4576
Abhishek Singh716c46c2016-05-04 16:24:07 +05304577 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304578 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304579 if (QDF_IS_STATUS_ERROR(ret)) {
4580 WMI_LOGE("Failed to set GTX PARAMS");
4581 wmi_buf_free(buf);
4582 }
4583 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304584}
4585
4586/**
4587 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4588 * @wmi_handle: wmi handle
4589 * @edca_params: edca parameters
4590 *
4591 * This function updates EDCA parameters to the target
4592 *
4593 * Return: CDF Status
4594 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304595static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596 uint8_t vdev_id,
4597 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4598{
4599 uint8_t *buf_ptr;
4600 wmi_buf_t buf;
4601 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4602 wmi_wmm_vparams *wmm_param, *twmm_param;
4603 int len = sizeof(*cmd);
4604 int ac;
4605
4606 buf = wmi_buf_alloc(wmi_handle, len);
4607
4608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304609 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4610 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304611 }
4612
4613 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4614 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4615 WMITLV_SET_HDR(&cmd->tlv_header,
4616 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4617 WMITLV_GET_STRUCT_TLVLEN
4618 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4619 cmd->vdev_id = vdev_id;
4620
4621 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4622 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4623 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4624 WMITLV_SET_HDR(&wmm_param->tlv_header,
4625 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4626 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4627 wmm_param->cwmin = twmm_param->cwmin;
4628 wmm_param->cwmax = twmm_param->cwmax;
4629 wmm_param->aifs = twmm_param->aifs;
4630 wmm_param->txoplimit = twmm_param->txoplimit;
4631 wmm_param->acm = twmm_param->acm;
4632 wmm_param->no_ack = twmm_param->no_ack;
4633 }
4634
4635 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4636 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4637 goto fail;
4638
Govind Singhb53420c2016-03-09 14:32:57 +05304639 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304640
4641fail:
4642 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304643 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4644 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304645}
4646
4647/**
4648 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4649 * @wmi_handle: wmi handle
4650 * @vdev_id: vdev id
4651 * @probe_rsp_info: probe response info
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_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304656 uint8_t vdev_id,
4657 struct wmi_probe_resp_params *probe_rsp_info,
4658 uint8_t *frm)
4659{
4660 wmi_prb_tmpl_cmd_fixed_param *cmd;
4661 wmi_bcn_prb_info *bcn_prb_info;
4662 wmi_buf_t wmi_buf;
4663 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4664 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304665 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304666
Govind Singhb53420c2016-03-09 14:32:57 +05304667 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304668
4669 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4670 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4671
4672 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4673 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4674 tmpl_len_aligned;
4675
4676 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304677 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304678 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304679 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304680 }
4681
4682 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4683 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304684 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304685 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304686 }
4687
4688 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4689
4690 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4691 WMITLV_SET_HDR(&cmd->tlv_header,
4692 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4693 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4694 cmd->vdev_id = vdev_id;
4695 cmd->buf_len = tmpl_len;
4696 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4697
4698 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4699 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4700 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4701 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4702 bcn_prb_info->caps = 0;
4703 bcn_prb_info->erp = 0;
4704 buf_ptr += sizeof(wmi_bcn_prb_info);
4705
4706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4707 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304708 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304709
4710 ret = wmi_unified_cmd_send(wmi_handle,
4711 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304712 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304713 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304714 wmi_buf_free(wmi_buf);
4715 }
4716
4717 return ret;
4718}
4719
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304720#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304721#define WPI_IV_LEN 16
4722
4723/**
4724 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4725 *
4726 * @dest_tx: destination address of tsc key counter
4727 * @src_tx: source address of tsc key counter
4728 * @dest_rx: destination address of rsc key counter
4729 * @src_rx: source address of rsc key counter
4730 *
4731 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4732 *
4733 * Return: None
4734 *
4735 */
4736static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4737 uint8_t *dest_rx, uint8_t *src_rx)
4738{
4739 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4740 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4741}
4742#else
4743static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4744 uint8_t *dest_rx, uint8_t *src_rx)
4745{
4746 return;
4747}
4748#endif
4749
4750/**
4751 * send_setup_install_key_cmd_tlv() - set key parameters
4752 * @wmi_handle: wmi handle
4753 * @key_params: key parameters
4754 *
4755 * This function fills structure from information
4756 * passed in key_params.
4757 *
4758 * Return: QDF_STATUS_SUCCESS - success
4759 * QDF_STATUS_E_FAILURE - failure
4760 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4761 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304762static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304763 struct set_key_params *key_params)
4764{
4765 wmi_vdev_install_key_cmd_fixed_param *cmd;
4766 wmi_buf_t buf;
4767 uint8_t *buf_ptr;
4768 uint32_t len;
4769 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304770 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304771
4772 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4773 WMI_TLV_HDR_SIZE;
4774
4775 buf = wmi_buf_alloc(wmi_handle, len);
4776 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304777 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304778 return QDF_STATUS_E_NOMEM;
4779 }
4780
4781 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4782 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4783 WMITLV_SET_HDR(&cmd->tlv_header,
4784 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4785 WMITLV_GET_STRUCT_TLVLEN
4786 (wmi_vdev_install_key_cmd_fixed_param));
4787 cmd->vdev_id = key_params->vdev_id;
4788 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304789
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304790
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304791 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4792 cmd->key_flags |= key_params->key_flags;
4793 cmd->key_cipher = key_params->key_cipher;
4794 if ((key_params->key_txmic_len) &&
4795 (key_params->key_rxmic_len)) {
4796 cmd->key_txmic_len = key_params->key_txmic_len;
4797 cmd->key_rxmic_len = key_params->key_rxmic_len;
4798 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304799#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304800 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4801 key_params->tx_iv,
4802 cmd->wpi_key_rsc_counter,
4803 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304804#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304805 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4807 roundup(key_params->key_len, sizeof(uint32_t)));
4808 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4809 qdf_mem_copy((void *)key_data,
4810 (const void *)key_params->key_data, key_params->key_len);
4811 cmd->key_len = key_params->key_len;
4812
4813 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4814 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304815 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304816 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304817
Govind Singh67922e82016-04-01 16:48:57 +05304818 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304819}
4820
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304821/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004822 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4823 * @wmi_handle: wmi handle
4824 * @params: sar limit params
4825 *
4826 * Return: QDF_STATUS_SUCCESS for success or error code
4827 */
4828static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4829 struct sar_limit_cmd_params *sar_limit_params)
4830{
4831 wmi_buf_t buf;
4832 QDF_STATUS qdf_status;
4833 wmi_sar_limits_cmd_fixed_param *cmd;
4834 int i;
4835 uint8_t *buf_ptr;
4836 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4837 struct sar_limit_cmd_row *sar_rows_list;
4838 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4839
4840 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4841 buf = wmi_buf_alloc(wmi_handle, len);
4842 if (!buf) {
4843 WMI_LOGE("Failed to allocate memory");
4844 qdf_status = QDF_STATUS_E_NOMEM;
4845 goto end;
4846 }
4847
4848 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4849 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4850 WMITLV_SET_HDR(&cmd->tlv_header,
4851 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4852 WMITLV_GET_STRUCT_TLVLEN
4853 (wmi_sar_limits_cmd_fixed_param));
4854 cmd->sar_enable = sar_limit_params->sar_enable;
4855 cmd->commit_limits = sar_limit_params->commit_limits;
4856 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4857
4858 WMI_LOGD("no of sar rows = %d, len = %d",
4859 sar_limit_params->num_limit_rows, len);
4860 buf_ptr += sizeof(*cmd);
4861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4862 sizeof(wmi_sar_limit_cmd_row) *
4863 sar_limit_params->num_limit_rows);
4864 if (cmd->num_limit_rows == 0)
4865 goto send_sar_limits;
4866
4867 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4868 (buf_ptr + WMI_TLV_HDR_SIZE);
4869 sar_rows_list = sar_limit_params->sar_limit_row_list;
4870
4871 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4872 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4873 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4874 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4875 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4876 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4877 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4878 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4879 wmi_sar_rows_list->validity_bitmap =
4880 sar_rows_list->validity_bitmap;
4881 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4882 i, wmi_sar_rows_list->band_id,
4883 wmi_sar_rows_list->chain_id,
4884 wmi_sar_rows_list->mod_id,
4885 wmi_sar_rows_list->limit_value,
4886 wmi_sar_rows_list->validity_bitmap);
4887 sar_rows_list++;
4888 wmi_sar_rows_list++;
4889 }
4890send_sar_limits:
4891 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4892 WMI_SAR_LIMITS_CMDID);
4893
4894 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4895 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4896 wmi_buf_free(buf);
4897 }
4898
4899end:
4900 return qdf_status;
4901}
4902
4903/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304904 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4905 * @wmi_handle: wmi handle
4906 * @params: encrypt/decrypt params
4907 *
4908 * Return: QDF_STATUS_SUCCESS for success or error code
4909 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004910static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304911QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4912 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4913{
4914 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4915 wmi_buf_t wmi_buf;
4916 uint8_t *buf_ptr;
4917 QDF_STATUS ret;
4918 uint32_t len;
4919
4920 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4921
4922 len = sizeof(*cmd) +
4923 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4924 WMI_TLV_HDR_SIZE;
4925 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4926 if (!wmi_buf) {
4927 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4928 __func__);
4929 return QDF_STATUS_E_NOMEM;
4930 }
4931
4932 buf_ptr = wmi_buf_data(wmi_buf);
4933 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4934
4935 WMITLV_SET_HDR(&cmd->tlv_header,
4936 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4937 WMITLV_GET_STRUCT_TLVLEN(
4938 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4939
4940 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4941 cmd->key_flag = encrypt_decrypt_params->key_flag;
4942 cmd->key_idx = encrypt_decrypt_params->key_idx;
4943 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4944 cmd->key_len = encrypt_decrypt_params->key_len;
4945 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4946 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4947
4948 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4949 encrypt_decrypt_params->key_len);
4950
4951 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4952 MAX_MAC_HEADER_LEN);
4953
4954 cmd->data_len = encrypt_decrypt_params->data_len;
4955
4956 if (cmd->data_len) {
4957 buf_ptr += sizeof(*cmd);
4958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4959 roundup(encrypt_decrypt_params->data_len,
4960 sizeof(A_UINT32)));
4961 buf_ptr += WMI_TLV_HDR_SIZE;
4962 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4963 encrypt_decrypt_params->data_len);
4964 }
4965
4966 /* This conversion is to facilitate data to FW in little endian */
4967 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4968 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4969 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4970 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4971 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4972 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4973
4974 ret = wmi_unified_cmd_send(wmi_handle,
4975 wmi_buf, len,
4976 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4977 if (QDF_IS_STATUS_ERROR(ret)) {
4978 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4979 wmi_buf_free(wmi_buf);
4980 }
4981
4982 return ret;
4983}
4984
4985
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304986
Govind Singh4eacd2b2016-03-07 14:24:22 +05304987/**
4988 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4989 * @wmi_handle: wmi handle
4990 * @vdev_id: vdev id
4991 * @p2p_ie: p2p IE
4992 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304993 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304995static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304996 A_UINT32 vdev_id, uint8_t *p2p_ie)
4997{
Govind Singh67922e82016-04-01 16:48:57 +05304998 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304999 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5000 wmi_buf_t wmi_buf;
5001 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5002 uint8_t *buf_ptr;
5003
5004 ie_len = (uint32_t) (p2p_ie[1] + 2);
5005
5006 /* More than one P2P IE may be included in a single frame.
5007 If multiple P2P IEs are present, the complete P2P attribute
5008 data consists of the concatenation of the P2P Attribute
5009 fields of the P2P IEs. The P2P Attributes field of each
5010 P2P IE may be any length up to the maximum (251 octets).
5011 In this case host sends one P2P IE to firmware so the length
5012 should not exceed more than 251 bytes
5013 */
5014 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305015 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305016 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305017 }
5018
5019 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5020
5021 wmi_buf_len =
5022 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5023 WMI_TLV_HDR_SIZE;
5024
5025 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5026 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305027 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305028 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305029 }
5030
5031 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5032
5033 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5034 WMITLV_SET_HDR(&cmd->tlv_header,
5035 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5036 WMITLV_GET_STRUCT_TLVLEN
5037 (wmi_p2p_go_set_beacon_ie_fixed_param));
5038 cmd->vdev_id = vdev_id;
5039 cmd->ie_buf_len = ie_len;
5040
5041 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5042 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5043 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305044 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305045
Govind Singhb53420c2016-03-09 14:32:57 +05305046 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305047
5048 ret = wmi_unified_cmd_send(wmi_handle,
5049 wmi_buf, wmi_buf_len,
5050 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305051 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305052 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305053 wmi_buf_free(wmi_buf);
5054 }
5055
Govind Singhb53420c2016-03-09 14:32:57 +05305056 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305057 return ret;
5058}
5059
5060/**
5061 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5062 * @wmi_handle: wmi handle
5063 * @req: gateway parameter update request structure
5064 *
5065 * This function reads the incoming @req and fill in the destination
5066 * WMI structure and sends down the gateway configs down to the firmware
5067 *
Govind Singhb53420c2016-03-09 14:32:57 +05305068 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305069 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305070static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305071 struct gateway_update_req_param *req)
5072{
5073 wmi_roam_subnet_change_config_fixed_param *cmd;
5074 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305075 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305076 int len = sizeof(*cmd);
5077
5078 buf = wmi_buf_alloc(wmi_handle, len);
5079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305080 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5081 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305082 }
5083
5084 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5085 WMITLV_SET_HDR(&cmd->tlv_header,
5086 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5087 WMITLV_GET_STRUCT_TLVLEN(
5088 wmi_roam_subnet_change_config_fixed_param));
5089
5090 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305091 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5092 QDF_IPV4_ADDR_SIZE);
5093 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5094 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5096 &cmd->inet_gw_mac_addr);
5097 cmd->max_retries = req->max_retries;
5098 cmd->timeout = req->timeout;
5099 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5100 cmd->flag = 0;
5101 if (req->ipv4_addr_type)
5102 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5103
5104 if (req->ipv6_addr_type)
5105 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5106
5107 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5108 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305109 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305110 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305111 ret);
5112 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113 }
5114
Govind Singh67922e82016-04-01 16:48:57 +05305115 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305116}
5117
5118/**
5119 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5120 * @wmi_handle: wmi handle
5121 * @req: rssi monitoring request structure
5122 *
5123 * This function reads the incoming @req and fill in the destination
5124 * WMI structure and send down the rssi monitoring configs down to the firmware
5125 *
5126 * Return: 0 on success; error number otherwise
5127 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305128static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 struct rssi_monitor_param *req)
5130{
5131 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5132 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305133 QDF_STATUS ret;
5134 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305135
5136 buf = wmi_buf_alloc(wmi_handle, len);
5137 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305138 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5139 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305140 }
5141
5142 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5143 WMITLV_SET_HDR(&cmd->tlv_header,
5144 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5145 WMITLV_GET_STRUCT_TLVLEN(
5146 wmi_rssi_breach_monitor_config_fixed_param));
5147
5148 cmd->vdev_id = req->session_id;
5149 cmd->request_id = req->request_id;
5150 cmd->lo_rssi_reenable_hysteresis = 0;
5151 cmd->hi_rssi_reenable_histeresis = 0;
5152 cmd->min_report_interval = 0;
5153 cmd->max_num_report = 1;
5154 if (req->control) {
5155 /* enable one threshold for each min/max */
5156 cmd->enabled_bitmap = 0x09;
5157 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5158 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5159 } else {
5160 cmd->enabled_bitmap = 0;
5161 cmd->low_rssi_breach_threshold[0] = 0;
5162 cmd->hi_rssi_breach_threshold[0] = 0;
5163 }
5164
5165 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5166 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305167 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305168 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305169 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305170 }
5171
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005172 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5173
Govind Singh67922e82016-04-01 16:48:57 +05305174 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305175}
5176
5177/**
5178 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5179 * @wmi_handle: wmi handle
5180 * @psetoui: OUI parameters
5181 *
5182 * set scan probe OUI parameters in firmware
5183 *
5184 * Return: CDF status
5185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305186static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305187 struct scan_mac_oui *psetoui)
5188{
5189 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5190 wmi_buf_t wmi_buf;
5191 uint32_t len;
5192 uint8_t *buf_ptr;
5193 uint32_t *oui_buf;
5194
5195 len = sizeof(*cmd);
5196 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5197 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305198 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5199 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305200 }
5201 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5202 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5203 WMITLV_SET_HDR(&cmd->tlv_header,
5204 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5205 WMITLV_GET_STRUCT_TLVLEN
5206 (wmi_scan_prob_req_oui_cmd_fixed_param));
5207
5208 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305209 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305210 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5211 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305212 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305213 cmd->prob_req_oui);
5214
5215 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5216 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305217 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305218 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305219 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 }
Govind Singhb53420c2016-03-09 14:32:57 +05305221 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305222}
5223
5224/**
5225 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5226 * @wmi_handle: wmi handle
5227 * @req: passpoint network request structure
5228 *
5229 * This function sends down WMI command with network id set to wildcard id.
5230 * firmware shall clear all the config entries
5231 *
Govind Singhb53420c2016-03-09 14:32:57 +05305232 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305234static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305235 struct wifi_passpoint_req_param *req)
5236{
5237 wmi_passpoint_config_cmd_fixed_param *cmd;
5238 wmi_buf_t buf;
5239 uint32_t len;
5240 int ret;
5241
5242 len = sizeof(*cmd);
5243 buf = wmi_buf_alloc(wmi_handle, len);
5244 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305245 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5246 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247 }
5248
5249 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5250
5251 WMITLV_SET_HDR(&cmd->tlv_header,
5252 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5253 WMITLV_GET_STRUCT_TLVLEN(
5254 wmi_passpoint_config_cmd_fixed_param));
5255 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5256
5257 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5258 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5259 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305260 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 __func__);
5262 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305263 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264 }
5265
Govind Singhb53420c2016-03-09 14:32:57 +05305266 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267}
5268
5269/**
5270 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5271 * @wmi_handle: wmi handle
5272 * @req: passpoint network request structure
5273 *
5274 * This function reads the incoming @req and fill in the destination
5275 * WMI structure and send down the passpoint configs down to the firmware
5276 *
Govind Singhb53420c2016-03-09 14:32:57 +05305277 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305278 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305279static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305280 struct wifi_passpoint_req_param *req)
5281{
5282 wmi_passpoint_config_cmd_fixed_param *cmd;
5283 u_int8_t i, j, *bytes;
5284 wmi_buf_t buf;
5285 uint32_t len;
5286 int ret;
5287
5288 len = sizeof(*cmd);
5289 for (i = 0; i < req->num_networks; i++) {
5290 buf = wmi_buf_alloc(wmi_handle, len);
5291 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305292 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5293 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305294 }
5295
5296 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5297 wmi_buf_data(buf);
5298
5299 WMITLV_SET_HDR(&cmd->tlv_header,
5300 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5301 WMITLV_GET_STRUCT_TLVLEN(
5302 wmi_passpoint_config_cmd_fixed_param));
5303 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305304 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5305 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305306 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305307 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5309 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305310 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305311 j, bytes[0], bytes[1], bytes[2], bytes[3],
5312 bytes[4], bytes[5], bytes[6], bytes[7]);
5313
Govind Singhb53420c2016-03-09 14:32:57 +05305314 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305315 &req->networks[i].roaming_consortium_ids[j],
5316 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5317 }
Govind Singhb53420c2016-03-09 14:32:57 +05305318 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305319 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305320 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305321 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5322
5323 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5324 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5325 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305326 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305327 __func__);
5328 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305329 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305330 }
5331 }
5332
Govind Singhb53420c2016-03-09 14:32:57 +05305333 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305334}
5335
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305336/**
5337 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5338 * @wmi_handle: wmi handle
5339 * @scan_cmd_fp: start scan command ptr
5340 * @roam_req: roam request param
5341 *
5342 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5343 * of WMI_ROAM_SCAN_MODE.
5344 *
5345 * Return: QDF status
5346 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305347static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305348 wmi_start_scan_cmd_fixed_param *
5349 scan_cmd_fp,
5350 struct roam_offload_scan_params *roam_req)
5351{
5352 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305353 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305354 int len;
5355 uint8_t *buf_ptr;
5356 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305357
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305358#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5359 int auth_mode = roam_req->auth_mode;
5360 wmi_roam_offload_tlv_param *roam_offload_params;
5361 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5362 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5363 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305364 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305365#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5366 /* Need to create a buf with roam_scan command at
5367 * front and piggyback with scan command */
5368 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5369#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5370 (2 * WMI_TLV_HDR_SIZE) +
5371#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5372 sizeof(wmi_start_scan_cmd_fixed_param);
5373#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5374 if (roam_req->is_roam_req_valid &&
5375 roam_req->roam_offload_enabled) {
5376 len += sizeof(wmi_roam_offload_tlv_param);
5377 len += WMI_TLV_HDR_SIZE;
5378 if ((auth_mode != WMI_AUTH_NONE) &&
5379 ((auth_mode != WMI_AUTH_OPEN) ||
5380 (auth_mode == WMI_AUTH_OPEN &&
5381 roam_req->mdid.mdie_present) ||
5382 roam_req->is_ese_assoc)) {
5383 len += WMI_TLV_HDR_SIZE;
5384 if (roam_req->is_ese_assoc)
5385 len +=
5386 sizeof(wmi_roam_ese_offload_tlv_param);
5387 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5388 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5389 (auth_mode == WMI_AUTH_OPEN &&
5390 roam_req->mdid.mdie_present))
5391 len +=
5392 sizeof(wmi_roam_11r_offload_tlv_param);
5393 else
5394 len +=
5395 sizeof(wmi_roam_11i_offload_tlv_param);
5396 } else {
5397 len += WMI_TLV_HDR_SIZE;
5398 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305399
5400 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5401 + roundup(roam_req->assoc_ie_length,
5402 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305403 } else {
5404 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305405 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305406 __func__, roam_req->roam_offload_enabled);
5407 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305408 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305409 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305410 }
5411 if (roam_req->is_roam_req_valid &&
5412 roam_req->roam_offload_enabled) {
5413 roam_req->mode = roam_req->mode |
5414 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5415 }
5416#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5417
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305418 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5419 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5420 len = sizeof(wmi_roam_scan_mode_fixed_param);
5421
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305422 buf = wmi_buf_alloc(wmi_handle, len);
5423 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305424 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305425 return QDF_STATUS_E_NOMEM;
5426 }
5427
5428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305429
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305430 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5431 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5432 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5433 WMITLV_GET_STRUCT_TLVLEN
5434 (wmi_roam_scan_mode_fixed_param));
5435
5436 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5437 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305438 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5439 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5440 roam_scan_mode_fp->flags |=
5441 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305442 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305443 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305444
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305445 /* Fill in scan parameters suitable for roaming scan */
5446 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305447
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305448 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5449 sizeof(wmi_start_scan_cmd_fixed_param));
5450 /* Ensure there is no additional IEs */
5451 scan_cmd_fp->ie_len = 0;
5452 WMITLV_SET_HDR(buf_ptr,
5453 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5454 WMITLV_GET_STRUCT_TLVLEN
5455 (wmi_start_scan_cmd_fixed_param));
5456#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5457 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5458 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5459 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5460 sizeof(wmi_roam_offload_tlv_param));
5461 buf_ptr += WMI_TLV_HDR_SIZE;
5462 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5463 WMITLV_SET_HDR(buf_ptr,
5464 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5465 WMITLV_GET_STRUCT_TLVLEN
5466 (wmi_roam_offload_tlv_param));
5467 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5468 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5469 roam_offload_params->select_5g_margin =
5470 roam_req->select_5ghz_margin;
5471 roam_offload_params->reassoc_failure_timeout =
5472 roam_req->reassoc_failure_timeout;
5473
5474 /* Fill the capabilities */
5475 roam_offload_params->capability =
5476 roam_req->roam_offload_params.capability;
5477 roam_offload_params->ht_caps_info =
5478 roam_req->roam_offload_params.ht_caps_info;
5479 roam_offload_params->ampdu_param =
5480 roam_req->roam_offload_params.ampdu_param;
5481 roam_offload_params->ht_ext_cap =
5482 roam_req->roam_offload_params.ht_ext_cap;
5483 roam_offload_params->ht_txbf =
5484 roam_req->roam_offload_params.ht_txbf;
5485 roam_offload_params->asel_cap =
5486 roam_req->roam_offload_params.asel_cap;
5487 roam_offload_params->qos_caps =
5488 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005489 roam_offload_params->qos_enabled =
5490 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305491 roam_offload_params->wmm_caps =
5492 roam_req->roam_offload_params.wmm_caps;
5493 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5494 (uint8_t *)roam_req->roam_offload_params.mcsset,
5495 ROAM_OFFLOAD_NUM_MCS_SET);
5496
5497 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5498 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5499 * they are filled in the same order.Depending on the
5500 * authentication type, the other mode TLV's are nullified
5501 * and only headers are filled.*/
5502 if ((auth_mode != WMI_AUTH_NONE) &&
5503 ((auth_mode != WMI_AUTH_OPEN) ||
5504 (auth_mode == WMI_AUTH_OPEN
5505 && roam_req->mdid.mdie_present) ||
5506 roam_req->is_ese_assoc)) {
5507 if (roam_req->is_ese_assoc) {
5508 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5509 WMITLV_GET_STRUCT_TLVLEN(0));
5510 buf_ptr += WMI_TLV_HDR_SIZE;
5511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5512 WMITLV_GET_STRUCT_TLVLEN(0));
5513 buf_ptr += WMI_TLV_HDR_SIZE;
5514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5515 sizeof(wmi_roam_ese_offload_tlv_param));
5516 buf_ptr += WMI_TLV_HDR_SIZE;
5517 roam_offload_ese =
5518 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5519 qdf_mem_copy(roam_offload_ese->krk,
5520 roam_req->krk,
5521 sizeof(roam_req->krk));
5522 qdf_mem_copy(roam_offload_ese->btk,
5523 roam_req->btk,
5524 sizeof(roam_req->btk));
5525 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5526 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5527 WMITLV_GET_STRUCT_TLVLEN
5528 (wmi_roam_ese_offload_tlv_param));
5529 buf_ptr +=
5530 sizeof(wmi_roam_ese_offload_tlv_param);
5531 } else if (auth_mode == WMI_AUTH_FT_RSNA
5532 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5533 || (auth_mode == WMI_AUTH_OPEN
5534 && roam_req->mdid.mdie_present)) {
5535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5536 0);
5537 buf_ptr += WMI_TLV_HDR_SIZE;
5538 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5539 sizeof(wmi_roam_11r_offload_tlv_param));
5540 buf_ptr += WMI_TLV_HDR_SIZE;
5541 roam_offload_11r =
5542 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5543 roam_offload_11r->r0kh_id_len =
5544 roam_req->rokh_id_length;
5545 qdf_mem_copy(roam_offload_11r->r0kh_id,
5546 roam_req->rokh_id,
5547 roam_offload_11r->r0kh_id_len);
5548 qdf_mem_copy(roam_offload_11r->psk_msk,
5549 roam_req->psk_pmk,
5550 sizeof(roam_req->psk_pmk));
5551 roam_offload_11r->psk_msk_len =
5552 roam_req->pmk_len;
5553 roam_offload_11r->mdie_present =
5554 roam_req->mdid.mdie_present;
5555 roam_offload_11r->mdid =
5556 roam_req->mdid.mobility_domain;
5557 if (auth_mode == WMI_AUTH_OPEN) {
5558 /* If FT-Open ensure pmk length
5559 and r0khid len are zero */
5560 roam_offload_11r->r0kh_id_len = 0;
5561 roam_offload_11r->psk_msk_len = 0;
5562 }
5563 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5564 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5565 WMITLV_GET_STRUCT_TLVLEN
5566 (wmi_roam_11r_offload_tlv_param));
5567 buf_ptr +=
5568 sizeof(wmi_roam_11r_offload_tlv_param);
5569 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5570 WMITLV_GET_STRUCT_TLVLEN(0));
5571 buf_ptr += WMI_TLV_HDR_SIZE;
5572 } else {
5573 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5574 sizeof(wmi_roam_11i_offload_tlv_param));
5575 buf_ptr += WMI_TLV_HDR_SIZE;
5576 roam_offload_11i =
5577 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005578
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005579 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005580 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305581 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5582 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005583 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305584 } else {
5585 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5586 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005587 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005588 }
5589 if (roam_req->roam_key_mgmt_offload_enabled &&
5590 roam_req->fw_pmksa_cache) {
5591 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5592 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005593 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005594 } else {
5595 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5596 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005597 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305598 }
5599
5600 qdf_mem_copy(roam_offload_11i->pmk,
5601 roam_req->psk_pmk,
5602 sizeof(roam_req->psk_pmk));
5603 roam_offload_11i->pmk_len = roam_req->pmk_len;
5604 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5605 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5606 WMITLV_GET_STRUCT_TLVLEN
5607 (wmi_roam_11i_offload_tlv_param));
5608 buf_ptr +=
5609 sizeof(wmi_roam_11i_offload_tlv_param);
5610 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5611 0);
5612 buf_ptr += WMI_TLV_HDR_SIZE;
5613 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5614 0);
5615 buf_ptr += WMI_TLV_HDR_SIZE;
5616 }
5617 } else {
5618 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5619 WMITLV_GET_STRUCT_TLVLEN(0));
5620 buf_ptr += WMI_TLV_HDR_SIZE;
5621 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5622 WMITLV_GET_STRUCT_TLVLEN(0));
5623 buf_ptr += WMI_TLV_HDR_SIZE;
5624 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5625 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305626 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305627 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305628
5629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5630 sizeof(*assoc_ies));
5631 buf_ptr += WMI_TLV_HDR_SIZE;
5632
5633 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5634 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5635 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5636 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5637 assoc_ies->buf_len = roam_req->assoc_ie_length;
5638
5639 buf_ptr += sizeof(*assoc_ies);
5640
5641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5642 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5643 buf_ptr += WMI_TLV_HDR_SIZE;
5644
5645 if (assoc_ies->buf_len != 0) {
5646 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5647 assoc_ies->buf_len);
5648 }
5649
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305650 } else {
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 WMITLV_GET_STRUCT_TLVLEN(0));
5656 buf_ptr += WMI_TLV_HDR_SIZE;
5657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5658 WMITLV_GET_STRUCT_TLVLEN(0));
5659 buf_ptr += WMI_TLV_HDR_SIZE;
5660 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5661 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305662 buf_ptr += WMI_TLV_HDR_SIZE;
5663 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5664 WMITLV_GET_STRUCT_TLVLEN(0));
5665 buf_ptr += WMI_TLV_HDR_SIZE;
5666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5667 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305668 }
5669#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305670
5671send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305672 status = wmi_unified_cmd_send(wmi_handle, buf,
5673 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305674 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305675 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305676 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5677 status);
5678 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305679 }
5680
Govind Singh67922e82016-04-01 16:48:57 +05305681 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305682}
5683
5684
5685/**
5686 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5687 * rssi threashold
5688 * @wmi_handle: wmi handle
5689 * @roam_req: Roaming request buffer
5690 *
5691 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5692 *
5693 * Return: QDF status
5694 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305695static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305696 struct roam_offload_scan_rssi_params *roam_req)
5697{
5698 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305699 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305700 int len;
5701 uint8_t *buf_ptr;
5702 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5703 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5704 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305705 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305706
5707 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5708 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5709 len += sizeof(wmi_roam_scan_extended_threshold_param);
5710 len += WMI_TLV_HDR_SIZE;
5711 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305712 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5713 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305714 buf = wmi_buf_alloc(wmi_handle, len);
5715 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305716 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305717 return QDF_STATUS_E_NOMEM;
5718 }
5719
5720 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5721 rssi_threshold_fp =
5722 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5723 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5724 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5725 WMITLV_GET_STRUCT_TLVLEN
5726 (wmi_roam_scan_rssi_threshold_fixed_param));
5727 /* fill in threshold values */
5728 rssi_threshold_fp->vdev_id = roam_req->session_id;
5729 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5730 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5731 rssi_threshold_fp->hirssi_scan_max_count =
5732 roam_req->hi_rssi_scan_max_count;
5733 rssi_threshold_fp->hirssi_scan_delta =
5734 roam_req->hi_rssi_scan_rssi_delta;
5735 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5736
5737 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5738 WMITLV_SET_HDR(buf_ptr,
5739 WMITLV_TAG_ARRAY_STRUC,
5740 sizeof(wmi_roam_scan_extended_threshold_param));
5741 buf_ptr += WMI_TLV_HDR_SIZE;
5742 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5743
5744 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5745 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5746 ext_thresholds->boost_threshold_5g =
5747 roam_req->boost_threshold_5g;
5748
5749 ext_thresholds->boost_algorithm_5g =
5750 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5751 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5752 ext_thresholds->penalty_algorithm_5g =
5753 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5754 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5755 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5756 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5757 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5758
5759 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5760 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5761 WMITLV_GET_STRUCT_TLVLEN
5762 (wmi_roam_scan_extended_threshold_param));
5763 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5764 WMITLV_SET_HDR(buf_ptr,
5765 WMITLV_TAG_ARRAY_STRUC,
5766 sizeof(wmi_roam_earlystop_rssi_thres_param));
5767 buf_ptr += WMI_TLV_HDR_SIZE;
5768 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5769 early_stop_thresholds->roam_earlystop_thres_min =
5770 roam_req->roam_earlystop_thres_min;
5771 early_stop_thresholds->roam_earlystop_thres_max =
5772 roam_req->roam_earlystop_thres_max;
5773 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5774 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5775 WMITLV_GET_STRUCT_TLVLEN
5776 (wmi_roam_earlystop_rssi_thres_param));
5777
Gupta, Kapil7e652922016-04-12 15:02:00 +05305778 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5780 sizeof(wmi_roam_dense_thres_param));
5781 buf_ptr += WMI_TLV_HDR_SIZE;
5782 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5783 dense_thresholds->roam_dense_rssi_thres_offset =
5784 roam_req->dense_rssi_thresh_offset;
5785 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5786 dense_thresholds->roam_dense_traffic_thres =
5787 roam_req->traffic_threshold;
5788 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5789 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5790 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5791 WMITLV_GET_STRUCT_TLVLEN
5792 (wmi_roam_dense_thres_param));
5793
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305794 status = wmi_unified_cmd_send(wmi_handle, buf,
5795 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305796 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305797 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305798 status);
5799 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305800 }
5801
Govind Singh67922e82016-04-01 16:48:57 +05305802 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305803}
5804
5805/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305806 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5807 * configuration params
5808 * @wma_handle: wma handler
5809 * @dwelltime_params: pointer to dwelltime_params
5810 *
5811 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5812 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005813static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305814QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5815 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5816{
5817 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5818 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5819 wmi_buf_t buf;
5820 uint8_t *buf_ptr;
5821 int32_t err;
5822 int len;
5823
5824 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5825 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5826 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5827 buf = wmi_buf_alloc(wmi_handle, len);
5828 if (!buf) {
5829 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5830 __func__);
5831 return QDF_STATUS_E_NOMEM;
5832 }
5833 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5834 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5835 WMITLV_SET_HDR(&dwell_param->tlv_header,
5836 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5837 WMITLV_GET_STRUCT_TLVLEN
5838 (wmi_scan_adaptive_dwell_config_fixed_param));
5839
5840 dwell_param->enable = dwelltime_params->is_enabled;
5841 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5842 WMITLV_SET_HDR(buf_ptr,
5843 WMITLV_TAG_ARRAY_STRUC,
5844 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5845 buf_ptr += WMI_TLV_HDR_SIZE;
5846
5847 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5848 WMITLV_SET_HDR(&cmd->tlv_header,
5849 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5850 WMITLV_GET_STRUCT_TLVLEN(
5851 wmi_scan_adaptive_dwell_parameters_tlv));
5852
5853 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5854 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5855 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5856 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5857 err = wmi_unified_cmd_send(wmi_handle, buf,
5858 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5859 if (err) {
5860 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5861 wmi_buf_free(buf);
5862 return QDF_STATUS_E_FAILURE;
5863 }
5864
5865 return QDF_STATUS_SUCCESS;
5866}
5867
Nitesh Shah52323d02017-05-22 15:49:00 +05305868/**
5869 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
5870 * configuration params
5871 * @wmi_handle: wmi handler
5872 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
5873 *
5874 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5875 */
5876static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
5877 struct wmi_dbs_scan_sel_params *dbs_scan_params)
5878{
5879 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
5880 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
5881 wmi_buf_t buf;
5882 uint8_t *buf_ptr;
5883 QDF_STATUS err;
5884 uint32_t i;
5885 int len;
5886
5887 len = sizeof(*dbs_scan_param);
5888 len += WMI_TLV_HDR_SIZE;
5889 len += dbs_scan_params->num_clients * sizeof(*cmd);
5890
5891 buf = wmi_buf_alloc(wmi_handle, len);
5892 if (!buf) {
5893 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
5894 return QDF_STATUS_E_NOMEM;
5895 }
5896
5897 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5898 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
5899 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
5900 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
5901 WMITLV_GET_STRUCT_TLVLEN
5902 (wmi_scan_dbs_duty_cycle_fixed_param));
5903
5904 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
5905 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
5906 buf_ptr += sizeof(*dbs_scan_param);
5907 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5908 (sizeof(*cmd) * dbs_scan_params->num_clients));
5909 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
5910
5911 for (i = 0; i < dbs_scan_params->num_clients; i++) {
5912 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
5913 WMITLV_SET_HDR(&cmd->tlv_header,
5914 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
5915 WMITLV_GET_STRUCT_TLVLEN(
5916 wmi_scan_dbs_duty_cycle_tlv_param));
5917 cmd->module_id = dbs_scan_params->module_id[i];
5918 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
5919 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
5920 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
5921 }
5922
5923 err = wmi_unified_cmd_send(wmi_handle, buf,
5924 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
5925 if (QDF_IS_STATUS_ERROR(err)) {
5926 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
5927 wmi_buf_free(buf);
5928 return QDF_STATUS_E_FAILURE;
5929 }
5930
5931 return QDF_STATUS_SUCCESS;
5932}
Gupta, Kapil2e685982016-04-25 19:14:19 +05305933
5934/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305935 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5936 * @wmi_handle: wmi handle
5937 * @roam_req: Request which contains the filters
5938 *
5939 * There are filters such as whitelist, blacklist and preferred
5940 * list that need to be applied to the scan results to form the
5941 * probable candidates for roaming.
5942 *
5943 * Return: Return success upon succesfully passing the
5944 * parameters to the firmware, otherwise failure.
5945 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305946static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305947 struct roam_scan_filter_params *roam_req)
5948{
5949 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305950 QDF_STATUS status;
5951 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305952 uint32_t len;
5953 uint8_t *buf_ptr;
5954 wmi_roam_filter_fixed_param *roam_filter;
5955 uint8_t *bssid_src_ptr = NULL;
5956 wmi_mac_addr *bssid_dst_ptr = NULL;
5957 wmi_ssid *ssid_ptr = NULL;
5958 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05305959 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305960
5961 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05305962
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305963 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05305964 if (roam_req->num_bssid_black_list)
5965 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
5966 len += WMI_TLV_HDR_SIZE;
5967 if (roam_req->num_ssid_white_list)
5968 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
5969 len += 2 * WMI_TLV_HDR_SIZE;
5970 if (roam_req->num_bssid_preferred_list) {
5971 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
5972 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
5973 }
5974 if (roam_req->lca_disallow_config_present)
5975 len += WMI_TLV_HDR_SIZE +
5976 sizeof(wmi_roam_lca_disallow_config_tlv_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305977
5978 buf = wmi_buf_alloc(wmi_handle, len);
5979 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305980 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305981 return QDF_STATUS_E_NOMEM;
5982 }
5983
5984 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5985 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5986 WMITLV_SET_HDR(&roam_filter->tlv_header,
5987 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5988 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5989 /* fill in fixed values */
5990 roam_filter->vdev_id = roam_req->session_id;
5991 roam_filter->flags = 0;
5992 roam_filter->op_bitmap = roam_req->op_bitmap;
5993 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5994 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5995 roam_filter->num_bssid_preferred_list =
5996 roam_req->num_bssid_preferred_list;
5997 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5998
5999 WMITLV_SET_HDR((buf_ptr),
6000 WMITLV_TAG_ARRAY_FIXED_STRUC,
6001 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6002 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6003 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6004 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6005 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6006 bssid_src_ptr += ATH_MAC_LEN;
6007 bssid_dst_ptr++;
6008 }
6009 buf_ptr += WMI_TLV_HDR_SIZE +
6010 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6011 WMITLV_SET_HDR((buf_ptr),
6012 WMITLV_TAG_ARRAY_FIXED_STRUC,
6013 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6014 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6015 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6016 qdf_mem_copy(&ssid_ptr->ssid,
6017 &roam_req->ssid_allowed_list[i].mac_ssid,
6018 roam_req->ssid_allowed_list[i].length);
6019 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6020 ssid_ptr++;
6021 }
6022 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6023 sizeof(wmi_ssid));
6024 WMITLV_SET_HDR((buf_ptr),
6025 WMITLV_TAG_ARRAY_FIXED_STRUC,
6026 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6027 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6028 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6029 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6030 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6031 (wmi_mac_addr *)bssid_dst_ptr);
6032 bssid_src_ptr += ATH_MAC_LEN;
6033 bssid_dst_ptr++;
6034 }
6035 buf_ptr += WMI_TLV_HDR_SIZE +
6036 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6037 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6038 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6039 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6040 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6041 *bssid_preferred_factor_ptr =
6042 roam_req->bssid_favored_factor[i];
6043 bssid_preferred_factor_ptr++;
6044 }
6045 buf_ptr += WMI_TLV_HDR_SIZE +
6046 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6047
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306048 if (roam_req->lca_disallow_config_present) {
6049 WMITLV_SET_HDR(buf_ptr,
6050 WMITLV_TAG_ARRAY_STRUC,
6051 sizeof(wmi_roam_lca_disallow_config_tlv_param));
6052 buf_ptr += WMI_TLV_HDR_SIZE;
6053 blist_param =
6054 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6055 WMITLV_SET_HDR(&blist_param->tlv_header,
6056 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6057 WMITLV_GET_STRUCT_TLVLEN(
6058 wmi_roam_lca_disallow_config_tlv_param));
6059
6060 blist_param->disallow_duration = roam_req->disallow_duration;
6061 blist_param->rssi_channel_penalization =
6062 roam_req->rssi_channel_penalization;
6063 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
6064 blist_param->disallow_lca_enable_source_bitmap = 0x1;
6065 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6066 }
6067
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306068 status = wmi_unified_cmd_send(wmi_handle, buf,
6069 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306070 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306071 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306072 status);
6073 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306074 }
Govind Singh67922e82016-04-01 16:48:57 +05306075
6076 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306077}
6078
Govind Singh4eacd2b2016-03-07 14:24:22 +05306079/** send_set_epno_network_list_cmd_tlv() - set epno network list
6080 * @wmi_handle: wmi handle
6081 * @req: epno config params request structure
6082 *
6083 * This function reads the incoming epno config request structure
6084 * and constructs the WMI message to the firmware.
6085 *
6086 * Returns: 0 on success, error number otherwise
6087 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306088static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306089 struct wifi_enhanched_pno_params *req)
6090{
6091 wmi_nlo_config_cmd_fixed_param *cmd;
6092 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306093 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306094 u_int8_t i, *buf_ptr;
6095 wmi_buf_t buf;
6096 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306097 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306098
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306099 /* Fixed Params */
6100 len = sizeof(*cmd);
6101 if (req->num_networks) {
6102 /* TLV place holder for array of structures
6103 * then each nlo_configured_parameters(nlo_list) TLV.
6104 */
6105 len += WMI_TLV_HDR_SIZE;
6106 len += (sizeof(nlo_configured_parameters)
6107 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6108 /* TLV for array of uint32 channel_list */
6109 len += WMI_TLV_HDR_SIZE;
6110 /* TLV for nlo_channel_prediction_cfg */
6111 len += WMI_TLV_HDR_SIZE;
6112 /* TLV for candidate score params */
6113 len += sizeof(enlo_candidate_score_params);
6114 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306115
6116 buf = wmi_buf_alloc(wmi_handle, len);
6117 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306118 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6119 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306120 }
6121
6122 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6123
6124 buf_ptr = (u_int8_t *) cmd;
6125 WMITLV_SET_HDR(&cmd->tlv_header,
6126 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6127 WMITLV_GET_STRUCT_TLVLEN(
6128 wmi_nlo_config_cmd_fixed_param));
6129 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306130
6131 /* set flag to reset if num of networks are 0 */
6132 cmd->flags = (req->num_networks == 0 ?
6133 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306134
6135 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6136
Govind Singhb53420c2016-03-09 14:32:57 +05306137 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306138 WMI_LOGD("SSID count: %d flags: %d",
6139 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306140
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306141 /* Fill nlo_config only when num_networks are non zero */
6142 if (cmd->no_of_ssids) {
6143 /* Fill networks */
6144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6145 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6146 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306147
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306148 nlo_list = (nlo_configured_parameters *) buf_ptr;
6149 for (i = 0; i < cmd->no_of_ssids; i++) {
6150 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6151 WMITLV_TAG_ARRAY_BYTE,
6152 WMITLV_GET_STRUCT_TLVLEN(
6153 nlo_configured_parameters));
6154 /* Copy ssid and it's length */
6155 nlo_list[i].ssid.valid = true;
6156 nlo_list[i].ssid.ssid.ssid_len =
6157 req->networks[i].ssid.length;
6158 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6159 req->networks[i].ssid.mac_ssid,
6160 nlo_list[i].ssid.ssid.ssid_len);
6161 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6162 nlo_list[i].ssid.ssid.ssid_len,
6163 (char *) nlo_list[i].ssid.ssid.ssid,
6164 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306165
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306166 /* Copy pno flags */
6167 nlo_list[i].bcast_nw_type.valid = true;
6168 nlo_list[i].bcast_nw_type.bcast_nw_type =
6169 req->networks[i].flags;
6170 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306171 nlo_list[i].bcast_nw_type.bcast_nw_type);
6172
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306173 /* Copy auth bit field */
6174 nlo_list[i].auth_type.valid = true;
6175 nlo_list[i].auth_type.auth_type =
6176 req->networks[i].auth_bit_field;
6177 WMI_LOGD("Auth bit field (%u)",
6178 nlo_list[i].auth_type.auth_type);
6179 }
6180
6181 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6182 /* Fill the channel list */
6183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6184 buf_ptr += WMI_TLV_HDR_SIZE;
6185
6186 /* Fill prediction_param */
6187 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6188 buf_ptr += WMI_TLV_HDR_SIZE;
6189
6190 /* Fill epno candidate score params */
6191 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6192 WMITLV_SET_HDR(buf_ptr,
6193 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6194 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6195 cand_score_params->min5GHz_rssi =
6196 req->min_5ghz_rssi;
6197 cand_score_params->min24GHz_rssi =
6198 req->min_24ghz_rssi;
6199 cand_score_params->initial_score_max =
6200 req->initial_score_max;
6201 cand_score_params->current_connection_bonus =
6202 req->current_connection_bonus;
6203 cand_score_params->same_network_bonus =
6204 req->same_network_bonus;
6205 cand_score_params->secure_bonus =
6206 req->secure_bonus;
6207 cand_score_params->band5GHz_bonus =
6208 req->band_5ghz_bonus;
6209 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306210 }
6211
Govind Singh4eacd2b2016-03-07 14:24:22 +05306212 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306213 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306214 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306215 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306216 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306217 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306218 }
6219
Govind Singhb53420c2016-03-09 14:32:57 +05306220 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306221 req->session_id);
6222
Govind Singh67922e82016-04-01 16:48:57 +05306223 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306224}
6225
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306226
Govind Singh4eacd2b2016-03-07 14:24:22 +05306227/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6228 * @wmi_handle: wmi handle
6229 * @ipa_offload: ipa offload control parameter
6230 *
6231 * Returns: 0 on success, error number otherwise
6232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306233static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306234 struct ipa_offload_control_params *ipa_offload)
6235{
6236 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6237 wmi_buf_t wmi_buf;
6238 uint32_t len;
6239 u_int8_t *buf_ptr;
6240
6241 len = sizeof(*cmd);
6242 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6243 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306244 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6245 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306246 }
6247
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08006248 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306249 ipa_offload->offload_type, ipa_offload->enable);
6250
6251 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6252
6253 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6254 WMITLV_SET_HDR(&cmd->tlv_header,
6255 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6256 WMITLV_GET_STRUCT_TLVLEN(
6257 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6258
6259 cmd->offload_type = ipa_offload->offload_type;
6260 cmd->vdev_id = ipa_offload->vdev_id;
6261 cmd->enable = ipa_offload->enable;
6262
6263 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6264 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306265 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306266 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306267 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306268 }
6269
Govind Singhb53420c2016-03-09 14:32:57 +05306270 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306271}
6272
6273/**
6274 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6275 * @wmi_handle: wmi handle
6276 * @pgetcapab: get capabilities params
6277 *
6278 * This function send request to fw to get extscan capabilities.
6279 *
6280 * Return: CDF status
6281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306282static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306283 struct extscan_capabilities_params *pgetcapab)
6284{
6285 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6286 wmi_buf_t wmi_buf;
6287 uint32_t len;
6288 uint8_t *buf_ptr;
6289
6290 len = sizeof(*cmd);
6291 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6292 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306293 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6294 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306295 }
6296 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6297
6298 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6299 WMITLV_SET_HDR(&cmd->tlv_header,
6300 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6301 WMITLV_GET_STRUCT_TLVLEN
6302 (wmi_extscan_get_capabilities_cmd_fixed_param));
6303
6304 cmd->request_id = pgetcapab->request_id;
6305
6306 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6307 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306308 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306309 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306310 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306311 }
Govind Singhb53420c2016-03-09 14:32:57 +05306312 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306313}
6314
6315/**
6316 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6317 * @wmi_handle: wmi handle
6318 * @pcached_results: cached results parameters
6319 *
6320 * This function send request to fw to get cached results.
6321 *
6322 * Return: CDF status
6323 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306324static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306325 struct extscan_cached_result_params *pcached_results)
6326{
6327 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6328 wmi_buf_t wmi_buf;
6329 uint32_t len;
6330 uint8_t *buf_ptr;
6331
6332 len = sizeof(*cmd);
6333 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6334 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306335 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6336 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306337 }
6338 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6339
6340 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6341 WMITLV_SET_HDR(&cmd->tlv_header,
6342 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6343 WMITLV_GET_STRUCT_TLVLEN
6344 (wmi_extscan_get_cached_results_cmd_fixed_param));
6345
6346 cmd->request_id = pcached_results->request_id;
6347 cmd->vdev_id = pcached_results->session_id;
6348 cmd->control_flags = pcached_results->flush;
6349
6350 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6351 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306352 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306353 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306354 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306355 }
Govind Singhb53420c2016-03-09 14:32:57 +05306356 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306357}
6358
6359/**
6360 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6361 * @wmi_handle: wmi handle
6362 * @reset_req: Reset change request params
6363 *
6364 * This function sends stop change monitor request to fw.
6365 *
6366 * Return: CDF status
6367 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306368static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306369 struct extscan_capabilities_reset_params *reset_req)
6370{
6371 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6372 wmi_buf_t wmi_buf;
6373 uint32_t len;
6374 uint8_t *buf_ptr;
6375 int change_list = 0;
6376
6377 len = sizeof(*cmd);
6378
6379 /* reset significant change tlv is set to 0 */
6380 len += WMI_TLV_HDR_SIZE;
6381 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6382 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6383 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306384 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6385 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306386 }
6387 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6388
6389 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6390 buf_ptr;
6391 WMITLV_SET_HDR(&cmd->tlv_header,
6392 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6393 WMITLV_GET_STRUCT_TLVLEN
6394 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6395
6396 cmd->request_id = reset_req->request_id;
6397 cmd->vdev_id = reset_req->session_id;
6398 cmd->mode = 0;
6399
6400 buf_ptr += sizeof(*cmd);
6401 WMITLV_SET_HDR(buf_ptr,
6402 WMITLV_TAG_ARRAY_STRUC,
6403 change_list *
6404 sizeof(wmi_extscan_wlan_change_bssid_param));
6405 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6406 sizeof
6407 (wmi_extscan_wlan_change_bssid_param));
6408
6409 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6410 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306411 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306412 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306413 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306414 }
Govind Singhb53420c2016-03-09 14:32:57 +05306415 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306416}
6417
6418/**
6419 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6420 * @wmi_handle: wmi handle
6421 * @psigchange: change monitor request params
6422 * @buf: wmi buffer
6423 * @buf_len: buffer length
6424 *
6425 * This function fills elements of change monitor request buffer.
6426 *
6427 * Return: CDF status
6428 */
Govind Singhb53420c2016-03-09 14:32:57 +05306429static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306430 struct extscan_set_sig_changereq_params
6431 *psigchange, wmi_buf_t *buf, int *buf_len)
6432{
6433 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6434 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6435 uint8_t *buf_ptr;
6436 int j;
6437 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006438 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306439 struct ap_threshold_params *src_ap = psigchange->ap;
6440
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006441 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306442 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6443 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 }
6445 len += WMI_TLV_HDR_SIZE;
6446 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6447
6448 *buf = wmi_buf_alloc(wmi_handle, len);
6449 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306450 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306451 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306452 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306453 }
6454 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6455 cmd =
6456 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6457 buf_ptr;
6458 WMITLV_SET_HDR(&cmd->tlv_header,
6459 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6460 WMITLV_GET_STRUCT_TLVLEN
6461 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6462
6463 cmd->request_id = psigchange->request_id;
6464 cmd->vdev_id = psigchange->session_id;
6465 cmd->total_entries = numap;
6466 cmd->mode = 1;
6467 cmd->num_entries_in_page = numap;
6468 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6469 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6470 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6471 cmd->max_out_of_range_count = psigchange->min_breaching;
6472
6473 buf_ptr += sizeof(*cmd);
6474 WMITLV_SET_HDR(buf_ptr,
6475 WMITLV_TAG_ARRAY_STRUC,
6476 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6477 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6478 (buf_ptr + WMI_TLV_HDR_SIZE);
6479
6480 for (j = 0; j < numap; j++) {
6481 WMITLV_SET_HDR(dest_chglist,
6482 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6483 WMITLV_GET_STRUCT_TLVLEN
6484 (wmi_extscan_wlan_change_bssid_param));
6485
6486 dest_chglist->lower_rssi_limit = src_ap->low;
6487 dest_chglist->upper_rssi_limit = src_ap->high;
6488 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6489 &dest_chglist->bssid);
6490
Govind Singhb53420c2016-03-09 14:32:57 +05306491 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306492 dest_chglist->lower_rssi_limit);
6493 dest_chglist++;
6494 src_ap++;
6495 }
6496 buf_ptr += WMI_TLV_HDR_SIZE +
6497 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6498 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306499 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306500}
6501
6502/**
6503 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6504 * @wmi_handle: wmi handle
6505 * @psigchange: change monitor request params
6506 *
6507 * This function sends start change monitor request to fw.
6508 *
6509 * Return: CDF status
6510 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306511static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306512 struct extscan_set_sig_changereq_params *
6513 psigchange)
6514{
Govind Singhb53420c2016-03-09 14:32:57 +05306515 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306516 wmi_buf_t buf;
6517 int len;
6518
6519
Govind Singhb53420c2016-03-09 14:32:57 +05306520 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306521 psigchange, &buf,
6522 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306523 if (qdf_status != QDF_STATUS_SUCCESS) {
6524 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306525 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306526 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306527 }
6528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306529 WMI_LOGE("%s: Failed to get buffer", __func__);
6530 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306531 }
6532 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6533 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306534 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306535 wmi_buf_free(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_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6543 * @wmi_handle: wmi handle
6544 * @photlist_reset: hotlist reset params
6545 *
6546 * This function configures hotlist monitor to stop in fw.
6547 *
6548 * Return: CDF status
6549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306550static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306551 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6552{
6553 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6554 wmi_buf_t wmi_buf;
6555 uint32_t len;
6556 uint8_t *buf_ptr;
6557 int hotlist_entries = 0;
6558
6559 len = sizeof(*cmd);
6560
6561 /* reset bssid hotlist with tlv set to 0 */
6562 len += WMI_TLV_HDR_SIZE;
6563 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6564
6565 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6566 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306567 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6568 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306569 }
6570
6571 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6572 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6573 buf_ptr;
6574 WMITLV_SET_HDR(&cmd->tlv_header,
6575 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6576 WMITLV_GET_STRUCT_TLVLEN
6577 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6578
6579 cmd->request_id = photlist_reset->request_id;
6580 cmd->vdev_id = photlist_reset->session_id;
6581 cmd->mode = 0;
6582
6583 buf_ptr += sizeof(*cmd);
6584 WMITLV_SET_HDR(buf_ptr,
6585 WMITLV_TAG_ARRAY_STRUC,
6586 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6587 buf_ptr += WMI_TLV_HDR_SIZE +
6588 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6589
6590 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6591 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306592 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306593 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306594 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306595 }
Govind Singhb53420c2016-03-09 14:32:57 +05306596 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306597}
6598
6599/**
6600 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6601 * @wmi_handle: wmi handle
6602 * @pstopcmd: stop scan command request params
6603 *
6604 * This function sends stop extscan request to fw.
6605 *
6606 * Return: CDF Status.
6607 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306608static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306609 struct extscan_stop_req_params *pstopcmd)
6610{
6611 wmi_extscan_stop_cmd_fixed_param *cmd;
6612 wmi_buf_t wmi_buf;
6613 uint32_t len;
6614 uint8_t *buf_ptr;
6615
6616 len = sizeof(*cmd);
6617 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6618 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306619 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6620 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306621 }
6622 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6623 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6624 WMITLV_SET_HDR(&cmd->tlv_header,
6625 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6626 WMITLV_GET_STRUCT_TLVLEN
6627 (wmi_extscan_stop_cmd_fixed_param));
6628
6629 cmd->request_id = pstopcmd->request_id;
6630 cmd->vdev_id = pstopcmd->session_id;
6631
6632 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6633 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306634 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306635 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306636 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306637 }
6638
Govind Singhb53420c2016-03-09 14:32:57 +05306639 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306640}
6641
6642/**
6643 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6644 * @wmi_handle: wmi handle
6645 * @pstart: scan command request params
6646 * @buf: event buffer
6647 * @buf_len: length of buffer
6648 *
6649 * This function fills individual elements of extscan request and
6650 * TLV for buckets, channel list.
6651 *
6652 * Return: CDF Status.
6653 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006654static
Govind Singhb53420c2016-03-09 14:32:57 +05306655QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306656 struct wifi_scan_cmd_req_params *pstart,
6657 wmi_buf_t *buf, int *buf_len)
6658{
6659 wmi_extscan_start_cmd_fixed_param *cmd;
6660 wmi_extscan_bucket *dest_blist;
6661 wmi_extscan_bucket_channel *dest_clist;
6662 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6663 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6664 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6665
6666 uint8_t *buf_ptr;
6667 int i, k, count = 0;
6668 int len = sizeof(*cmd);
6669 int nbuckets = pstart->numBuckets;
6670 int nchannels = 0;
6671
6672 /* These TLV's are are NULL by default */
6673 uint32_t ie_len_with_pad = 0;
6674 int num_ssid = 0;
6675 int num_bssid = 0;
6676 int ie_len = 0;
6677
6678 uint32_t base_period = pstart->basePeriod;
6679
6680 /* TLV placeholder for ssid_list (NULL) */
6681 len += WMI_TLV_HDR_SIZE;
6682 len += num_ssid * sizeof(wmi_ssid);
6683
6684 /* TLV placeholder for bssid_list (NULL) */
6685 len += WMI_TLV_HDR_SIZE;
6686 len += num_bssid * sizeof(wmi_mac_addr);
6687
6688 /* TLV placeholder for ie_data (NULL) */
6689 len += WMI_TLV_HDR_SIZE;
6690 len += ie_len * sizeof(uint32_t);
6691
6692 /* TLV placeholder for bucket */
6693 len += WMI_TLV_HDR_SIZE;
6694 len += nbuckets * sizeof(wmi_extscan_bucket);
6695
6696 /* TLV channel placeholder */
6697 len += WMI_TLV_HDR_SIZE;
6698 for (i = 0; i < nbuckets; i++) {
6699 nchannels += src_bucket->numChannels;
6700 src_bucket++;
6701 }
6702
Govind Singhb53420c2016-03-09 14:32:57 +05306703 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306704 __func__, nbuckets, nchannels);
6705 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6706 /* Allocate the memory */
6707 *buf = wmi_buf_alloc(wmi_handle, len);
6708 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306709 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306710 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306711 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306712 }
6713 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6714 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6715 WMITLV_SET_HDR(&cmd->tlv_header,
6716 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6717 WMITLV_GET_STRUCT_TLVLEN
6718 (wmi_extscan_start_cmd_fixed_param));
6719
6720 cmd->request_id = pstart->requestId;
6721 cmd->vdev_id = pstart->sessionId;
6722 cmd->base_period = pstart->basePeriod;
6723 cmd->num_buckets = nbuckets;
6724 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306725 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306727 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306728 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306729#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306730 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6731 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306732 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6733 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6734#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306735 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6736
6737 /* The max dwell time is retrieved from the first channel
6738 * of the first bucket and kept common for all channels.
6739 */
6740 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6741 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6742 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6743 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6744 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6745 cmd->max_table_usage = pstart->report_threshold_percent;
6746 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6747
6748 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306749 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306750 cmd->probe_delay = 0;
6751 cmd->probe_spacing_time = 0;
6752 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306753 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6754 WMI_SCAN_ADD_CCK_RATES |
6755 WMI_SCAN_ADD_OFDM_RATES |
6756 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6757 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306758 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6759 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306760 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306761 cmd->num_ssids = 0;
6762 cmd->num_bssid = 0;
6763 cmd->ie_len = 0;
6764 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6765 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6766
6767 buf_ptr += sizeof(*cmd);
6768 WMITLV_SET_HDR(buf_ptr,
6769 WMITLV_TAG_ARRAY_FIXED_STRUC,
6770 num_ssid * sizeof(wmi_ssid));
6771 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6772
6773 WMITLV_SET_HDR(buf_ptr,
6774 WMITLV_TAG_ARRAY_FIXED_STRUC,
6775 num_bssid * sizeof(wmi_mac_addr));
6776 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6777
6778 ie_len_with_pad = 0;
6779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6780 ie_len_with_pad);
6781 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6782
6783 WMITLV_SET_HDR(buf_ptr,
6784 WMITLV_TAG_ARRAY_STRUC,
6785 nbuckets * sizeof(wmi_extscan_bucket));
6786 dest_blist = (wmi_extscan_bucket *)
6787 (buf_ptr + WMI_TLV_HDR_SIZE);
6788 src_bucket = pstart->buckets;
6789
6790 /* Retrieve scanning information from each bucket and
6791 * channels and send it to the target
6792 */
6793 for (i = 0; i < nbuckets; i++) {
6794 WMITLV_SET_HDR(dest_blist,
6795 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6796 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6797
6798 dest_blist->bucket_id = src_bucket->bucket;
6799 dest_blist->base_period_multiplier =
6800 src_bucket->period / base_period;
6801 dest_blist->min_period = src_bucket->period;
6802 dest_blist->max_period = src_bucket->max_period;
6803 dest_blist->exp_backoff = src_bucket->exponent;
6804 dest_blist->exp_max_step_count = src_bucket->step_count;
6805 dest_blist->channel_band = src_bucket->band;
6806 dest_blist->num_channels = src_bucket->numChannels;
6807 dest_blist->notify_extscan_events = 0;
6808
6809 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6810 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006811 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6812 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306813
6814 if (src_bucket->reportEvents &
6815 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6816 dest_blist->forwarding_flags =
6817 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6818 dest_blist->notify_extscan_events |=
6819 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6820 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6821 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6822 } else {
6823 dest_blist->forwarding_flags =
6824 WMI_EXTSCAN_NO_FORWARDING;
6825 }
6826
6827 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6828 dest_blist->configuration_flags = 0;
6829 else
6830 dest_blist->configuration_flags =
6831 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6832
Govind Singhb53420c2016-03-09 14:32:57 +05306833 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834 __func__, dest_blist->notify_extscan_events,
6835 dest_blist->configuration_flags,
6836 dest_blist->forwarding_flags);
6837
6838 dest_blist->min_dwell_time_active =
6839 src_bucket->min_dwell_time_active;
6840 dest_blist->max_dwell_time_active =
6841 src_bucket->max_dwell_time_active;
6842 dest_blist->min_dwell_time_passive =
6843 src_bucket->min_dwell_time_passive;
6844 dest_blist->max_dwell_time_passive =
6845 src_bucket->max_dwell_time_passive;
6846 src_channel = src_bucket->channels;
6847
6848 /* save the channel info to later populate
6849 * the channel TLV
6850 */
6851 for (k = 0; k < src_bucket->numChannels; k++) {
6852 save_channel[count++].channel = src_channel->channel;
6853 src_channel++;
6854 }
6855 dest_blist++;
6856 src_bucket++;
6857 }
6858 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6859 WMITLV_SET_HDR(buf_ptr,
6860 WMITLV_TAG_ARRAY_STRUC,
6861 nchannels * sizeof(wmi_extscan_bucket_channel));
6862 dest_clist = (wmi_extscan_bucket_channel *)
6863 (buf_ptr + WMI_TLV_HDR_SIZE);
6864
6865 /* Active or passive scan is based on the bucket dwell time
6866 * and channel specific active,passive scans are not
6867 * supported yet
6868 */
6869 for (i = 0; i < nchannels; i++) {
6870 WMITLV_SET_HDR(dest_clist,
6871 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6872 WMITLV_GET_STRUCT_TLVLEN
6873 (wmi_extscan_bucket_channel));
6874 dest_clist->channel = save_channel[i].channel;
6875 dest_clist++;
6876 }
6877 buf_ptr += WMI_TLV_HDR_SIZE +
6878 (nchannels * sizeof(wmi_extscan_bucket_channel));
6879 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306880 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306881}
6882
6883/**
6884 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6885 * @wmi_handle: wmi handle
6886 * @pstart: scan command request params
6887 *
6888 * This function sends start extscan request to fw.
6889 *
6890 * Return: CDF Status.
6891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306892static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306893 struct wifi_scan_cmd_req_params *pstart)
6894{
Govind Singhb53420c2016-03-09 14:32:57 +05306895 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306896 wmi_buf_t buf;
6897 int len;
6898
6899 /* Fill individual elements of extscan request and
6900 * TLV for buckets, channel list.
6901 */
Govind Singhb53420c2016-03-09 14:32:57 +05306902 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306903 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306904 if (qdf_status != QDF_STATUS_SUCCESS) {
6905 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6906 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306907 }
6908 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306909 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306910 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306911 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306912 }
6913 if (wmi_unified_cmd_send(wmi_handle, buf,
6914 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306915 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306917 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918 }
6919
Govind Singhb53420c2016-03-09 14:32:57 +05306920 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306921}
6922
6923/**
6924 * send_plm_stop_cmd_tlv() - plm stop request
6925 * @wmi_handle: wmi handle
6926 * @plm: plm request parameters
6927 *
6928 * This function request FW to stop PLM.
6929 *
6930 * Return: CDF status
6931 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306932static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306933 const struct plm_req_params *plm)
6934{
6935 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6936 int32_t len;
6937 wmi_buf_t buf;
6938 uint8_t *buf_ptr;
6939 int ret;
6940
6941 len = sizeof(*cmd);
6942 buf = wmi_buf_alloc(wmi_handle, len);
6943 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306944 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6945 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306946 }
6947
6948 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6949
6950 buf_ptr = (uint8_t *) cmd;
6951
6952 WMITLV_SET_HDR(&cmd->tlv_header,
6953 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6954 WMITLV_GET_STRUCT_TLVLEN
6955 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6956
6957 cmd->vdev_id = plm->session_id;
6958
6959 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306960 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961
6962 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6963 WMI_VDEV_PLMREQ_STOP_CMDID);
6964 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306965 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306966 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306967 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306968 }
6969
Govind Singhb53420c2016-03-09 14:32:57 +05306970 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306971}
6972
6973/**
6974 * send_plm_start_cmd_tlv() - plm start request
6975 * @wmi_handle: wmi handle
6976 * @plm: plm request parameters
6977 *
6978 * This function request FW to start PLM.
6979 *
6980 * Return: CDF status
6981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306982static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306983 const struct plm_req_params *plm,
6984 uint32_t *gchannel_list)
6985{
6986 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6987 uint32_t *channel_list;
6988 int32_t len;
6989 wmi_buf_t buf;
6990 uint8_t *buf_ptr;
6991 uint8_t count;
6992 int ret;
6993
6994 /* TLV place holder for channel_list */
6995 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6996 len += sizeof(uint32_t) * plm->plm_num_ch;
6997
6998 buf = wmi_buf_alloc(wmi_handle, len);
6999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307000 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7001 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 }
7003 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7004
7005 buf_ptr = (uint8_t *) cmd;
7006
7007 WMITLV_SET_HDR(&cmd->tlv_header,
7008 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7009 WMITLV_GET_STRUCT_TLVLEN
7010 (wmi_vdev_plmreq_start_cmd_fixed_param));
7011
7012 cmd->vdev_id = plm->session_id;
7013
7014 cmd->meas_token = plm->meas_token;
7015 cmd->dialog_token = plm->diag_token;
7016 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307017 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307018 cmd->off_duration = plm->meas_duration;
7019 cmd->burst_cycle = plm->burst_len;
7020 cmd->tx_power = plm->desired_tx_pwr;
7021 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7022 cmd->num_chans = plm->plm_num_ch;
7023
7024 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7025
Govind Singhb53420c2016-03-09 14:32:57 +05307026 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7027 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7028 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7029 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7030 WMI_LOGD("off_duration: %d", cmd->off_duration);
7031 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7032 WMI_LOGD("tx_power: %d", cmd->tx_power);
7033 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307034
7035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7036 (cmd->num_chans * sizeof(uint32_t)));
7037
7038 buf_ptr += WMI_TLV_HDR_SIZE;
7039 if (cmd->num_chans) {
7040 channel_list = (uint32_t *) buf_ptr;
7041 for (count = 0; count < cmd->num_chans; count++) {
7042 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307043 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307044 channel_list[count] =
7045 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307046 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307047 }
7048 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7049 }
7050
7051 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7052 WMI_VDEV_PLMREQ_START_CMDID);
7053 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307054 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307055 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307056 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307057 }
7058
Govind Singhb53420c2016-03-09 14:32:57 +05307059 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307060}
7061
7062/**
7063 * send_pno_stop_cmd_tlv() - PNO stop request
7064 * @wmi_handle: wmi handle
7065 * @vdev_id: vdev id
7066 *
7067 * This function request FW to stop ongoing PNO operation.
7068 *
7069 * Return: CDF status
7070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307071static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307072{
7073 wmi_nlo_config_cmd_fixed_param *cmd;
7074 int32_t len = sizeof(*cmd);
7075 wmi_buf_t buf;
7076 uint8_t *buf_ptr;
7077 int ret;
7078
7079 /*
7080 * TLV place holder for array of structures nlo_configured_parameters
7081 * TLV place holder for array of uint32_t channel_list
7082 * TLV place holder for chnl prediction cfg
7083 */
7084 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7085 buf = wmi_buf_alloc(wmi_handle, len);
7086 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307087 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7088 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307089 }
7090
7091 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7092 buf_ptr = (uint8_t *) cmd;
7093
7094 WMITLV_SET_HDR(&cmd->tlv_header,
7095 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7096 WMITLV_GET_STRUCT_TLVLEN
7097 (wmi_nlo_config_cmd_fixed_param));
7098
7099 cmd->vdev_id = vdev_id;
7100 cmd->flags = WMI_NLO_CONFIG_STOP;
7101 buf_ptr += sizeof(*cmd);
7102
7103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7104 buf_ptr += WMI_TLV_HDR_SIZE;
7105
7106 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7107 buf_ptr += WMI_TLV_HDR_SIZE;
7108
7109 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7110 buf_ptr += WMI_TLV_HDR_SIZE;
7111
7112
7113 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7114 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7115 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307116 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307117 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307118 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119 }
7120
Govind Singhb53420c2016-03-09 14:32:57 +05307121 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307122}
7123
7124/**
Govind Singhccb0c272016-04-01 16:30:08 +05307125 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7126 * @buf_ptr: Buffer passed by upper layers
7127 * @pno: Buffer to be sent to the firmware
7128 *
7129 * Copy the PNO Channel prediction configuration parameters
7130 * passed by the upper layers to a WMI format TLV and send it
7131 * down to the firmware.
7132 *
7133 * Return: None
7134 */
7135static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7136 struct pno_scan_req_params *pno)
7137{
7138 nlo_channel_prediction_cfg *channel_prediction_cfg =
7139 (nlo_channel_prediction_cfg *) buf_ptr;
7140 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7141 WMITLV_TAG_ARRAY_BYTE,
7142 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307143#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307144 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7145 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7146 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7147 channel_prediction_cfg->full_scan_period_ms =
7148 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307149#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307150 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7151 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7152 channel_prediction_cfg->enable,
7153 channel_prediction_cfg->top_k_num,
7154 channel_prediction_cfg->stationary_threshold,
7155 channel_prediction_cfg->full_scan_period_ms);
7156}
7157
7158/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307159 * send_pno_start_cmd_tlv() - PNO start request
7160 * @wmi_handle: wmi handle
7161 * @pno: PNO request
7162 *
7163 * This function request FW to start PNO request.
7164 * Request: CDF status
7165 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307166static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307167 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307168{
7169 wmi_nlo_config_cmd_fixed_param *cmd;
7170 nlo_configured_parameters *nlo_list;
7171 uint32_t *channel_list;
7172 int32_t len;
7173 wmi_buf_t buf;
7174 uint8_t *buf_ptr;
7175 uint8_t i;
7176 int ret;
7177
7178 /*
7179 * TLV place holder for array nlo_configured_parameters(nlo_list)
7180 * TLV place holder for array of uint32_t channel_list
7181 * TLV place holder for chnnl prediction cfg
7182 */
7183 len = sizeof(*cmd) +
7184 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7185
Abhishek Singh5987b632017-03-03 22:09:07 +05307186 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307187 WMI_NLO_MAX_CHAN);
7188 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307189 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307190 len += sizeof(nlo_channel_prediction_cfg);
7191
7192 buf = wmi_buf_alloc(wmi_handle, len);
7193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307194 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7195 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307196 }
7197
7198 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7199
7200 buf_ptr = (uint8_t *) cmd;
7201 WMITLV_SET_HDR(&cmd->tlv_header,
7202 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7203 WMITLV_GET_STRUCT_TLVLEN
7204 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307205 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307206 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7207
Govind Singh87542482016-06-08 19:40:11 +05307208#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307209 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307210 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307211#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307212 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307213 cmd->active_dwell_time = pno->active_dwell_time;
7214 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215
7216 /* Copy scan interval */
7217 cmd->fast_scan_period = pno->fast_scan_period;
7218 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007219 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007221 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307222 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307223 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307225
7226 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7227
Abhishek Singh5987b632017-03-03 22:09:07 +05307228 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307229 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307230 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7231 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7232 buf_ptr += WMI_TLV_HDR_SIZE;
7233
7234 nlo_list = (nlo_configured_parameters *) buf_ptr;
7235 for (i = 0; i < cmd->no_of_ssids; i++) {
7236 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7237 WMITLV_TAG_ARRAY_BYTE,
7238 WMITLV_GET_STRUCT_TLVLEN
7239 (nlo_configured_parameters));
7240 /* Copy ssid and it's length */
7241 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307242 nlo_list[i].ssid.ssid.ssid_len =
7243 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307244 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307245 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307246 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307247 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248 nlo_list[i].ssid.ssid.ssid_len,
7249 (char *)nlo_list[i].ssid.ssid.ssid,
7250 nlo_list[i].ssid.ssid.ssid_len);
7251
7252 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307253 if (pno->networks_list[i].rssi_thresh &&
7254 pno->networks_list[i].rssi_thresh >
7255 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307256 nlo_list[i].rssi_cond.valid = true;
7257 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307258 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307259 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307260 nlo_list[i].rssi_cond.rssi);
7261 }
7262 nlo_list[i].bcast_nw_type.valid = true;
7263 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307264 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007265 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307266 nlo_list[i].bcast_nw_type.bcast_nw_type);
7267 }
7268 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7269
7270 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307271 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307272 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307273 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7275 (cmd->num_of_channels * sizeof(uint32_t)));
7276 buf_ptr += WMI_TLV_HDR_SIZE;
7277
7278 channel_list = (uint32_t *) buf_ptr;
7279 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307280 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281
7282 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307283 channel_list[i] =
7284 wlan_chan_to_freq(pno->
7285 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307286
Govind Singhb53420c2016-03-09 14:32:57 +05307287 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307288 }
7289 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7290 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7291 sizeof(nlo_channel_prediction_cfg));
7292 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307293 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307294 buf_ptr += WMI_TLV_HDR_SIZE;
7295 /** TODO: Discrete firmware doesn't have command/option to configure
7296 * App IE which comes from wpa_supplicant as of part PNO start request.
7297 */
7298 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7299 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7300 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307301 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307302 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307303 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307304 }
7305
Govind Singhb53420c2016-03-09 14:32:57 +05307306 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307307}
7308
7309/* send_set_ric_req_cmd_tlv() - set ric request element
7310 * @wmi_handle: wmi handle
7311 * @msg: message
7312 * @is_add_ts: is addts required
7313 *
7314 * This function sets ric request element for 11r roaming.
7315 *
7316 * Return: CDF status
7317 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307318static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307319 void *msg, uint8_t is_add_ts)
7320{
7321 wmi_ric_request_fixed_param *cmd;
7322 wmi_ric_tspec *tspec_param;
7323 wmi_buf_t buf;
7324 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307325 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307326 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7327 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7328
7329 buf = wmi_buf_alloc(wmi_handle, len);
7330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307331 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7332 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307333 }
7334
7335 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7336
7337 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7338 WMITLV_SET_HDR(&cmd->tlv_header,
7339 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7340 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7341 if (is_add_ts)
7342 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7343 else
7344 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7345 cmd->num_ric_request = 1;
7346 cmd->is_add_ric = is_add_ts;
7347
7348 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7349 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7350
7351 buf_ptr += WMI_TLV_HDR_SIZE;
7352 tspec_param = (wmi_ric_tspec *) buf_ptr;
7353 WMITLV_SET_HDR(&tspec_param->tlv_header,
7354 WMITLV_TAG_STRUC_wmi_ric_tspec,
7355 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7356
7357 if (is_add_ts)
7358 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307359#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307360 else
7361 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307362#endif
7363 if (ptspecIE) {
7364 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307365#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307366 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7367 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307368#else
Govind Singh87542482016-06-08 19:40:11 +05307369 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7370 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307371#endif /* ANI_LITTLE_BIT_ENDIAN */
7372
Govind Singh87542482016-06-08 19:40:11 +05307373 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7374 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7375 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7376 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7377 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7378 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7379 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7380 tspec_param->min_data_rate = ptspecIE->minDataRate;
7381 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7382 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7383 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7384 tspec_param->delay_bound = ptspecIE->delayBound;
7385 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7386 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7387 tspec_param->medium_time = 0;
7388 }
Govind Singhb53420c2016-03-09 14:32:57 +05307389 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307390
7391 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7392 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307393 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307394 __func__);
7395 if (is_add_ts)
7396 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307397 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307398 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307399 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307400 }
7401
Govind Singhb53420c2016-03-09 14:32:57 +05307402 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307403}
7404
7405/**
7406 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7407 * @wmi_handle: wmi handle
7408 * @clear_req: ll stats clear request command params
7409 *
Govind Singhb53420c2016-03-09 14:32:57 +05307410 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307412static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307413 const struct ll_stats_clear_params *clear_req,
7414 uint8_t addr[IEEE80211_ADDR_LEN])
7415{
7416 wmi_clear_link_stats_cmd_fixed_param *cmd;
7417 int32_t len;
7418 wmi_buf_t buf;
7419 uint8_t *buf_ptr;
7420 int ret;
7421
7422 len = sizeof(*cmd);
7423 buf = wmi_buf_alloc(wmi_handle, len);
7424
7425 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307426 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7427 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307428 }
7429
7430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307431 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307432 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7433
7434 WMITLV_SET_HDR(&cmd->tlv_header,
7435 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7436 WMITLV_GET_STRUCT_TLVLEN
7437 (wmi_clear_link_stats_cmd_fixed_param));
7438
7439 cmd->stop_stats_collection_req = clear_req->stop_req;
7440 cmd->vdev_id = clear_req->sta_id;
7441 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7442
7443 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7444 &cmd->peer_macaddr);
7445
Govind Singhb53420c2016-03-09 14:32:57 +05307446 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7447 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7448 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7449 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7450 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307451 cmd->peer_macaddr); */
7452
7453 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7454 WMI_CLEAR_LINK_STATS_CMDID);
7455 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307456 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307457 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307458 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307459 }
7460
Govind Singhb53420c2016-03-09 14:32:57 +05307461 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7462 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307463}
7464
7465/**
7466 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7467 * @wmi_handle: wmi handle
7468 * @setReq: ll stats set request command params
7469 *
Govind Singhb53420c2016-03-09 14:32:57 +05307470 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307471 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307472static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307473 const struct ll_stats_set_params *set_req)
7474{
7475 wmi_start_link_stats_cmd_fixed_param *cmd;
7476 int32_t len;
7477 wmi_buf_t buf;
7478 uint8_t *buf_ptr;
7479 int ret;
7480
7481 len = sizeof(*cmd);
7482 buf = wmi_buf_alloc(wmi_handle, len);
7483
7484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307485 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7486 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307487 }
7488
7489 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307490 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307491 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7492
7493 WMITLV_SET_HDR(&cmd->tlv_header,
7494 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7495 WMITLV_GET_STRUCT_TLVLEN
7496 (wmi_start_link_stats_cmd_fixed_param));
7497
7498 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7499 cmd->aggressive_statistics_gathering =
7500 set_req->aggressive_statistics_gathering;
7501
Govind Singhb53420c2016-03-09 14:32:57 +05307502 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7503 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7504 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307505
7506 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7507 WMI_START_LINK_STATS_CMDID);
7508 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307509 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307510 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307511 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307512 }
7513
Govind Singhb53420c2016-03-09 14:32:57 +05307514 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307515}
7516
7517/**
7518 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7519 * @wmi_handle:wmi handle
7520 * @get_req:ll stats get request command params
7521 * @addr: mac address
7522 *
Govind Singhb53420c2016-03-09 14:32:57 +05307523 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307524 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307525static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307526 const struct ll_stats_get_params *get_req,
7527 uint8_t addr[IEEE80211_ADDR_LEN])
7528{
7529 wmi_request_link_stats_cmd_fixed_param *cmd;
7530 int32_t len;
7531 wmi_buf_t buf;
7532 uint8_t *buf_ptr;
7533 int ret;
7534
7535 len = sizeof(*cmd);
7536 buf = wmi_buf_alloc(wmi_handle, len);
7537
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307538 if (!buf) {
7539 WMI_LOGE("%s: buf allocation failed", __func__);
7540 return QDF_STATUS_E_NOMEM;
7541 }
7542
Govind Singh4eacd2b2016-03-07 14:24:22 +05307543 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307544 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307545 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7546
7547 WMITLV_SET_HDR(&cmd->tlv_header,
7548 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7549 WMITLV_GET_STRUCT_TLVLEN
7550 (wmi_request_link_stats_cmd_fixed_param));
7551
7552 cmd->request_id = get_req->req_id;
7553 cmd->stats_type = get_req->param_id_mask;
7554 cmd->vdev_id = get_req->sta_id;
7555
7556 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7557 &cmd->peer_macaddr);
7558
Govind Singhb53420c2016-03-09 14:32:57 +05307559 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007560 WMI_LOGD("Request ID : %u", cmd->request_id);
7561 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307562 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7563 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307564
7565 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7566 WMI_REQUEST_LINK_STATS_CMDID);
7567 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307568 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307569 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307570 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307571 }
7572
Govind Singhb53420c2016-03-09 14:32:57 +05307573 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307574}
7575
7576/**
7577 * send_get_stats_cmd_tlv() - get stats request
7578 * @wmi_handle: wmi handle
7579 * @get_stats_param: stats params
7580 * @addr: mac address
7581 *
7582 * Return: CDF status
7583 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307584static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307585 struct pe_stats_req *get_stats_param,
7586 uint8_t addr[IEEE80211_ADDR_LEN])
7587{
7588 wmi_buf_t buf;
7589 wmi_request_stats_cmd_fixed_param *cmd;
7590 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7591
7592 buf = wmi_buf_alloc(wmi_handle, len);
7593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307594 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7595 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307596 }
7597
7598
7599 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7600 WMITLV_SET_HDR(&cmd->tlv_header,
7601 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7602 WMITLV_GET_STRUCT_TLVLEN
7603 (wmi_request_stats_cmd_fixed_param));
Gurumoorthi Gnanasambandhan4aec3672017-07-10 11:55:23 +05307604 cmd->stats_id = get_stats_param->stats_mask;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307605 cmd->vdev_id = get_stats_param->session_id;
7606 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307607 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307608 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7609 WMI_REQUEST_STATS_CMDID)) {
7610
Govind Singhb53420c2016-03-09 14:32:57 +05307611 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307612 __func__);
7613 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307614 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307615 }
7616
Govind Singhb53420c2016-03-09 14:32:57 +05307617 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618
7619}
7620
Govind Singh20c5dac2016-03-07 15:33:31 +05307621/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307622 * send_congestion_cmd_tlv() - send request to fw to get CCA
7623 * @wmi_handle: wmi handle
7624 * @vdev_id: vdev id
7625 *
7626 * Return: CDF status
7627 */
7628static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7629 A_UINT8 vdev_id)
7630{
7631 wmi_buf_t buf;
7632 wmi_request_stats_cmd_fixed_param *cmd;
7633 uint8_t len;
7634 uint8_t *buf_ptr;
7635
7636 len = sizeof(*cmd);
7637 buf = wmi_buf_alloc(wmi_handle, len);
7638 if (!buf) {
7639 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7640 return QDF_STATUS_E_FAILURE;
7641 }
7642
7643 buf_ptr = wmi_buf_data(buf);
7644 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7645 WMITLV_SET_HDR(&cmd->tlv_header,
7646 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7647 WMITLV_GET_STRUCT_TLVLEN
7648 (wmi_request_stats_cmd_fixed_param));
7649
7650 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7651 cmd->vdev_id = vdev_id;
7652 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7653 cmd->vdev_id, cmd->stats_id);
7654
7655 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7656 WMI_REQUEST_STATS_CMDID)) {
7657 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7658 __func__);
7659 wmi_buf_free(buf);
7660 return QDF_STATUS_E_FAILURE;
7661 }
7662
7663 return QDF_STATUS_SUCCESS;
7664}
7665
7666/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307667 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7668 * @wmi_handle: wmi handle
7669 * @rssi_req: get RSSI request
7670 *
7671 * Return: CDF status
7672 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307673static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307674{
7675 wmi_buf_t buf;
7676 wmi_request_stats_cmd_fixed_param *cmd;
7677 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7678
7679 buf = wmi_buf_alloc(wmi_handle, len);
7680 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307681 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7682 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307683 }
7684
7685 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7686 WMITLV_SET_HDR(&cmd->tlv_header,
7687 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7688 WMITLV_GET_STRUCT_TLVLEN
7689 (wmi_request_stats_cmd_fixed_param));
7690 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7691 if (wmi_unified_cmd_send
7692 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307693 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307694 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307695 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307696 }
7697
Govind Singhb53420c2016-03-09 14:32:57 +05307698 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307699}
7700
7701/**
7702 * send_snr_cmd_tlv() - get RSSI from fw
7703 * @wmi_handle: wmi handle
7704 * @vdev_id: vdev id
7705 *
7706 * Return: CDF status
7707 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307708static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307709{
7710 wmi_buf_t buf;
7711 wmi_request_stats_cmd_fixed_param *cmd;
7712 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7713
7714 buf = wmi_buf_alloc(wmi_handle, len);
7715 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307716 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7717 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307718 }
7719
7720 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7721 cmd->vdev_id = vdev_id;
7722
7723 WMITLV_SET_HDR(&cmd->tlv_header,
7724 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7725 WMITLV_GET_STRUCT_TLVLEN
7726 (wmi_request_stats_cmd_fixed_param));
7727 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7728 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7729 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307730 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307731 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307732 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307733 }
7734
Govind Singhb53420c2016-03-09 14:32:57 +05307735 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307736}
7737
7738/**
7739 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7740 * @wmi_handle: wmi handle
7741 * @link_status: get link params
7742 *
7743 * Return: CDF status
7744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307745static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307746 struct link_status_params *link_status)
7747{
7748 wmi_buf_t buf;
7749 wmi_request_stats_cmd_fixed_param *cmd;
7750 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7751
7752 buf = wmi_buf_alloc(wmi_handle, len);
7753 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307754 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7755 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307756 }
7757
7758 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7759 WMITLV_SET_HDR(&cmd->tlv_header,
7760 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7761 WMITLV_GET_STRUCT_TLVLEN
7762 (wmi_request_stats_cmd_fixed_param));
7763 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7764 cmd->vdev_id = link_status->session_id;
7765 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7766 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307767 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307768 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307769 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307770 }
7771
Govind Singhb53420c2016-03-09 14:32:57 +05307772 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307773}
7774
Govind Singh20c5dac2016-03-07 15:33:31 +05307775/**
7776 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7777 * @wmi_handle: wmi handle
7778 * @ta_dhcp_ind: DHCP indication parameter
7779 *
7780 * Return: CDF Status
7781 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307782static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307783 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7784{
Govind Singh67922e82016-04-01 16:48:57 +05307785 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307786 wmi_buf_t buf = NULL;
7787 uint8_t *buf_ptr;
7788 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7789 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7790
7791
7792 buf = wmi_buf_alloc(wmi_handle, len);
7793 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307794 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7795 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307796 }
7797
7798 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7799 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7800 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7801 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7802 WMITLV_GET_STRUCT_TLVLEN
7803 (wmi_peer_set_param_cmd_fixed_param));
7804
7805 /* fill in values */
7806 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7807 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7808 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307809 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307810 &ta_dhcp_ind->peer_macaddr,
7811 sizeof(ta_dhcp_ind->peer_macaddr));
7812
7813 status = wmi_unified_cmd_send(wmi_handle, buf,
7814 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307815 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307816 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307817 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307818 wmi_buf_free(buf);
7819 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307820
Govind Singh67922e82016-04-01 16:48:57 +05307821 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307822}
7823
7824/**
7825 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7826 * @wmi_handle: wmi handle
7827 * @pLinkSpeed: link speed info
7828 *
7829 * Return: CDF status
7830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307831static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307832 wmi_mac_addr peer_macaddr)
7833{
7834 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7835 wmi_buf_t wmi_buf;
7836 uint32_t len;
7837 uint8_t *buf_ptr;
7838
7839 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7840 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7841 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307842 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7843 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307844 }
7845 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7846
7847 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7848 WMITLV_SET_HDR(&cmd->tlv_header,
7849 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7850 WMITLV_GET_STRUCT_TLVLEN
7851 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7852
7853 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307854 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307855 &peer_macaddr,
7856 sizeof(peer_macaddr));
7857
7858
7859 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7860 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307861 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307862 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307863 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307864 }
Govind Singhb53420c2016-03-09 14:32:57 +05307865 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307866}
7867
7868/**
7869 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7870 * @wmi_handle: wmi handler
7871 * @egap_params: pointer to egap_params
7872 *
7873 * Return: 0 for success, otherwise appropriate error code
7874 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307875static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307876 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7877{
7878 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7879 wmi_buf_t buf;
7880 int32_t err;
7881
7882 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307884 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7885 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307886 }
7887 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7888 WMITLV_SET_HDR(&cmd->tlv_header,
7889 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7890 WMITLV_GET_STRUCT_TLVLEN(
7891 wmi_ap_ps_egap_param_cmd_fixed_param));
7892
7893 cmd->enable = egap_params->enable;
7894 cmd->inactivity_time = egap_params->inactivity_time;
7895 cmd->wait_time = egap_params->wait_time;
7896 cmd->flags = egap_params->flags;
7897 err = wmi_unified_cmd_send(wmi_handle, buf,
7898 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7899 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307900 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307901 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307902 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307903 }
7904
Govind Singhb53420c2016-03-09 14:32:57 +05307905 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307906}
7907
7908/**
7909 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7910 * @wmi_handl: wmi handle
7911 * @cmd: Profiling command index
7912 * @value1: parameter1 value
7913 * @value2: parameter2 value
7914 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307915 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307916 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307917static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307918 uint32_t cmd, uint32_t value1, uint32_t value2)
7919{
7920 wmi_buf_t buf;
7921 int32_t len = 0;
7922 int ret;
7923 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7924 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7925 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7926 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7927
7928 switch (cmd) {
7929 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7930 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7931 buf = wmi_buf_alloc(wmi_handle, len);
7932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307934 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307935 }
7936 prof_trig_cmd =
7937 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7938 wmi_buf_data(buf);
7939 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7940 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7941 WMITLV_GET_STRUCT_TLVLEN
7942 (wmi_wlan_profile_trigger_cmd_fixed_param));
7943 prof_trig_cmd->enable = value1;
7944 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7945 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7946 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307947 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307948 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307949 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307950 return ret;
7951 }
7952 break;
7953
7954 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7955 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7956 buf = wmi_buf_alloc(wmi_handle, len);
7957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307958 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307959 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307960 }
7961 profile_getdata_cmd =
7962 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7963 wmi_buf_data(buf);
7964 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7965 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7966 WMITLV_GET_STRUCT_TLVLEN
7967 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7968 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7969 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7970 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307971 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307972 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307973 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307974 return ret;
7975 }
7976 break;
7977
7978 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7979 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7980 buf = wmi_buf_alloc(wmi_handle, len);
7981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307982 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307983 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307984 }
7985 hist_intvl_cmd =
7986 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7987 wmi_buf_data(buf);
7988 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7989 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7990 WMITLV_GET_STRUCT_TLVLEN
7991 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7992 hist_intvl_cmd->profile_id = value1;
7993 hist_intvl_cmd->value = value2;
7994 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7995 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7996 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307997 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307998 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307999 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 return ret;
8001 }
8002 break;
8003
8004 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8005 len =
8006 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8007 buf = wmi_buf_alloc(wmi_handle, len);
8008 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308009 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308010 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308011 }
8012 profile_enable_cmd =
8013 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8014 wmi_buf_data(buf);
8015 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8016 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8017 WMITLV_GET_STRUCT_TLVLEN
8018 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8019 profile_enable_cmd->profile_id = value1;
8020 profile_enable_cmd->enable = value2;
8021 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8022 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8023 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308024 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308025 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308026 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308027 return ret;
8028 }
8029 break;
8030
8031 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308032 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308033 break;
8034 }
8035
8036 return 0;
8037}
8038
Govind Singh20c5dac2016-03-07 15:33:31 +05308039/**
8040 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8041 * @wmi_handle: wmi handle
8042 * @vdev_id: vdev id
8043 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308044 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308045 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308046static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308047{
8048 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8049 wmi_buf_t buf;
8050 int32_t len = sizeof(*cmd);
8051
Govind Singhb53420c2016-03-09 14:32:57 +05308052 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308053 buf = wmi_buf_alloc(wmi_handle, len);
8054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308055 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308056 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308057 }
8058 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8059 wmi_buf_data(buf);
8060 WMITLV_SET_HDR(&cmd->tlv_header,
8061 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8062 WMITLV_GET_STRUCT_TLVLEN
8063 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8064 cmd->vdev_id = vdev_id;
8065 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8066 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8067 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308068 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308069 __func__);
8070 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308071 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308072 }
8073
8074 return 0;
8075}
8076
8077/**
8078 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8079 * @wmi_handle: wmi handle
8080 * @vdev_id: vdev id
8081 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308082 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308083 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308084static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308085 uint8_t vdev_id)
8086{
8087 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8088 wmi_buf_t buf;
8089 int32_t len = sizeof(*cmd);
8090
Govind Singhb53420c2016-03-09 14:32:57 +05308091 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308092 buf = wmi_buf_alloc(wmi_handle, len);
8093 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308094 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308095 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308096 }
8097 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8098 WMITLV_SET_HDR(&cmd->tlv_header,
8099 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8100 WMITLV_GET_STRUCT_TLVLEN
8101 (wmi_csa_offload_enable_cmd_fixed_param));
8102 cmd->vdev_id = vdev_id;
8103 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8104 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8105 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308106 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308107 __func__);
8108 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308109 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308110 }
8111
8112 return 0;
8113}
8114
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008115#ifdef WLAN_FEATURE_CIF_CFR
8116/**
8117 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8118 * @wmi_handle: wmi handle
8119 * @data_len: len of dma cfg req
8120 * @data: dma cfg req
8121 *
8122 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8123 */
8124static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8125 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8126{
8127 wmi_buf_t buf;
8128 uint8_t *cmd;
8129 QDF_STATUS ret;
8130
8131 WMITLV_SET_HDR(cfg,
8132 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8133 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8134
8135 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8136 if (!buf) {
8137 WMI_LOGE(FL("wmi_buf_alloc failed"));
8138 return QDF_STATUS_E_FAILURE;
8139 }
8140
8141 cmd = (uint8_t *) wmi_buf_data(buf);
8142 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8143 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8144 sizeof(*cfg));
8145 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8146 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8147 if (QDF_IS_STATUS_ERROR(ret)) {
8148 WMI_LOGE(FL(":wmi cmd send failed"));
8149 wmi_buf_free(buf);
8150 }
8151
8152 return ret;
8153}
8154#endif
8155
Govind Singh20c5dac2016-03-07 15:33:31 +05308156/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008157 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8158 * @wmi_handle: wmi handle
8159 * @start_11d_scan: 11d scan start request parameters
8160 *
8161 * This function request FW to start 11d scan.
8162 *
8163 * Return: QDF status
8164 */
8165static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8166 struct reg_start_11d_scan_req *start_11d_scan)
8167{
8168 wmi_11d_scan_start_cmd_fixed_param *cmd;
8169 int32_t len;
8170 wmi_buf_t buf;
8171 int ret;
8172
8173 len = sizeof(*cmd);
8174 buf = wmi_buf_alloc(wmi_handle, len);
8175 if (!buf) {
8176 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8177 return QDF_STATUS_E_NOMEM;
8178 }
8179
8180 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8181
8182 WMITLV_SET_HDR(&cmd->tlv_header,
8183 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8184 WMITLV_GET_STRUCT_TLVLEN
8185 (wmi_11d_scan_start_cmd_fixed_param));
8186
8187 cmd->vdev_id = start_11d_scan->vdev_id;
8188 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8189 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8190
8191 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8192
8193 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8194 WMI_11D_SCAN_START_CMDID);
8195 if (ret) {
8196 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8197 wmi_buf_free(buf);
8198 return QDF_STATUS_E_FAILURE;
8199 }
8200
8201 return QDF_STATUS_SUCCESS;
8202}
8203
8204/**
8205 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8206 * @wmi_handle: wmi handle
8207 * @start_11d_scan: 11d scan stop request parameters
8208 *
8209 * This function request FW to stop 11d scan.
8210 *
8211 * Return: QDF status
8212 */
8213static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8214 struct reg_stop_11d_scan_req *stop_11d_scan)
8215{
8216 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8217 int32_t len;
8218 wmi_buf_t buf;
8219 int ret;
8220
8221 len = sizeof(*cmd);
8222 buf = wmi_buf_alloc(wmi_handle, len);
8223 if (!buf) {
8224 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8225 return QDF_STATUS_E_NOMEM;
8226 }
8227
8228 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8229
8230 WMITLV_SET_HDR(&cmd->tlv_header,
8231 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8232 WMITLV_GET_STRUCT_TLVLEN
8233 (wmi_11d_scan_stop_cmd_fixed_param));
8234
8235 cmd->vdev_id = stop_11d_scan->vdev_id;
8236
8237 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8238
8239 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8240 WMI_11D_SCAN_STOP_CMDID);
8241 if (ret) {
8242 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8243 wmi_buf_free(buf);
8244 return QDF_STATUS_E_FAILURE;
8245 }
8246
8247 return QDF_STATUS_SUCCESS;
8248}
8249
8250/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308251 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8252 * @wmi_handle: wmi handle
8253 * @startOemDataReq: start request params
8254 *
8255 * Return: CDF status
8256 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308257static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008258 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308259 uint8_t *data)
8260{
8261 wmi_buf_t buf;
8262 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308263 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308264
8265 buf = wmi_buf_alloc(wmi_handle,
8266 (data_len + WMI_TLV_HDR_SIZE));
8267 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308268 WMI_LOGE(FL("wmi_buf_alloc failed"));
8269 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308270 }
8271
8272 cmd = (uint8_t *) wmi_buf_data(buf);
8273
8274 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8275 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308276 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308277 data_len);
8278
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008279 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308280 data_len);
8281
8282 ret = wmi_unified_cmd_send(wmi_handle, buf,
8283 (data_len +
8284 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8285
Govind Singh67922e82016-04-01 16:48:57 +05308286 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308287 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308288 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308289 }
8290
Govind Singh67922e82016-04-01 16:48:57 +05308291 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308292}
8293
8294/**
8295 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8296 * @wmi_handle: wmi handle
8297 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8298 *
8299 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8300 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8301 * to firmware based on phyerr filtering
8302 * offload status.
8303 *
8304 * Return: 1 success, 0 failure
8305 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308306static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308307send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8308 bool dfs_phyerr_filter_offload)
8309{
8310 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8311 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8312 wmi_buf_t buf;
8313 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308314 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308315
8316
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008317 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308318 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308319 __func__);
8320 len = sizeof(*disable_phyerr_offload_cmd);
8321 buf = wmi_buf_alloc(wmi_handle, len);
8322 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308323 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308324 return 0;
8325 }
8326 disable_phyerr_offload_cmd =
8327 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8328 wmi_buf_data(buf);
8329
8330 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8331 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8332 WMITLV_GET_STRUCT_TLVLEN
8333 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8334
8335 /*
8336 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8337 * to the firmware to disable the phyerror
8338 * filtering offload.
8339 */
8340 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8341 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308342 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308343 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308344 __func__, ret);
8345 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308346 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 }
Govind Singhb53420c2016-03-09 14:32:57 +05308348 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308349 __func__);
8350 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308351 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308352 __func__);
8353
8354 len = sizeof(*enable_phyerr_offload_cmd);
8355 buf = wmi_buf_alloc(wmi_handle, len);
8356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308357 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8358 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 }
8360
8361 enable_phyerr_offload_cmd =
8362 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8363 wmi_buf_data(buf);
8364
8365 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8366 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8367 WMITLV_GET_STRUCT_TLVLEN
8368 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8369
8370 /*
8371 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8372 * to the firmware to enable the phyerror
8373 * filtering offload.
8374 */
8375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8376 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8377
Govind Singh67922e82016-04-01 16:48:57 +05308378 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308379 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308380 __func__, ret);
8381 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308382 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308383 }
Govind Singhb53420c2016-03-09 14:32:57 +05308384 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308385 __func__);
8386 }
8387
Govind Singhb53420c2016-03-09 14:32:57 +05308388 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308389}
8390
8391#if !defined(REMOVE_PKT_LOG)
8392/**
8393 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8394 * @wmi_handle: wmi handle
8395 * @pktlog_event: pktlog event
8396 * @cmd_id: pktlog cmd id
8397 *
8398 * Return: CDF status
8399 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308400static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308401 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308402 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308403{
8404 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8405 WMI_CMD_ID CMD_ID;
8406 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8407 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8408 int len = 0;
8409 wmi_buf_t buf;
8410
8411 PKTLOG_EVENT = pktlog_event;
8412 CMD_ID = cmd_id;
8413
8414 switch (CMD_ID) {
8415 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8416 len = sizeof(*cmd);
8417 buf = wmi_buf_alloc(wmi_handle, len);
8418 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308419 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8420 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308421 }
8422 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8423 wmi_buf_data(buf);
8424 WMITLV_SET_HDR(&cmd->tlv_header,
8425 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8426 WMITLV_GET_STRUCT_TLVLEN
8427 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8428 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308429 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8430 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308431 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8432 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308433 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8434 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308435 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308436 goto wmi_send_failed;
8437 }
8438 break;
8439 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8440 len = sizeof(*disable_cmd);
8441 buf = wmi_buf_alloc(wmi_handle, len);
8442 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308443 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8444 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308445 }
8446 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8447 wmi_buf_data(buf);
8448 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8449 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8450 WMITLV_GET_STRUCT_TLVLEN
8451 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308452 disable_cmd->pdev_id =
8453 wmi_handle->ops->convert_pdev_id_host_to_target(
8454 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308455 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8456 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308457 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308458 goto wmi_send_failed;
8459 }
8460 break;
8461 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308462 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308463 break;
8464 }
8465
Govind Singhb53420c2016-03-09 14:32:57 +05308466 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308467
8468wmi_send_failed:
8469 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308470 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308471}
8472#endif /* REMOVE_PKT_LOG */
8473
8474/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308475 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8476 * @wmi_handle: wmi handle
8477 * @ptrn_id: pattern id
8478 * @vdev_id: vdev id
8479 *
8480 * Return: CDF status
8481 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308482static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8483 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308484{
8485 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8486 wmi_buf_t buf;
8487 int32_t len;
8488 int ret;
8489
8490 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8491
8492
8493 buf = wmi_buf_alloc(wmi_handle, len);
8494 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308495 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8496 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308497 }
8498
8499 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8500
8501 WMITLV_SET_HDR(&cmd->tlv_header,
8502 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8503 WMITLV_GET_STRUCT_TLVLEN(
8504 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8505 cmd->vdev_id = vdev_id;
8506 cmd->pattern_id = ptrn_id;
8507 cmd->pattern_type = WOW_BITMAP_PATTERN;
8508
Govind Singhb53420c2016-03-09 14:32:57 +05308509 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308510 cmd->pattern_id, vdev_id);
8511
8512 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8513 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8514 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308515 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308516 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308517 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308518 }
8519
Govind Singhb53420c2016-03-09 14:32:57 +05308520 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308521}
8522
8523/**
8524 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8525 * @wmi_handle: wmi handle
8526 *
8527 * Sends host wakeup indication to FW. On receiving this indication,
8528 * FW will come out of WOW.
8529 *
8530 * Return: CDF status
8531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308532static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308533{
8534 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8535 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308536 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308537 int32_t len;
8538 int ret;
8539
8540 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8541
8542 buf = wmi_buf_alloc(wmi_handle, len);
8543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308544 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8545 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308546 }
8547
8548 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8549 wmi_buf_data(buf);
8550 WMITLV_SET_HDR(&cmd->tlv_header,
8551 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8552 WMITLV_GET_STRUCT_TLVLEN
8553 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8554
8555
8556 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8557 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8558 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308559 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308561 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308562 }
8563
Govind Singhb53420c2016-03-09 14:32:57 +05308564 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308565}
8566
8567/**
8568 * send_del_ts_cmd_tlv() - send DELTS request to fw
8569 * @wmi_handle: wmi handle
8570 * @msg: delts params
8571 *
8572 * Return: CDF status
8573 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308574static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308575 uint8_t ac)
8576{
8577 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8578 wmi_buf_t buf;
8579 int32_t len = sizeof(*cmd);
8580
8581 buf = wmi_buf_alloc(wmi_handle, len);
8582 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308583 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8584 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308585 }
8586 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8587 WMITLV_SET_HDR(&cmd->tlv_header,
8588 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8589 WMITLV_GET_STRUCT_TLVLEN
8590 (wmi_vdev_wmm_delts_cmd_fixed_param));
8591 cmd->vdev_id = vdev_id;
8592 cmd->ac = ac;
8593
Govind Singhb53420c2016-03-09 14:32:57 +05308594 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8596 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8597 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308598 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308599 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308600 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308601 }
8602
Govind Singhb53420c2016-03-09 14:32:57 +05308603 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308604}
8605
8606/**
8607 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8608 * @wmi_handle: handle to wmi
8609 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8610 *
Govind Singhb53420c2016-03-09 14:32:57 +05308611 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308612 * ADD_TS requestes to firmware in loop for all the ACs with
8613 * active flow.
8614 *
8615 * Return: CDF status
8616 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308617static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308618 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8619{
8620 int i = 0;
8621 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8622 wmi_buf_t buf;
8623 int32_t len = sizeof(*cmd);
8624
8625 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8626 /* if flow in this AC is active */
8627 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8628 /*
8629 * as per implementation of wma_add_ts_req() we
8630 * are not waiting any response from firmware so
8631 * apart from sending ADDTS to firmware just send
8632 * success to upper layers
8633 */
Govind Singhb53420c2016-03-09 14:32:57 +05308634 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308635
8636 buf = wmi_buf_alloc(wmi_handle, len);
8637 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308638 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8639 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308640 }
8641 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8642 wmi_buf_data(buf);
8643 WMITLV_SET_HDR(&cmd->tlv_header,
8644 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8645 WMITLV_GET_STRUCT_TLVLEN
8646 (wmi_vdev_wmm_addts_cmd_fixed_param));
8647 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8648 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308649 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308650 traffic.userPrio);
8651 cmd->medium_time_us =
8652 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8653 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308654 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308655 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8656 cmd->medium_time_us, cmd->downgrade_type);
8657 if (wmi_unified_cmd_send
8658 (wmi_handle, buf, len,
8659 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308660 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308661 __func__);
8662 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308663 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308664 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308665 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308666 }
8667 }
8668 }
8669
Govind Singhb53420c2016-03-09 14:32:57 +05308670 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308671}
8672
8673/**
8674 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8675 * @wmi_handle: wmi handle
8676 * @msg: ADDTS params
8677 *
8678 * Return: CDF status
8679 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308680static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308681 struct add_ts_param *msg)
8682{
8683 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8684 wmi_buf_t buf;
8685 int32_t len = sizeof(*cmd);
8686
Govind Singhb53420c2016-03-09 14:32:57 +05308687 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308688
8689 buf = wmi_buf_alloc(wmi_handle, len);
8690 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308691 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8692 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308693 }
8694 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8695 WMITLV_SET_HDR(&cmd->tlv_header,
8696 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8697 WMITLV_GET_STRUCT_TLVLEN
8698 (wmi_vdev_wmm_addts_cmd_fixed_param));
8699 cmd->vdev_id = msg->sme_session_id;
8700 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8701 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8702 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308703 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308704 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8705 cmd->downgrade_type, __func__, __LINE__);
8706 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8707 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308708 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8709 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308710 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308711 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 }
8713
Govind Singhb53420c2016-03-09 14:32:57 +05308714 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308715}
8716
8717/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308718 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8719 * @wmi_handle: wmi handle
8720 * @pAddPeriodicTxPtrnParams: tx ptrn params
8721 *
8722 * Retrun: CDF status
8723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308724static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308725 struct periodic_tx_pattern *
8726 pAddPeriodicTxPtrnParams,
8727 uint8_t vdev_id)
8728{
8729 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8730 wmi_buf_t wmi_buf;
8731 uint32_t len;
8732 uint8_t *buf_ptr;
8733 uint32_t ptrn_len, ptrn_len_aligned;
8734 int j;
8735
8736 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8737 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8738 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8739 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8740
8741 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8742 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308743 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8744 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 }
8746
8747 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8748
8749 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8750 WMITLV_SET_HDR(&cmd->tlv_header,
8751 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8752 WMITLV_GET_STRUCT_TLVLEN
8753 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8754
8755 /* Pass the pattern id to delete for the corresponding vdev id */
8756 cmd->vdev_id = vdev_id;
8757 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8758 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8759 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8760
8761 /* Pattern info */
8762 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8763 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8764 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308765 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308766 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308767 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308768
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308770 __func__, cmd->pattern_id, cmd->vdev_id);
8771
8772 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8773 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308774 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308775 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308776 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308777 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308778 }
Govind Singhb53420c2016-03-09 14:32:57 +05308779 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308780}
8781
8782/**
8783 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8784 * @wmi_handle: wmi handle
8785 * @vdev_id: vdev id
8786 * @pattern_id: pattern id
8787 *
8788 * Retrun: CDF status
8789 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308790static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308791 uint8_t vdev_id,
8792 uint8_t pattern_id)
8793{
8794 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8795 wmi_buf_t wmi_buf;
8796 uint32_t len =
8797 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8798
8799 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8800 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308801 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8802 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308803 }
8804
8805 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8806 wmi_buf_data(wmi_buf);
8807 WMITLV_SET_HDR(&cmd->tlv_header,
8808 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8809 WMITLV_GET_STRUCT_TLVLEN
8810 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8811
8812 /* Pass the pattern id to delete for the corresponding vdev id */
8813 cmd->vdev_id = vdev_id;
8814 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308815 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308816 __func__, cmd->pattern_id, cmd->vdev_id);
8817
8818 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8819 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308820 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308821 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308822 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308823 }
Govind Singhb53420c2016-03-09 14:32:57 +05308824 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308825}
8826
8827/**
8828 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8829 * @wmi_handle: wmi handle
8830 * @preq: stats ext params
8831 *
8832 * Return: CDF status
8833 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308834static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308835 struct stats_ext_params *preq)
8836{
Govind Singh67922e82016-04-01 16:48:57 +05308837 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308838 wmi_req_stats_ext_cmd_fixed_param *cmd;
8839 wmi_buf_t buf;
8840 uint16_t len;
8841 uint8_t *buf_ptr;
8842
8843 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8844
8845 buf = wmi_buf_alloc(wmi_handle, len);
8846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308847 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308848 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308849 }
8850
8851 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8852 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8853
8854 WMITLV_SET_HDR(&cmd->tlv_header,
8855 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8856 WMITLV_GET_STRUCT_TLVLEN
8857 (wmi_req_stats_ext_cmd_fixed_param));
8858 cmd->vdev_id = preq->vdev_id;
8859 cmd->data_len = preq->request_data_len;
8860
Govind Singhb53420c2016-03-09 14:32:57 +05308861 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308862 __func__, preq->request_data_len, preq->vdev_id);
8863
8864 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8865 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8866
8867 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308868 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308869
8870 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8871 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308872 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308873 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308874 ret);
8875 wmi_buf_free(buf);
8876 }
8877
8878 return ret;
8879}
8880
8881/**
8882 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8883 * @wmi_handle: wmi handle
8884 * @params: ext wow params
8885 *
8886 * Return:0 for success or error code
8887 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308888static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308889 struct ext_wow_params *params)
8890{
8891 wmi_extwow_enable_cmd_fixed_param *cmd;
8892 wmi_buf_t buf;
8893 int32_t len;
8894 int ret;
8895
8896 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8897 buf = wmi_buf_alloc(wmi_handle, len);
8898 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308899 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8900 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308901 }
8902
8903 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8904
8905 WMITLV_SET_HDR(&cmd->tlv_header,
8906 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8907 WMITLV_GET_STRUCT_TLVLEN
8908 (wmi_extwow_enable_cmd_fixed_param));
8909
8910 cmd->vdev_id = params->vdev_id;
8911 cmd->type = params->type;
8912 cmd->wakeup_pin_num = params->wakeup_pin_num;
8913
Govind Singhb53420c2016-03-09 14:32:57 +05308914 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308915 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8916
8917 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8918 WMI_EXTWOW_ENABLE_CMDID);
8919 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308920 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308921 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308922 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308923 }
8924
Govind Singhb53420c2016-03-09 14:32:57 +05308925 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308926
8927}
8928
8929/**
8930 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8931 * @wmi_handle: wmi handle
8932 * @app_type1_params: app type1 params
8933 *
8934 * Return: CDF status
8935 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308936static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308937 struct app_type1_params *app_type1_params)
8938{
8939 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8940 wmi_buf_t buf;
8941 int32_t len;
8942 int ret;
8943
8944 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8945 buf = wmi_buf_alloc(wmi_handle, len);
8946 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308947 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8948 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308949 }
8950
8951 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8952 wmi_buf_data(buf);
8953
8954 WMITLV_SET_HDR(&cmd->tlv_header,
8955 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8956 WMITLV_GET_STRUCT_TLVLEN
8957 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8958
8959 cmd->vdev_id = app_type1_params->vdev_id;
8960 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8961 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308962 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308963 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308964 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308965 cmd->passwd_len = app_type1_params->pass_length;
8966
Govind Singhb53420c2016-03-09 14:32:57 +05308967 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308968 "identification_id %.8s id_length %u "
8969 "password %.16s pass_length %u",
8970 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8971 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8972
8973 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8974 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8975 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308976 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308977 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308978 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308979 }
8980
Govind Singhb53420c2016-03-09 14:32:57 +05308981 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308982}
8983
8984/**
8985 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8986 * @wmi_handle: wmi handle
8987 * @appType2Params: app type2 params
8988 *
8989 * Return: CDF status
8990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308991static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308992 struct app_type2_params *appType2Params)
8993{
8994 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8995 wmi_buf_t buf;
8996 int32_t len;
8997 int ret;
8998
8999 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9000 buf = wmi_buf_alloc(wmi_handle, len);
9001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309002 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9003 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309004 }
9005
9006 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9007 wmi_buf_data(buf);
9008
9009 WMITLV_SET_HDR(&cmd->tlv_header,
9010 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9011 WMITLV_GET_STRUCT_TLVLEN
9012 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9013
9014 cmd->vdev_id = appType2Params->vdev_id;
9015
Govind Singhb53420c2016-03-09 14:32:57 +05309016 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 cmd->rc4_key_len = appType2Params->rc4_key_len;
9018
9019 cmd->ip_id = appType2Params->ip_id;
9020 cmd->ip_device_ip = appType2Params->ip_device_ip;
9021 cmd->ip_server_ip = appType2Params->ip_server_ip;
9022
9023 cmd->tcp_src_port = appType2Params->tcp_src_port;
9024 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9025 cmd->tcp_seq = appType2Params->tcp_seq;
9026 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9027
9028 cmd->keepalive_init = appType2Params->keepalive_init;
9029 cmd->keepalive_min = appType2Params->keepalive_min;
9030 cmd->keepalive_max = appType2Params->keepalive_max;
9031 cmd->keepalive_inc = appType2Params->keepalive_inc;
9032
9033 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9034 &cmd->gateway_mac);
9035 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9036 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9037
Govind Singhb53420c2016-03-09 14:32:57 +05309038 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309039 "rc4_key %.16s rc4_key_len %u "
9040 "ip_id %x ip_device_ip %x ip_server_ip %x "
9041 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9042 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9043 "keepalive_max %u keepalive_inc %u "
9044 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9045 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9046 cmd->rc4_key, cmd->rc4_key_len,
9047 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9048 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9049 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9050 cmd->keepalive_max, cmd->keepalive_inc,
9051 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9052
9053 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9054 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9055 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309056 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309057 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309059 }
9060
Govind Singhb53420c2016-03-09 14:32:57 +05309061 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309062
9063}
9064
9065/**
9066 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9067 * @wmi_handle: wmi handle
9068 * @timer_val: auto shutdown timer value
9069 *
9070 * Return: CDF status
9071 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309072static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309073 uint32_t timer_val)
9074{
Govind Singh67922e82016-04-01 16:48:57 +05309075 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 wmi_buf_t buf = NULL;
9077 uint8_t *buf_ptr;
9078 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9079 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9080
Govind Singhb53420c2016-03-09 14:32:57 +05309081 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309082 __func__, timer_val);
9083
9084 buf = wmi_buf_alloc(wmi_handle, len);
9085 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309086 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9087 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309088 }
9089
9090 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9091 wmi_auto_sh_cmd =
9092 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9093 wmi_auto_sh_cmd->timer_value = timer_val;
9094
9095 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9096 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9097 WMITLV_GET_STRUCT_TLVLEN
9098 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9099
9100 status = wmi_unified_cmd_send(wmi_handle, buf,
9101 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309102 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309103 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 __func__, status);
9105 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309106 }
9107
Govind Singh67922e82016-04-01 16:48:57 +05309108 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309109}
9110
9111/**
9112 * send_nan_req_cmd_tlv() - to send nan request to target
9113 * @wmi_handle: wmi handle
9114 * @nan_req: request data which will be non-null
9115 *
9116 * Return: CDF status
9117 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309118static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309119 struct nan_req_params *nan_req)
9120{
Govind Singh67922e82016-04-01 16:48:57 +05309121 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309122 wmi_nan_cmd_param *cmd;
9123 wmi_buf_t buf;
9124 uint16_t len = sizeof(*cmd);
9125 uint16_t nan_data_len, nan_data_len_aligned;
9126 uint8_t *buf_ptr;
9127
9128 /*
9129 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9130 * +------------+----------+-----------------------+--------------+
9131 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9132 * +------------+----------+-----------------------+--------------+
9133 */
9134 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309135 WMI_LOGE("%s:nan req is not valid", __func__);
9136 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309137 }
9138 nan_data_len = nan_req->request_data_len;
9139 nan_data_len_aligned = roundup(nan_req->request_data_len,
9140 sizeof(uint32_t));
9141 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9142 buf = wmi_buf_alloc(wmi_handle, len);
9143 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309144 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9145 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309146 }
9147 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9148 cmd = (wmi_nan_cmd_param *) buf_ptr;
9149 WMITLV_SET_HDR(&cmd->tlv_header,
9150 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9151 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9152 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309153 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309154 __func__, nan_req->request_data_len);
9155 buf_ptr += sizeof(wmi_nan_cmd_param);
9156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9157 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309158 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309159
9160 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9161 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309162 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309163 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309164 __func__, ret);
9165 wmi_buf_free(buf);
9166 }
9167
9168 return ret;
9169}
9170
9171/**
9172 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9173 * @wmi_handle: wmi handle
9174 * @pDhcpSrvOffloadInfo: DHCP server offload info
9175 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309176 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309177 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309178static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309179 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9180{
9181 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9182 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309183 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309184
9185 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309187 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309189 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 }
9191
9192 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309193 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309194
9195 WMITLV_SET_HDR(&cmd->tlv_header,
9196 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9197 WMITLV_GET_STRUCT_TLVLEN
9198 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9199 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9200 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9201 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9202 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9203 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309204 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309205 sizeof(*cmd),
9206 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309207 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309208 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309209 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309210 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309211 }
Govind Singhb53420c2016-03-09 14:32:57 +05309212 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309213 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309214
9215 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309216}
9217
9218/**
9219 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9220 * @wmi_handle: wmi handle
9221 * @flashing: flashing request
9222 *
9223 * Return: CDF status
9224 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309225static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309226 struct flashing_req_params *flashing)
9227{
9228 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309229 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309230 wmi_buf_t buf;
9231 uint8_t *buf_ptr;
9232 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9233
9234 buf = wmi_buf_alloc(wmi_handle, len);
9235 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309236 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309237 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309238 }
9239 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9240 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9241 WMITLV_SET_HDR(&cmd->tlv_header,
9242 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9243 WMITLV_GET_STRUCT_TLVLEN
9244 (wmi_set_led_flashing_cmd_fixed_param));
9245 cmd->pattern_id = flashing->pattern_id;
9246 cmd->led_x0 = flashing->led_x0;
9247 cmd->led_x1 = flashing->led_x1;
9248
9249 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9250 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309251 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309252 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309254 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309255 }
Govind Singh67922e82016-04-01 16:48:57 +05309256
9257 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309258}
9259
9260/**
9261 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9262 * @wmi_handle: wmi handle
9263 * @ch_avoid_update_req: channel avoid update params
9264 *
9265 * Return: CDF status
9266 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309267static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309268{
Govind Singh67922e82016-04-01 16:48:57 +05309269 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309270 wmi_buf_t buf = NULL;
9271 uint8_t *buf_ptr;
9272 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9273 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9274
9275
9276 buf = wmi_buf_alloc(wmi_handle, len);
9277 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309278 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9279 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309280 }
9281
9282 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9283 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9284 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9285 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9286 WMITLV_GET_STRUCT_TLVLEN
9287 (wmi_chan_avoid_update_cmd_param));
9288
9289 status = wmi_unified_cmd_send(wmi_handle, buf,
9290 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309291 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309292 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309293 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9294 " returned Error %d", status);
9295 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309296 }
9297
Govind Singh67922e82016-04-01 16:48:57 +05309298 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309299}
9300
9301/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309302 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9303 * @wmi_handle: wmi handle
9304 * @param: pointer to pdev regdomain params
9305 *
9306 * Return: 0 for success or error code
9307 */
9308static QDF_STATUS
9309send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9310 struct pdev_set_regdomain_params *param)
9311{
9312 wmi_buf_t buf;
9313 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9314 int32_t len = sizeof(*cmd);
9315
9316
9317 buf = wmi_buf_alloc(wmi_handle, len);
9318 if (!buf) {
9319 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9320 return QDF_STATUS_E_NOMEM;
9321 }
9322 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9323 WMITLV_SET_HDR(&cmd->tlv_header,
9324 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9325 WMITLV_GET_STRUCT_TLVLEN
9326 (wmi_pdev_set_regdomain_cmd_fixed_param));
9327
9328 cmd->reg_domain = param->currentRDinuse;
9329 cmd->reg_domain_2G = param->currentRD2G;
9330 cmd->reg_domain_5G = param->currentRD5G;
9331 cmd->conformance_test_limit_2G = param->ctl_2G;
9332 cmd->conformance_test_limit_5G = param->ctl_5G;
9333 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309334 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9335 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309336
9337 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9338 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9339 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9340 __func__);
9341 wmi_buf_free(buf);
9342 return QDF_STATUS_E_FAILURE;
9343 }
9344
9345 return QDF_STATUS_SUCCESS;
9346}
9347
9348/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309349 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9350 * @wmi_handle: wmi handle
9351 * @reg_dmn: reg domain
9352 * @regdmn2G: 2G reg domain
9353 * @regdmn5G: 5G reg domain
9354 * @ctl2G: 2G test limit
9355 * @ctl5G: 5G test limit
9356 *
9357 * Return: none
9358 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309359static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309360 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309361 uint16_t regdmn5G, uint8_t ctl2G,
9362 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309363{
9364 wmi_buf_t buf;
9365 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9366 int32_t len = sizeof(*cmd);
9367
9368
9369 buf = wmi_buf_alloc(wmi_handle, len);
9370 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309371 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9372 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309373 }
9374 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9375 WMITLV_SET_HDR(&cmd->tlv_header,
9376 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9377 WMITLV_GET_STRUCT_TLVLEN
9378 (wmi_pdev_set_regdomain_cmd_fixed_param));
9379 cmd->reg_domain = reg_dmn;
9380 cmd->reg_domain_2G = regdmn2G;
9381 cmd->reg_domain_5G = regdmn5G;
9382 cmd->conformance_test_limit_2G = ctl2G;
9383 cmd->conformance_test_limit_5G = ctl5G;
9384
9385 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9386 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309387 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309388 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309389 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309390 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 }
9392
Govind Singhb53420c2016-03-09 14:32:57 +05309393 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309394}
9395
9396
9397/**
9398 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9399 * @wmi_handle: wmi handle
9400 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9401 *
9402 * This function sets tdls off channel mode
9403 *
9404 * Return: 0 on success; Negative errno otherwise
9405 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309406static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309407 struct tdls_channel_switch_params *chan_switch_params)
9408{
9409 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9410 wmi_buf_t wmi_buf;
9411 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9412
9413 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9414 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309415 WMI_LOGE(FL("wmi_buf_alloc failed"));
9416 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309417 }
9418 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9419 wmi_buf_data(wmi_buf);
9420 WMITLV_SET_HDR(&cmd->tlv_header,
9421 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9422 WMITLV_GET_STRUCT_TLVLEN(
9423 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9424
9425 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9426 &cmd->peer_macaddr);
9427 cmd->vdev_id = chan_switch_params->vdev_id;
9428 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9429 cmd->is_peer_responder = chan_switch_params->is_responder;
9430 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9431 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9432 cmd->offchan_oper_class = chan_switch_params->oper_class;
9433
Govind Singhb53420c2016-03-09 14:32:57 +05309434 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309435 cmd->peer_macaddr.mac_addr31to0,
9436 cmd->peer_macaddr.mac_addr47to32);
9437
Govind Singhb53420c2016-03-09 14:32:57 +05309438 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309439 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9440 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9441 ),
9442 cmd->vdev_id,
9443 cmd->offchan_mode,
9444 cmd->offchan_num,
9445 cmd->offchan_bw_bitmap,
9446 cmd->is_peer_responder,
9447 cmd->offchan_oper_class);
9448
9449 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9450 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309451 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309452 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309453 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 }
9455
9456
Govind Singhb53420c2016-03-09 14:32:57 +05309457 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309458}
9459
9460/**
9461 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9462 * @wmi_handle: wmi handle
9463 * @pwmaTdlsparams: TDLS params
9464 *
9465 * Return: 0 for sucess or error code
9466 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309467static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309468 void *tdls_param, uint8_t tdls_state)
9469{
9470 wmi_tdls_set_state_cmd_fixed_param *cmd;
9471 wmi_buf_t wmi_buf;
9472
9473 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9474 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9475
9476 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9477 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309478 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9479 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309480 }
9481 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9482 WMITLV_SET_HDR(&cmd->tlv_header,
9483 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9484 WMITLV_GET_STRUCT_TLVLEN
9485 (wmi_tdls_set_state_cmd_fixed_param));
9486 cmd->vdev_id = wmi_tdls->vdev_id;
9487 cmd->state = tdls_state;
9488 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9489 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9490 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9491 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9492 cmd->rssi_delta = wmi_tdls->rssi_delta;
9493 cmd->tdls_options = wmi_tdls->tdls_options;
9494 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9495 cmd->tdls_peer_traffic_response_timeout_ms =
9496 wmi_tdls->peer_traffic_response_timeout;
9497 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9498 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9499 cmd->tdls_puapsd_rx_frame_threshold =
9500 wmi_tdls->puapsd_rx_frame_threshold;
9501 cmd->teardown_notification_ms =
9502 wmi_tdls->teardown_notification_ms;
9503 cmd->tdls_peer_kickout_threshold =
9504 wmi_tdls->tdls_peer_kickout_threshold;
9505
Govind Singhb53420c2016-03-09 14:32:57 +05309506 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309507 "notification_interval_ms: %d, "
9508 "tx_discovery_threshold: %d, "
9509 "tx_teardown_threshold: %d, "
9510 "rssi_teardown_threshold: %d, "
9511 "rssi_delta: %d, "
9512 "tdls_options: 0x%x, "
9513 "tdls_peer_traffic_ind_window: %d, "
9514 "tdls_peer_traffic_response_timeout: %d, "
9515 "tdls_puapsd_mask: 0x%x, "
9516 "tdls_puapsd_inactivity_time: %d, "
9517 "tdls_puapsd_rx_frame_threshold: %d, "
9518 "teardown_notification_ms: %d, "
9519 "tdls_peer_kickout_threshold: %d",
9520 __func__, tdls_state, cmd->state,
9521 cmd->notification_interval_ms,
9522 cmd->tx_discovery_threshold,
9523 cmd->tx_teardown_threshold,
9524 cmd->rssi_teardown_threshold,
9525 cmd->rssi_delta,
9526 cmd->tdls_options,
9527 cmd->tdls_peer_traffic_ind_window,
9528 cmd->tdls_peer_traffic_response_timeout_ms,
9529 cmd->tdls_puapsd_mask,
9530 cmd->tdls_puapsd_inactivity_time_ms,
9531 cmd->tdls_puapsd_rx_frame_threshold,
9532 cmd->teardown_notification_ms,
9533 cmd->tdls_peer_kickout_threshold);
9534
9535 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9536 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309537 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309538 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309539 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 }
Govind Singhb53420c2016-03-09 14:32:57 +05309541 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309542
Govind Singhb53420c2016-03-09 14:32:57 +05309543 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309544}
9545
9546/**
9547 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9548 * @wmi_handle: wmi handle
9549 * @peerStateParams: TDLS peer state params
9550 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309551 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309552 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309553static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309554 struct tdls_peer_state_params *peerStateParams,
9555 uint32_t *ch_mhz)
9556{
9557 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9558 wmi_tdls_peer_capabilities *peer_cap;
9559 wmi_channel *chan_info;
9560 wmi_buf_t wmi_buf;
9561 uint8_t *buf_ptr;
9562 uint32_t i;
9563 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9564 sizeof(wmi_tdls_peer_capabilities);
9565
9566
9567 len += WMI_TLV_HDR_SIZE +
9568 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9569
9570 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9571 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309572 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9573 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309574 }
9575
9576 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9577 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9578 WMITLV_SET_HDR(&cmd->tlv_header,
9579 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9580 WMITLV_GET_STRUCT_TLVLEN
9581 (wmi_tdls_peer_update_cmd_fixed_param));
9582
9583 cmd->vdev_id = peerStateParams->vdevId;
9584 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9585 &cmd->peer_macaddr);
9586
9587
9588 cmd->peer_state = peerStateParams->peerState;
9589
Govind Singhb53420c2016-03-09 14:32:57 +05309590 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309591 "peer_macaddr.mac_addr31to0: 0x%x, "
9592 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9593 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9594 cmd->peer_macaddr.mac_addr31to0,
9595 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9596
9597 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9598 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9599 WMITLV_SET_HDR(&peer_cap->tlv_header,
9600 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9601 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9602
9603 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9604 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9605 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9606 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9607 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9608 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9609 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9610 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9611
9612 /* Ack and More Data Ack are sent as 0, so no need to set
9613 * but fill SP
9614 */
9615 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9616 peerStateParams->peerCap.peerMaxSp);
9617
9618 peer_cap->buff_sta_support =
9619 peerStateParams->peerCap.peerBuffStaSupport;
9620 peer_cap->off_chan_support =
9621 peerStateParams->peerCap.peerOffChanSupport;
9622 peer_cap->peer_curr_operclass =
9623 peerStateParams->peerCap.peerCurrOperClass;
9624 /* self curr operclass is not being used and so pass op class for
9625 * preferred off chan in it.
9626 */
9627 peer_cap->self_curr_operclass =
9628 peerStateParams->peerCap.opClassForPrefOffChan;
9629 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9630 peer_cap->peer_operclass_len =
9631 peerStateParams->peerCap.peerOperClassLen;
9632
Govind Singhb53420c2016-03-09 14:32:57 +05309633 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309634 __func__, peer_cap->peer_operclass_len);
9635 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9636 peer_cap->peer_operclass[i] =
9637 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309638 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309639 __func__, i, peer_cap->peer_operclass[i]);
9640 }
9641
9642 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9643 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9644 peer_cap->pref_offchan_bw =
9645 peerStateParams->peerCap.prefOffChanBandwidth;
9646
Govind Singhb53420c2016-03-09 14:32:57 +05309647 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309648 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9649 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9650 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9651 " %d, pref_offchan_bw: %d",
9652 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9653 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9654 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9655 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9656 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9657
9658 /* next fill variable size array of peer chan info */
9659 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9660 WMITLV_SET_HDR(buf_ptr,
9661 WMITLV_TAG_ARRAY_STRUC,
9662 sizeof(wmi_channel) *
9663 peerStateParams->peerCap.peerChanLen);
9664 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9665
9666 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9667 WMITLV_SET_HDR(&chan_info->tlv_header,
9668 WMITLV_TAG_STRUC_wmi_channel,
9669 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9670 chan_info->mhz = ch_mhz[i];
9671 chan_info->band_center_freq1 = chan_info->mhz;
9672 chan_info->band_center_freq2 = 0;
9673
Govind Singhb53420c2016-03-09 14:32:57 +05309674 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309675
9676 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9677 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309678 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309679 peerStateParams->peerCap.peerChan[i].chanId,
9680 peerStateParams->peerCap.peerChan[i].dfsSet);
9681 }
9682
9683 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9684 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9685 else
9686 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9687
9688 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9689 peerStateParams->peerCap.
9690 peerChan[i].pwr);
9691
9692 WMI_SET_CHANNEL_REG_POWER(chan_info,
9693 peerStateParams->peerCap.peerChan[i].
9694 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309695 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309696 peerStateParams->peerCap.peerChan[i].pwr);
9697
9698 chan_info++;
9699 }
9700
9701 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9702 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309703 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309704 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309705 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309706 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 }
9708
9709
Govind Singhb53420c2016-03-09 14:32:57 +05309710 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309711}
9712
9713/*
9714 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9715 * firmware
9716 * @wmi_handle: Pointer to wmi handle
9717 * @mem_dump_req: Pointer for mem_dump_req
9718 *
9719 * This function sends memory dump request to firmware
9720 *
Govind Singhb53420c2016-03-09 14:32:57 +05309721 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309722 *
9723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309724static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309725 struct fw_dump_req_param *mem_dump_req)
9726{
9727 wmi_get_fw_mem_dump_fixed_param *cmd;
9728 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309729 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309730 int32_t len;
9731 wmi_buf_t buf;
9732 u_int8_t *buf_ptr;
9733 int ret, loop;
9734
9735 /*
9736 * len = sizeof(fixed param) that includes tlv header +
9737 * tlv header for array of struc +
9738 * sizeof (each struct)
9739 */
9740 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9741 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9742 buf = wmi_buf_alloc(wmi_handle, len);
9743
9744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309745 WMI_LOGE(FL("Failed allocate wmi buffer"));
9746 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309747 }
9748
9749 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309750 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309751 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9752
9753 WMITLV_SET_HDR(&cmd->tlv_header,
9754 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9755 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9756
9757 cmd->request_id = mem_dump_req->request_id;
9758 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9759
9760 /* TLV indicating array of structures to follow */
9761 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9763 sizeof(wmi_fw_mem_dump) *
9764 cmd->num_fw_mem_dump_segs);
9765
9766 buf_ptr += WMI_TLV_HDR_SIZE;
9767 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9768
Govind Singhb53420c2016-03-09 14:32:57 +05309769 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309770 mem_dump_req->request_id, mem_dump_req->num_seg);
9771 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309772 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309773 ((uint8_t *)(mem_dump_req->segment) +
9774 loop * sizeof(*seg_req));
9775 WMITLV_SET_HDR(&dump_params->tlv_header,
9776 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9777 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9778 dump_params->seg_id = seg_req->seg_id;
9779 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9780 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9781 dump_params->seg_length = seg_req->seg_length;
9782 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9783 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309784 WMI_LOGI(FL("seg_number:%d"), loop);
9785 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309786 dump_params->seg_id, dump_params->seg_start_addr_lo,
9787 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309788 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309789 dump_params->seg_length, dump_params->dest_addr_lo,
9790 dump_params->dest_addr_hi);
9791 dump_params++;
9792 }
9793
9794 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9795 WMI_GET_FW_MEM_DUMP_CMDID);
9796 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309797 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309798 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309799 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309800 }
9801
Govind Singhb53420c2016-03-09 14:32:57 +05309802 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9803 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309804}
9805
9806/*
9807 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9808 * @wmi_handle: Pointer to WMi handle
9809 * @ie_data: Pointer for ie data
9810 *
9811 * This function sends IE information to firmware
9812 *
Govind Singhb53420c2016-03-09 14:32:57 +05309813 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309814 *
9815 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309816static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309817 struct vdev_ie_info_param *ie_info)
9818{
9819 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9820 wmi_buf_t buf;
9821 uint8_t *buf_ptr;
9822 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309823 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309824
9825
9826 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9827 /* Allocate memory for the WMI command */
9828 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9829
9830 buf = wmi_buf_alloc(wmi_handle, len);
9831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309832 WMI_LOGE(FL("wmi_buf_alloc failed"));
9833 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309834 }
9835
9836 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309837 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309838
9839 /* Populate the WMI command */
9840 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9841
9842 WMITLV_SET_HDR(&cmd->tlv_header,
9843 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9844 WMITLV_GET_STRUCT_TLVLEN(
9845 wmi_vdev_set_ie_cmd_fixed_param));
9846 cmd->vdev_id = ie_info->vdev_id;
9847 cmd->ie_id = ie_info->ie_id;
9848 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009849 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309850
Govind Singhb53420c2016-03-09 14:32:57 +05309851 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309852 ie_info->length, ie_info->vdev_id);
9853
9854 buf_ptr += sizeof(*cmd);
9855 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9856 buf_ptr += WMI_TLV_HDR_SIZE;
9857
Govind Singhb53420c2016-03-09 14:32:57 +05309858 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309859
9860 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9861 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309862 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309863 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309864 wmi_buf_free(buf);
9865 }
9866
9867 return ret;
9868}
9869
Sathish Kumar497bef42017-03-01 14:02:36 +05309870/**
9871 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9872 *
9873 * @param wmi_handle : handle to WMI.
9874 * @param param : pointer to antenna param
9875 *
9876 * This function sends smart antenna enable command to FW
9877 *
9878 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9879 */
9880static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9881 struct smart_ant_enable_params *param)
9882{
9883 /* Send WMI COMMAND to Enable */
9884 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9885 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9886 wmi_buf_t buf;
9887 uint8_t *buf_ptr;
9888 int len = 0;
9889 QDF_STATUS ret;
9890 int loop = 0;
9891
9892 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9893 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9894 buf = wmi_buf_alloc(wmi_handle, len);
9895
9896 if (!buf) {
9897 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9898 return QDF_STATUS_E_NOMEM;
9899 }
9900
9901 buf_ptr = wmi_buf_data(buf);
9902 qdf_mem_zero(buf_ptr, len);
9903 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9904
9905 WMITLV_SET_HDR(&cmd->tlv_header,
9906 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9907 WMITLV_GET_STRUCT_TLVLEN(
9908 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9909
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309910 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9911 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309912 cmd->enable = param->enable;
9913 cmd->mode = param->mode;
9914 cmd->rx_antenna = param->rx_antenna;
9915 cmd->tx_default_antenna = param->rx_antenna;
9916
9917 /* TLV indicating array of structures to follow */
9918 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9919 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9920 WMI_HAL_MAX_SANTENNA *
9921 sizeof(wmi_pdev_smart_ant_gpio_handle));
9922
9923 buf_ptr += WMI_TLV_HDR_SIZE;
9924 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9925
9926 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9927 WMITLV_SET_HDR(&gpio_param->tlv_header,
9928 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9929 WMITLV_GET_STRUCT_TLVLEN(
9930 wmi_pdev_smart_ant_gpio_handle));
9931 if (param->mode == SMART_ANT_MODE_SERIAL) {
9932 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9933 gpio_param->gpio_pin = param->gpio_pin[loop];
9934 gpio_param->gpio_func = param->gpio_func[loop];
9935 } else {
9936 gpio_param->gpio_pin = 0;
9937 gpio_param->gpio_func = 0;
9938 }
9939 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9940 gpio_param->gpio_pin = param->gpio_pin[loop];
9941 gpio_param->gpio_func = param->gpio_func[loop];
9942 }
9943 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309944 gpio_param->pdev_id =
9945 wmi_handle->ops->convert_pdev_id_host_to_target(
9946 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309947 gpio_param++;
9948 }
9949
9950 ret = wmi_unified_cmd_send(wmi_handle,
9951 buf,
9952 len,
9953 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9954
9955 if (ret != 0) {
9956 WMI_LOGE(" %s :WMI Failed\n", __func__);
9957 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9958 cmd->enable,
9959 cmd->mode,
9960 cmd->rx_antenna,
9961 param->gpio_pin[0], param->gpio_pin[1],
9962 param->gpio_pin[2], param->gpio_pin[3],
9963 param->gpio_func[0], param->gpio_func[1],
9964 param->gpio_func[2], param->gpio_func[3],
9965 ret);
9966 wmi_buf_free(buf);
9967 }
9968
9969 return ret;
9970}
9971
9972/**
9973 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9974 *
9975 * @param wmi_handle : handle to WMI.
9976 * @param param : pointer to rx antenna param
9977 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9978 */
9979static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9980 struct smart_ant_rx_ant_params *param)
9981{
9982 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9983 wmi_buf_t buf;
9984 uint8_t *buf_ptr;
9985 uint32_t len;
9986 QDF_STATUS ret;
9987
9988 len = sizeof(*cmd);
9989 buf = wmi_buf_alloc(wmi_handle, len);
9990 WMI_LOGD("%s:\n", __func__);
9991 if (!buf) {
9992 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9993 return QDF_STATUS_E_NOMEM;
9994 }
9995
9996 buf_ptr = wmi_buf_data(buf);
9997 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9998 WMITLV_SET_HDR(&cmd->tlv_header,
9999 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10000 WMITLV_GET_STRUCT_TLVLEN(
10001 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10002 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010003 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10004 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010005
10006 ret = wmi_unified_cmd_send(wmi_handle,
10007 buf,
10008 len,
10009 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10010
10011 if (ret != 0) {
10012 WMI_LOGE(" %s :WMI Failed\n", __func__);
10013 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10014 __func__,
10015 cmd->rx_antenna,
10016 ret);
10017 wmi_buf_free(buf);
10018 }
10019
10020 return ret;
10021}
10022
10023/**
10024 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10025 * @wmi_handle: wmi handle
10026 * @param: pointer to hold ctl table param
10027 *
10028 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10029 */
10030static QDF_STATUS
10031send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10032 struct ctl_table_params *param)
10033{
10034 uint16_t len, ctl_tlv_len;
10035 uint8_t *buf_ptr;
10036 wmi_buf_t buf;
10037 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10038 uint32_t *ctl_array;
10039
10040 if (!param->ctl_array)
10041 return QDF_STATUS_E_FAILURE;
10042
10043 if (param->ctl_cmd_len !=
10044 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10045 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
10046 qdf_print("CTL array len not correct\n");
10047 return QDF_STATUS_E_FAILURE;
10048 }
10049
10050 ctl_tlv_len = WMI_TLV_HDR_SIZE +
10051 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
10052 len = sizeof(*cmd) + ctl_tlv_len;
10053
10054 buf = wmi_buf_alloc(wmi_handle, len);
10055 if (!buf) {
10056 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10057 return QDF_STATUS_E_FAILURE;
10058 }
10059
10060 buf_ptr = wmi_buf_data(buf);
10061 qdf_mem_zero(buf_ptr, len);
10062
10063 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10064
10065 WMITLV_SET_HDR(&cmd->tlv_header,
10066 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10067 WMITLV_GET_STRUCT_TLVLEN(
10068 wmi_pdev_set_ctl_table_cmd_fixed_param));
10069 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010070 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10071 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010072
10073 buf_ptr += sizeof(*cmd);
10074 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10075 (cmd->ctl_len));
10076 buf_ptr += WMI_TLV_HDR_SIZE;
10077 ctl_array = (uint32_t *)buf_ptr;
10078
10079 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10080 sizeof(param->ctl_band));
10081 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10082 param->ctl_cmd_len -
10083 sizeof(param->ctl_band));
10084
10085 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10086 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10087 WMI_LOGE("%s:Failed to send command\n", __func__);
10088 wmi_buf_free(buf);
10089 return QDF_STATUS_E_FAILURE;
10090 }
10091
10092 return QDF_STATUS_SUCCESS;
10093}
10094
10095/**
10096 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10097 * @wmi_handle: wmi handle
10098 * @param: pointer to hold mimogain table param
10099 *
10100 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10101 */
10102static QDF_STATUS
10103send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10104 struct mimogain_table_params *param)
10105{
10106 uint16_t len, table_tlv_len;
10107 wmi_buf_t buf;
10108 uint8_t *buf_ptr;
10109 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10110 uint32_t *gain_table;
10111
10112 if (!param->array_gain)
10113 return QDF_STATUS_E_FAILURE;
10114
10115 /* len must be multiple of a single array gain table */
10116 if (param->tbl_len %
10117 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10118 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10119 WMI_LOGE("Array gain table len not correct\n");
10120 return QDF_STATUS_E_FAILURE;
10121 }
10122
10123 table_tlv_len = WMI_TLV_HDR_SIZE +
10124 roundup(param->tbl_len, sizeof(uint32_t));
10125 len = sizeof(*cmd) + table_tlv_len;
10126
10127 buf = wmi_buf_alloc(wmi_handle, len);
10128 if (!buf) {
10129 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10130 return QDF_STATUS_E_FAILURE;
10131 }
10132
10133 buf_ptr = wmi_buf_data(buf);
10134 qdf_mem_zero(buf_ptr, len);
10135
10136 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10137
10138 WMITLV_SET_HDR(&cmd->tlv_header,
10139 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10140 WMITLV_GET_STRUCT_TLVLEN(
10141 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10142
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010143 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10144 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010145 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10146 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10147 param->multichain_gain_bypass);
10148
10149 buf_ptr += sizeof(*cmd);
10150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10151 (param->tbl_len));
10152 buf_ptr += WMI_TLV_HDR_SIZE;
10153 gain_table = (uint32_t *)buf_ptr;
10154
10155 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10156 param->array_gain,
10157 param->tbl_len);
10158
10159 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10160 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10161 return QDF_STATUS_E_FAILURE;
10162 }
10163
10164 return QDF_STATUS_SUCCESS;
10165}
10166
10167/**
10168 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10169 * info to fw
10170 * @wmi_handle: wmi handle
10171 * @param: pointer to hold packet power info param
10172 *
10173 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10174 */
10175static QDF_STATUS
10176send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10177 struct packet_power_info_params *param)
10178{
10179 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10180 wmi_buf_t wmibuf;
10181 uint8_t *buf_ptr;
10182 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10183
10184 wmibuf = wmi_buf_alloc(wmi_handle, len);
10185 if (wmibuf == NULL)
10186 return QDF_STATUS_E_NOMEM;
10187
10188 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10189
10190 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10191 WMITLV_SET_HDR(&cmd->tlv_header,
10192 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10193 WMITLV_GET_STRUCT_TLVLEN(
10194 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010195 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10196 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010197 cmd->rate_flags = param->rate_flags;
10198 cmd->nss = param->nss;
10199 cmd->preamble = param->preamble;
10200 cmd->hw_rate = param->hw_rate;
10201 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10202 __func__,
10203 __LINE__,
10204 WMI_PDEV_GET_TPC_CMDID,
10205 *((u_int32_t *)cmd));
10206 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10207 WMI_PDEV_GET_TPC_CMDID)) {
10208 WMI_LOGE(FL("Failed to get tpc command\n"));
10209 wmi_buf_free(wmibuf);
10210 return QDF_STATUS_E_FAILURE;
10211 }
10212
10213 return QDF_STATUS_SUCCESS;
10214}
10215
10216/**
10217 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10218 * @wmi_handle: wmi handle
10219 * @param: pointer to hold config ratemask params
10220 *
10221 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10222 */
10223static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10224 struct config_ratemask_params *param)
10225{
10226 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10227 wmi_buf_t buf;
10228 int32_t len = sizeof(*cmd);
10229
10230 buf = wmi_buf_alloc(wmi_handle, len);
10231 if (!buf) {
10232 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10233 return QDF_STATUS_E_FAILURE;
10234 }
10235 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10236 WMITLV_SET_HDR(&cmd->tlv_header,
10237 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10238 WMITLV_GET_STRUCT_TLVLEN(
10239 wmi_vdev_config_ratemask_cmd_fixed_param));
10240 cmd->vdev_id = param->vdev_id;
10241 cmd->type = param->type;
10242 cmd->mask_lower32 = param->lower32;
10243 cmd->mask_higher32 = param->higher32;
10244 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10245 param->vdev_id, param->type, param->lower32, param->higher32);
10246
10247 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10248 WMI_VDEV_RATEMASK_CMDID)) {
10249 WMI_LOGE("Seting vdev ratemask failed\n");
10250 wmi_buf_free(buf);
10251 return QDF_STATUS_E_FAILURE;
10252 }
10253
10254 return QDF_STATUS_SUCCESS;
10255}
10256
10257/**
10258 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10259 * @wmi_handle: wmi handle
10260 * @param: pointer to hold vap dscp tid map param
10261 *
10262 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10263 */
10264static QDF_STATUS
10265send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10266 struct vap_dscp_tid_map_params *param)
10267{
10268 wmi_buf_t buf;
10269 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10270 int32_t len = sizeof(*cmd);
10271
10272 buf = wmi_buf_alloc(wmi_handle, len);
10273 if (!buf) {
10274 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10275 return QDF_STATUS_E_FAILURE;
10276 }
10277
10278 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10279 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10280 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10281
10282 cmd->vdev_id = param->vdev_id;
10283 cmd->enable_override = 0;
10284
10285 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10286 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10287 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10288 WMI_LOGE("Failed to set dscp cmd\n");
10289 wmi_buf_free(buf);
10290 return QDF_STATUS_E_FAILURE;
10291 }
10292
10293 return QDF_STATUS_SUCCESS;
10294}
10295
10296/**
10297 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10298 * @wmi_handle: wmi handle
10299 * @macaddr: vdev mac address
10300 * @param: pointer to hold neigbour rx param
10301 *
10302 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10303 */
10304static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10305 uint8_t macaddr[IEEE80211_ADDR_LEN],
10306 struct set_neighbour_rx_params *param)
10307{
10308 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10309 wmi_buf_t buf;
10310 int32_t len = sizeof(*cmd);
10311
10312 buf = wmi_buf_alloc(wmi_handle, len);
10313 if (!buf) {
10314 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10315 return QDF_STATUS_E_FAILURE;
10316 }
10317 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10318 WMITLV_SET_HDR(&cmd->tlv_header,
10319 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10320 WMITLV_GET_STRUCT_TLVLEN(
10321 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10322 cmd->vdev_id = param->vdev_id;
10323 cmd->bssid_idx = param->idx;
10324 cmd->action = param->action;
10325 cmd->type = param->type;
10326 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10327 cmd->flag = 0;
10328
10329 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10330 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10331 WMI_LOGE("Failed to set neighbour rx param\n");
10332 wmi_buf_free(buf);
10333 return QDF_STATUS_E_FAILURE;
10334 }
10335
10336 return QDF_STATUS_SUCCESS;
10337}
10338
10339/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010340 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010341 * @param wmi_handle : handle to WMI.
10342 * @param macaddr : vdev mac address
10343 * @param param : pointer to tx antenna param
10344 *
10345 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10346 */
10347static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10348 uint8_t macaddr[IEEE80211_ADDR_LEN],
10349 struct smart_ant_tx_ant_params *param)
10350{
10351 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10352 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10353 wmi_buf_t buf;
10354 int32_t len = 0;
10355 int i;
10356 uint8_t *buf_ptr;
10357 QDF_STATUS ret;
10358
10359 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10360 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10361 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10362 buf = wmi_buf_alloc(wmi_handle, len);
10363
10364 if (!buf) {
10365 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10366 return QDF_STATUS_E_NOMEM;
10367 }
10368
10369 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10370 qdf_mem_zero(buf_ptr, len);
10371 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10372
10373 WMITLV_SET_HDR(&cmd->tlv_header,
10374 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10375 WMITLV_GET_STRUCT_TLVLEN(
10376 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10377
10378 cmd->vdev_id = param->vdev_id;
10379 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10380
10381 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10382 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10383 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10384 buf_ptr += WMI_TLV_HDR_SIZE;
10385 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10386
10387 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10388 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10389 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10390 WMITLV_GET_STRUCT_TLVLEN(
10391 wmi_peer_smart_ant_set_tx_antenna_series));
10392 ant_tx_series->antenna_series = param->antenna_array[i];
10393 ant_tx_series++;
10394 }
10395
10396 ret = wmi_unified_cmd_send(wmi_handle,
10397 buf,
10398 len,
10399 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10400
10401 if (ret != 0) {
10402 WMI_LOGE(" %s :WMI Failed\n", __func__);
10403 wmi_buf_free(buf);
10404 }
10405
10406 return ret;
10407}
10408
Sathish Kumar02c3b542017-02-22 17:24:45 +053010409/**
10410 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10411 * @wmi_handle: wmi handle
10412 * @param: pointer to hold ant switch tbl param
10413 *
10414 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10415 */
10416static QDF_STATUS
10417send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10418 struct ant_switch_tbl_params *param)
10419{
10420 uint8_t len;
10421 wmi_buf_t buf;
10422 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10423 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10424 uint8_t *buf_ptr;
10425
10426 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10427 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10428 buf = wmi_buf_alloc(wmi_handle, len);
10429
10430 if (!buf) {
10431 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10432 return QDF_STATUS_E_NOMEM;
10433 }
10434
10435 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10436 qdf_mem_zero(buf_ptr, len);
10437 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10438
10439 WMITLV_SET_HDR(&cmd->tlv_header,
10440 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10441 WMITLV_GET_STRUCT_TLVLEN(
10442 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10443
10444 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10445 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010446 cmd->mac_id =
10447 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010448
10449 /* TLV indicating array of structures to follow */
10450 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10452 sizeof(wmi_pdev_set_ant_ctrl_chain));
10453 buf_ptr += WMI_TLV_HDR_SIZE;
10454 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10455
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010456 ctrl_chain->pdev_id =
10457 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010458 ctrl_chain->antCtrlChain = param->antCtrlChain;
10459
10460 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10461 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10462 wmi_buf_free(buf);
10463 return QDF_STATUS_E_FAILURE;
10464 }
10465
10466 return QDF_STATUS_SUCCESS;
10467}
10468
10469/**
10470 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10471 * training information function
10472 * @param wmi_handle : handle to WMI.
10473 * @macaddr : vdev mac address
10474 * @param param : pointer to tx antenna param
10475 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10476 */
10477static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10478 wmi_unified_t wmi_handle,
10479 uint8_t macaddr[IEEE80211_ADDR_LEN],
10480 struct smart_ant_training_info_params *param)
10481{
10482 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10483 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10484 wmi_buf_t buf;
10485 uint8_t *buf_ptr;
10486 int32_t len = 0;
10487 QDF_STATUS ret;
10488 int loop;
10489
10490 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10491 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10492 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10493 buf = wmi_buf_alloc(wmi_handle, len);
10494
10495 if (!buf) {
10496 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10497 return QDF_STATUS_E_NOMEM;
10498 }
10499
10500 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10501 qdf_mem_zero(buf_ptr, len);
10502 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10503
10504 WMITLV_SET_HDR(&cmd->tlv_header,
10505 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10506 WMITLV_GET_STRUCT_TLVLEN(
10507 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10508
10509 cmd->vdev_id = param->vdev_id;
10510 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10511 cmd->num_pkts = param->numpkts;
10512
10513 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10515 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10516 WMI_SMART_ANT_MAX_RATE_SERIES);
10517
10518 buf_ptr += WMI_TLV_HDR_SIZE;
10519 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10520
10521 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10522 WMITLV_SET_HDR(&train_param->tlv_header,
10523 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10524 WMITLV_GET_STRUCT_TLVLEN(
10525 wmi_peer_smart_ant_set_train_antenna_param));
10526 train_param->train_rate_series = param->rate_array[loop];
10527 train_param->train_antenna_series = param->antenna_array[loop];
10528 train_param->rc_flags = 0;
10529 WMI_LOGI(FL("Series number:%d\n"), loop);
10530 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10531 train_param->train_rate_series,
10532 train_param->train_antenna_series);
10533 train_param++;
10534 }
10535
10536 ret = wmi_unified_cmd_send(wmi_handle,
10537 buf,
10538 len,
10539 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10540
10541 if (ret != 0) {
10542 WMI_LOGE(" %s :WMI Failed\n", __func__);
10543 wmi_buf_free(buf);
10544 return QDF_STATUS_E_FAILURE;
10545 }
10546
10547 return ret;
10548}
10549
10550/**
10551 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10552 * configuration function
10553 * @param wmi_handle : handle to WMI.
10554 * @macaddr : vdev mad address
10555 * @param param : pointer to tx antenna param
10556 *
10557 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10558 */
10559static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10560 wmi_unified_t wmi_handle,
10561 uint8_t macaddr[IEEE80211_ADDR_LEN],
10562 struct smart_ant_node_config_params *param)
10563{
10564 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10565 wmi_buf_t buf;
10566 uint8_t *buf_ptr;
10567 int32_t len = 0, args_tlv_len;
10568 int ret;
10569 int i = 0;
10570 A_UINT32 *node_config_args;
10571
10572 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10573 len = sizeof(*cmd) + args_tlv_len;
10574
10575 if ((param->args_count == 0)) {
10576 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10577 __func__, param->args_count);
10578 return QDF_STATUS_E_FAILURE;
10579 }
10580
10581 buf = wmi_buf_alloc(wmi_handle, len);
10582 if (!buf) {
10583 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10584 return QDF_STATUS_E_NOMEM;
10585 }
10586
10587 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10588 wmi_buf_data(buf);
10589 buf_ptr = (uint8_t *)cmd;
10590 WMITLV_SET_HDR(&cmd->tlv_header,
10591 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10592 WMITLV_GET_STRUCT_TLVLEN(
10593 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10594 cmd->vdev_id = param->vdev_id;
10595 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10596 cmd->cmd_id = param->cmd_id;
10597 cmd->args_count = param->args_count;
10598 buf_ptr += sizeof(
10599 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10601 (cmd->args_count * sizeof(A_UINT32)));
10602 buf_ptr += WMI_TLV_HDR_SIZE;
10603 node_config_args = (A_UINT32 *)buf_ptr;
10604
10605 for (i = 0; i < param->args_count; i++) {
10606 node_config_args[i] = param->args_arr[i];
10607 WMI_LOGI("%d", param->args_arr[i]);
10608 }
10609
10610 ret = wmi_unified_cmd_send(wmi_handle,
10611 buf,
10612 len,
10613 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10614
10615 if (ret != 0) {
10616 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10617 __func__, param->cmd_id, macaddr[0],
10618 macaddr[1], macaddr[2], macaddr[3],
10619 macaddr[4], macaddr[5], ret);
10620 wmi_buf_free(buf);
10621 }
10622
10623 return ret;
10624}
10625
10626/**
10627 * send_set_atf_cmd_tlv() - send set atf command to fw
10628 * @wmi_handle: wmi handle
10629 * @param: pointer to set atf param
10630 *
10631 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10632 */
10633static QDF_STATUS
10634send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10635 struct set_atf_params *param)
10636{
10637 wmi_atf_peer_info *peer_info;
10638 wmi_peer_atf_request_fixed_param *cmd;
10639 wmi_buf_t buf;
10640 uint8_t *buf_ptr;
10641 int i;
10642 int32_t len = 0;
10643 QDF_STATUS retval;
10644
10645 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10646 len += param->num_peers * sizeof(wmi_atf_peer_info);
10647 buf = wmi_buf_alloc(wmi_handle, len);
10648 if (!buf) {
10649 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10650 return QDF_STATUS_E_FAILURE;
10651 }
10652 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10653 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10654 WMITLV_SET_HDR(&cmd->tlv_header,
10655 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10656 WMITLV_GET_STRUCT_TLVLEN(
10657 wmi_peer_atf_request_fixed_param));
10658 cmd->num_peers = param->num_peers;
10659
10660 buf_ptr += sizeof(*cmd);
10661 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10662 sizeof(wmi_atf_peer_info) *
10663 cmd->num_peers);
10664 buf_ptr += WMI_TLV_HDR_SIZE;
10665 peer_info = (wmi_atf_peer_info *)buf_ptr;
10666
10667 for (i = 0; i < cmd->num_peers; i++) {
10668 WMITLV_SET_HDR(&peer_info->tlv_header,
10669 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10670 WMITLV_GET_STRUCT_TLVLEN(
10671 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010672 qdf_mem_copy(&(peer_info->peer_macaddr),
10673 &(param->peer_info[i].peer_macaddr),
10674 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010675 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010676 peer_info->vdev_id = param->peer_info[i].vdev_id;
10677 peer_info->pdev_id =
10678 wmi_handle->ops->convert_pdev_id_host_to_target(
10679 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010680 /*
10681 * TLV definition for peer atf request fixed param combines
10682 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10683 * stats and atf extension stats as two different
10684 * implementations.
10685 * Need to discuss with FW on this.
10686 *
10687 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10688 * peer_info->atf_units_reserved =
10689 * param->peer_ext_info[i].atf_index_reserved;
10690 */
10691 peer_info++;
10692 }
10693
10694 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10695 WMI_PEER_ATF_REQUEST_CMDID);
10696
10697 if (retval != QDF_STATUS_SUCCESS) {
10698 WMI_LOGE("%s : WMI Failed\n", __func__);
10699 wmi_buf_free(buf);
10700 }
10701
10702 return retval;
10703}
10704
10705/**
10706 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10707 * @wmi_handle: wmi handle
10708 * @param: pointer to hold fwtest param
10709 *
10710 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10711 */
10712static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10713 struct set_fwtest_params *param)
10714{
10715 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10716 wmi_buf_t buf;
10717 int32_t len = sizeof(*cmd);
10718
10719 buf = wmi_buf_alloc(wmi_handle, len);
10720
10721 if (!buf) {
10722 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10723 return QDF_STATUS_E_FAILURE;
10724 }
10725
10726 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10727 WMITLV_SET_HDR(&cmd->tlv_header,
10728 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10729 WMITLV_GET_STRUCT_TLVLEN(
10730 wmi_fwtest_set_param_cmd_fixed_param));
10731 cmd->param_id = param->arg;
10732 cmd->param_value = param->value;
10733
10734 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10735 WMI_LOGE("Setting FW test param failed\n");
10736 wmi_buf_free(buf);
10737 return QDF_STATUS_E_FAILURE;
10738 }
10739
10740 return QDF_STATUS_SUCCESS;
10741}
10742
10743/**
10744 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10745 * @wmi_handle: wmi handle
10746 * @param: pointer to qboost params
10747 * @macaddr: vdev mac address
10748 *
10749 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10750 */
10751static QDF_STATUS
10752send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10753 uint8_t macaddr[IEEE80211_ADDR_LEN],
10754 struct set_qboost_params *param)
10755{
10756 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10757 wmi_buf_t buf;
10758 int32_t len;
10759 QDF_STATUS ret;
10760
10761 len = sizeof(*cmd);
10762
10763 buf = wmi_buf_alloc(wmi_handle, len);
10764 if (!buf) {
10765 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10766 return QDF_STATUS_E_FAILURE;
10767 }
10768
10769 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10770 WMITLV_SET_HDR(&cmd->tlv_header,
10771 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10772 WMITLV_GET_STRUCT_TLVLEN(
10773 WMI_QBOOST_CFG_CMD_fixed_param));
10774 cmd->vdev_id = param->vdev_id;
10775 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10776 cmd->qb_enable = param->value;
10777
10778 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10779 WMI_QBOOST_CFG_CMDID);
10780
10781 if (ret != 0) {
10782 WMI_LOGE("Setting qboost cmd failed\n");
10783 wmi_buf_free(buf);
10784 }
10785
10786 return ret;
10787}
10788
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010789/**
10790 * send_gpio_config_cmd_tlv() - send gpio config to fw
10791 * @wmi_handle: wmi handle
10792 * @param: pointer to hold gpio config param
10793 *
10794 * Return: 0 for success or error code
10795 */
10796static QDF_STATUS
10797send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10798 struct gpio_config_params *param)
10799{
10800 wmi_gpio_config_cmd_fixed_param *cmd;
10801 wmi_buf_t buf;
10802 int32_t len;
10803 QDF_STATUS ret;
10804
10805 len = sizeof(*cmd);
10806
10807 /* Sanity Checks */
10808 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10809 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10810 return QDF_STATUS_E_FAILURE;
10811 }
10812
10813 buf = wmi_buf_alloc(wmi_handle, len);
10814 if (!buf) {
10815 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10816 return QDF_STATUS_E_FAILURE;
10817 }
10818
10819 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10820 WMITLV_SET_HDR(&cmd->tlv_header,
10821 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10822 WMITLV_GET_STRUCT_TLVLEN(
10823 wmi_gpio_config_cmd_fixed_param));
10824 cmd->gpio_num = param->gpio_num;
10825 cmd->input = param->input;
10826 cmd->pull_type = param->pull_type;
10827 cmd->intr_mode = param->intr_mode;
10828
10829 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10830 WMI_GPIO_CONFIG_CMDID);
10831
10832 if (ret != 0) {
10833 WMI_LOGE("Sending GPIO config cmd failed\n");
10834 wmi_buf_free(buf);
10835 }
10836
10837 return ret;
10838}
10839
10840/**
10841 * send_gpio_output_cmd_tlv() - send gpio output to fw
10842 * @wmi_handle: wmi handle
10843 * @param: pointer to hold gpio output param
10844 *
10845 * Return: 0 for success or error code
10846 */
10847static QDF_STATUS
10848send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10849 struct gpio_output_params *param)
10850{
10851 wmi_gpio_output_cmd_fixed_param *cmd;
10852 wmi_buf_t buf;
10853 int32_t len;
10854 QDF_STATUS ret;
10855
10856 len = sizeof(*cmd);
10857
10858 buf = wmi_buf_alloc(wmi_handle, len);
10859 if (!buf) {
10860 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10861 return QDF_STATUS_E_FAILURE;
10862 }
10863
10864 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10865 WMITLV_SET_HDR(&cmd->tlv_header,
10866 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10867 WMITLV_GET_STRUCT_TLVLEN(
10868 wmi_gpio_output_cmd_fixed_param));
10869 cmd->gpio_num = param->gpio_num;
10870 cmd->set = param->set;
10871
10872 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10873 WMI_GPIO_OUTPUT_CMDID);
10874
10875 if (ret != 0) {
10876 WMI_LOGE("Sending GPIO output cmd failed\n");
10877 wmi_buf_free(buf);
10878 }
10879
10880 return ret;
10881
10882}
10883
10884/**
10885 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10886 *
10887 * @param wmi_handle : handle to WMI.
10888 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10889 */
10890static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10891{
10892 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10893 wmi_buf_t buf;
10894 QDF_STATUS ret;
10895 int32_t len;
10896
10897 len = sizeof(*cmd);
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_FAILURE;
10903 }
10904
10905 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10906 WMITLV_SET_HDR(&cmd->tlv_header,
10907 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10908 WMITLV_GET_STRUCT_TLVLEN(
10909 wmi_pdev_dfs_disable_cmd_fixed_param));
10910 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010911 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10912 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010913
10914 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10915 WMI_PDEV_DFS_DISABLE_CMDID);
10916
10917 if (ret != 0) {
10918 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10919 wmi_buf_free(buf);
10920 }
10921
10922 return ret;
10923}
10924
10925/**
10926 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10927 *
10928 * @param wmi_handle : handle to WMI.
10929 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10930 */
10931static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10932{
10933 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10934 wmi_buf_t buf;
10935 QDF_STATUS ret;
10936 int32_t len;
10937
10938 len = sizeof(*cmd);
10939
10940 buf = wmi_buf_alloc(wmi_handle, len);
10941 if (!buf) {
10942 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10943 return QDF_STATUS_E_FAILURE;
10944 }
10945
10946 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10947 WMITLV_SET_HDR(&cmd->tlv_header,
10948 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10949 WMITLV_GET_STRUCT_TLVLEN(
10950 wmi_pdev_dfs_enable_cmd_fixed_param));
10951 /* Reserved for future use */
10952 cmd->reserved0 = 0;
10953
10954 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10955 WMI_PDEV_DFS_ENABLE_CMDID);
10956
10957 if (ret != 0) {
10958 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10959 wmi_buf_free(buf);
10960 }
10961
10962 return ret;
10963}
10964
10965/**
10966 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10967 * @wmi_handle: wmi handle
10968 *
10969 * Return: 0 for success or error code
10970 */
10971static QDF_STATUS
10972send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10973{
10974 wmi_buf_t buf;
10975 QDF_STATUS ret;
10976
10977 buf = wmi_buf_alloc(wmi_handle, 0);
10978 if (buf == NULL)
10979 return QDF_STATUS_E_NOMEM;
10980
10981 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10982 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10983 if (ret != 0) {
10984 WMI_LOGE("Sending get nfcal power cmd failed\n");
10985 wmi_buf_free(buf);
10986 }
10987
10988 return ret;
10989}
10990
10991/**
10992 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10993 * @wmi_handle: wmi handle
10994 * @param: pointer to ht ie param
10995 *
10996 * Return: 0 for success or error code
10997 */
10998static QDF_STATUS
10999send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11000 struct ht_ie_params *param)
11001{
11002 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11003 wmi_buf_t buf;
11004 QDF_STATUS ret;
11005 int32_t len;
11006 uint8_t *buf_ptr;
11007
11008 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11009 roundup(param->ie_len, sizeof(uint32_t));
11010
11011 buf = wmi_buf_alloc(wmi_handle, len);
11012 if (!buf) {
11013 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11014 return QDF_STATUS_E_FAILURE;
11015 }
11016
11017 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11018 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11019 WMITLV_SET_HDR(&cmd->tlv_header,
11020 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11021 WMITLV_GET_STRUCT_TLVLEN(
11022 wmi_pdev_set_ht_ie_cmd_fixed_param));
11023 cmd->reserved0 = 0;
11024 cmd->ie_len = param->ie_len;
11025 cmd->tx_streams = param->tx_streams;
11026 cmd->rx_streams = param->rx_streams;
11027
11028 buf_ptr += sizeof(*cmd);
11029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11030 buf_ptr += WMI_TLV_HDR_SIZE;
11031 if (param->ie_len)
11032 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11033 cmd->ie_len);
11034
11035 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11036 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11037
11038 if (ret != 0) {
11039 WMI_LOGE("Sending set ht ie cmd failed\n");
11040 wmi_buf_free(buf);
11041 }
11042
11043 return ret;
11044}
11045
11046/**
11047 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11048 * @wmi_handle: wmi handle
11049 * @param: pointer to vht ie param
11050 *
11051 * Return: 0 for success or error code
11052 */
11053static QDF_STATUS
11054send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11055 struct vht_ie_params *param)
11056{
11057 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11058 wmi_buf_t buf;
11059 QDF_STATUS ret;
11060 int32_t len;
11061 uint8_t *buf_ptr;
11062
11063 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11064 roundup(param->ie_len, sizeof(uint32_t));
11065
11066 buf = wmi_buf_alloc(wmi_handle, len);
11067 if (!buf) {
11068 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11069 return QDF_STATUS_E_FAILURE;
11070 }
11071
11072 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11073 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11074 WMITLV_SET_HDR(&cmd->tlv_header,
11075 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11076 WMITLV_GET_STRUCT_TLVLEN(
11077 wmi_pdev_set_vht_ie_cmd_fixed_param));
11078 cmd->reserved0 = 0;
11079 cmd->ie_len = param->ie_len;
11080 cmd->tx_streams = param->tx_streams;
11081 cmd->rx_streams = param->rx_streams;
11082
11083 buf_ptr += sizeof(*cmd);
11084 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11085 buf_ptr += WMI_TLV_HDR_SIZE;
11086 if (param->ie_len)
11087 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11088 cmd->ie_len);
11089
11090 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11091 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11092
11093 if (ret != 0) {
11094 WMI_LOGE("Sending set vht ie cmd failed\n");
11095 wmi_buf_free(buf);
11096 }
11097
11098 return ret;
11099}
11100
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011101/**
11102 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11103 * @wmi_handle: wmi handle
11104 * @param: pointer to quiet mode params
11105 *
11106 * Return: 0 for success or error code
11107 */
11108static QDF_STATUS
11109send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11110 struct set_quiet_mode_params *param)
11111{
11112 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11113 wmi_buf_t buf;
11114 QDF_STATUS ret;
11115 int32_t len;
11116
11117 len = sizeof(*quiet_cmd);
11118 buf = wmi_buf_alloc(wmi_handle, len);
11119 if (!buf) {
11120 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11121 return QDF_STATUS_E_FAILURE;
11122 }
11123
11124 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11125 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11126 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11127 WMITLV_GET_STRUCT_TLVLEN(
11128 wmi_pdev_set_quiet_cmd_fixed_param));
11129 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11130 quiet_cmd->enabled = param->enabled;
11131 quiet_cmd->period = (param->period)*(param->intval);
11132 quiet_cmd->duration = param->duration;
11133 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011134 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11135 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011136
11137 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11138 WMI_PDEV_SET_QUIET_MODE_CMDID);
11139
11140 if (ret != 0) {
11141 WMI_LOGE("Sending set quiet cmd failed\n");
11142 wmi_buf_free(buf);
11143 }
11144
11145 return ret;
11146}
11147
11148/**
11149 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11150 * @wmi_handle: wmi handle
11151 * @param: pointer to set bwf param
11152 *
11153 * Return: 0 for success or error code
11154 */
11155static QDF_STATUS
11156send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11157 struct set_bwf_params *param)
11158{
11159 wmi_bwf_peer_info *peer_info;
11160 wmi_peer_bwf_request_fixed_param *cmd;
11161 wmi_buf_t buf;
11162 QDF_STATUS retval;
11163 int32_t len;
11164 uint8_t *buf_ptr;
11165 int i;
11166
11167 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11168 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11169 buf = wmi_buf_alloc(wmi_handle, len);
11170 if (!buf) {
11171 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11172 return QDF_STATUS_E_FAILURE;
11173 }
11174 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11175 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11176 WMITLV_SET_HDR(&cmd->tlv_header,
11177 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11178 WMITLV_GET_STRUCT_TLVLEN(
11179 wmi_peer_bwf_request_fixed_param));
11180 cmd->num_peers = param->num_peers;
11181
11182 buf_ptr += sizeof(*cmd);
11183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11184 sizeof(wmi_bwf_peer_info) *
11185 cmd->num_peers);
11186 buf_ptr += WMI_TLV_HDR_SIZE;
11187 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11188
11189 for (i = 0; i < cmd->num_peers; i++) {
11190 WMITLV_SET_HDR(&peer_info->tlv_header,
11191 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11192 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11193 peer_info->bwf_guaranteed_bandwidth =
11194 param->peer_info[i].throughput;
11195 peer_info->bwf_max_airtime =
11196 param->peer_info[i].max_airtime;
11197 peer_info->bwf_peer_priority =
11198 param->peer_info[i].priority;
11199 qdf_mem_copy(&peer_info->peer_macaddr,
11200 &param->peer_info[i].peer_macaddr,
11201 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011202 peer_info->vdev_id =
11203 param->peer_info[i].vdev_id;
11204 peer_info->pdev_id =
11205 wmi_handle->ops->convert_pdev_id_host_to_target(
11206 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011207 peer_info++;
11208 }
11209
11210 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11211 WMI_PEER_BWF_REQUEST_CMDID);
11212
11213 if (retval != QDF_STATUS_SUCCESS) {
11214 WMI_LOGE("%s : WMI Failed\n", __func__);
11215 wmi_buf_free(buf);
11216 }
11217
11218 return retval;
11219}
11220
11221/**
11222 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11223 * @wmi_handle: wmi handle
11224 * @param: pointer to hold mcast update param
11225 *
11226 * Return: 0 for success or error code
11227 */
11228static QDF_STATUS
11229send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11230 struct mcast_group_update_params *param)
11231{
11232 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11233 wmi_buf_t buf;
11234 QDF_STATUS ret;
11235 int32_t len;
11236 int offset = 0;
11237 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11238
11239 len = sizeof(*cmd);
11240 buf = wmi_buf_alloc(wmi_handle, len);
11241 if (!buf) {
11242 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11243 return QDF_STATUS_E_FAILURE;
11244 }
11245 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11246 WMITLV_SET_HDR(&cmd->tlv_header,
11247 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11248 WMITLV_GET_STRUCT_TLVLEN(
11249 wmi_peer_mcast_group_cmd_fixed_param));
11250 /* confirm the buffer is 4-byte aligned */
11251 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11252 qdf_mem_zero(cmd, sizeof(*cmd));
11253
11254 cmd->vdev_id = param->vap_id;
11255 /* construct the message assuming our endianness matches the target */
11256 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11257 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11258 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11259 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11260 if (param->is_action_delete)
11261 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11262
11263 if (param->is_mcast_addr_len)
11264 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11265
11266 if (param->is_filter_mode_snoop)
11267 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11268
11269 /* unicast address spec only applies for non-wildcard cases */
11270 if (!param->wildcard && param->ucast_mac_addr) {
11271 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11272 &cmd->ucast_mac_addr);
11273 }
11274 if (param->mcast_ip_addr) {
11275 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11276 sizeof(cmd->mcast_ip_addr));
11277 offset = sizeof(cmd->mcast_ip_addr) -
11278 param->mcast_ip_addr_bytes;
11279 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11280 param->mcast_ip_addr,
11281 param->mcast_ip_addr_bytes);
11282 }
11283 if (!param->mask)
11284 param->mask = &dummymask[0];
11285
11286 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11287 param->mask,
11288 param->mcast_ip_addr_bytes);
11289
11290 if (param->srcs && param->nsrcs) {
11291 cmd->num_filter_addr = param->nsrcs;
11292 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11293 sizeof(cmd->filter_addr));
11294
11295 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11296 param->nsrcs * param->mcast_ip_addr_bytes);
11297 }
11298
11299 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11300 WMI_PEER_MCAST_GROUP_CMDID);
11301
11302 if (ret != QDF_STATUS_SUCCESS) {
11303 WMI_LOGE("%s : WMI Failed\n", __func__);
11304 wmi_buf_free(buf);
11305 }
11306
11307 return ret;
11308}
11309
11310/**
11311 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11312 * command to fw
11313 * @wmi_handle: wmi handle
11314 * @param: pointer to hold spectral config parameter
11315 *
11316 * Return: 0 for success or error code
11317 */
11318static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11319 struct vdev_spectral_configure_params *param)
11320{
11321 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11322 wmi_buf_t buf;
11323 QDF_STATUS ret;
11324 int32_t len;
11325
11326 len = sizeof(*cmd);
11327 buf = wmi_buf_alloc(wmi_handle, len);
11328 if (!buf) {
11329 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11330 return QDF_STATUS_E_FAILURE;
11331 }
11332
11333 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11334 WMITLV_SET_HDR(&cmd->tlv_header,
11335 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11336 WMITLV_GET_STRUCT_TLVLEN(
11337 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
11338
11339 cmd->vdev_id = param->vdev_id;
11340 cmd->spectral_scan_count = param->count;
11341 cmd->spectral_scan_period = param->period;
11342 cmd->spectral_scan_priority = param->spectral_pri;
11343 cmd->spectral_scan_fft_size = param->fft_size;
11344 cmd->spectral_scan_gc_ena = param->gc_enable;
11345 cmd->spectral_scan_restart_ena = param->restart_enable;
11346 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11347 cmd->spectral_scan_init_delay = param->init_delay;
11348 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11349 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11350 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11351 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11352 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11353 cmd->spectral_scan_pwr_format = param->pwr_format;
11354 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11355 cmd->spectral_scan_bin_scale = param->bin_scale;
11356 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11357 cmd->spectral_scan_chn_mask = param->chn_mask;
11358
11359 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11360 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11361
11362 if (ret != 0) {
11363 WMI_LOGE("Sending set quiet cmd failed\n");
11364 wmi_buf_free(buf);
11365 }
11366
11367 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11368 __func__);
11369
11370 WMI_LOGI("vdev_id = %u\n"
11371 "spectral_scan_count = %u\n"
11372 "spectral_scan_period = %u\n"
11373 "spectral_scan_priority = %u\n"
11374 "spectral_scan_fft_size = %u\n"
11375 "spectral_scan_gc_ena = %u\n"
11376 "spectral_scan_restart_ena = %u\n"
11377 "spectral_scan_noise_floor_ref = %u\n"
11378 "spectral_scan_init_delay = %u\n"
11379 "spectral_scan_nb_tone_thr = %u\n"
11380 "spectral_scan_str_bin_thr = %u\n"
11381 "spectral_scan_wb_rpt_mode = %u\n"
11382 "spectral_scan_rssi_rpt_mode = %u\n"
11383 "spectral_scan_rssi_thr = %u\n"
11384 "spectral_scan_pwr_format = %u\n"
11385 "spectral_scan_rpt_mode = %u\n"
11386 "spectral_scan_bin_scale = %u\n"
11387 "spectral_scan_dBm_adj = %u\n"
11388 "spectral_scan_chn_mask = %u\n",
11389 param->vdev_id,
11390 param->count,
11391 param->period,
11392 param->spectral_pri,
11393 param->fft_size,
11394 param->gc_enable,
11395 param->restart_enable,
11396 param->noise_floor_ref,
11397 param->init_delay,
11398 param->nb_tone_thr,
11399 param->str_bin_thr,
11400 param->wb_rpt_mode,
11401 param->rssi_rpt_mode,
11402 param->rssi_thr,
11403 param->pwr_format,
11404 param->rpt_mode,
11405 param->bin_scale,
11406 param->dBm_adj,
11407 param->chn_mask);
11408 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11409
11410 return ret;
11411}
11412
11413/**
11414 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11415 * command to fw
11416 * @wmi_handle: wmi handle
11417 * @param: pointer to hold spectral enable parameter
11418 *
11419 * Return: 0 for success or error code
11420 */
11421static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11422 struct vdev_spectral_enable_params *param)
11423{
11424 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11425 wmi_buf_t buf;
11426 QDF_STATUS ret;
11427 int32_t len;
11428
11429 len = sizeof(*cmd);
11430 buf = wmi_buf_alloc(wmi_handle, len);
11431 if (!buf) {
11432 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11433 return QDF_STATUS_E_FAILURE;
11434 }
11435
11436 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11437 WMITLV_SET_HDR(&cmd->tlv_header,
11438 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11439 WMITLV_GET_STRUCT_TLVLEN(
11440 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11441
11442 cmd->vdev_id = param->vdev_id;
11443
11444 if (param->active_valid) {
11445 cmd->trigger_cmd = param->active ? 1 : 2;
11446 /* 1: Trigger, 2: Clear Trigger */
11447 } else {
11448 cmd->trigger_cmd = 0; /* 0: Ignore */
11449 }
11450
11451 if (param->enabled_valid) {
11452 cmd->enable_cmd = param->enabled ? 1 : 2;
11453 /* 1: Enable 2: Disable */
11454 } else {
11455 cmd->enable_cmd = 0; /* 0: Ignore */
11456 }
11457
11458 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11459 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11460
11461 if (ret != 0) {
11462 WMI_LOGE("Sending scan enable CMD failed\n");
11463 wmi_buf_free(buf);
11464 }
11465
11466 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11467
11468 WMI_LOGI("vdev_id = %u\n"
11469 "trigger_cmd = %u\n"
11470 "enable_cmd = %u\n",
11471 cmd->vdev_id,
11472 cmd->trigger_cmd,
11473 cmd->enable_cmd);
11474
11475 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11476
11477 return ret;
11478}
11479
11480/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011481 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11482 * @param wmi_handle : handle to WMI.
11483 * @param param : pointer to hold thermal mitigation param
11484 *
11485 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11486 */
11487static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11488 wmi_unified_t wmi_handle,
11489 struct thermal_mitigation_params *param)
11490{
11491 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11492 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11493 wmi_buf_t buf = NULL;
11494 uint8_t *buf_ptr = NULL;
11495 int error;
11496 int32_t len;
11497 int i;
11498
11499 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11500 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11501
11502 buf = wmi_buf_alloc(wmi_handle, len);
11503 if (!buf) {
11504 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11505 return QDF_STATUS_E_NOMEM;
11506 }
11507 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11508
11509 /* init fixed params */
11510 WMITLV_SET_HDR(tt_conf,
11511 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11512 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11513
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011514 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11515 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011516 tt_conf->enable = param->enable;
11517 tt_conf->dc = param->dc;
11518 tt_conf->dc_per_event = param->dc_per_event;
11519 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11520
11521 buf_ptr = (uint8_t *) ++tt_conf;
11522 /* init TLV params */
11523 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11524 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11525
11526 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11527 for (i = 0; i < THERMAL_LEVELS; i++) {
11528 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11529 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11530 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11531 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11532 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11533 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11534 lvl_conf->prio = param->levelconf[i].priority;
11535 lvl_conf++;
11536 }
11537
11538 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11539 WMI_THERM_THROT_SET_CONF_CMDID);
11540 if (QDF_IS_STATUS_ERROR(error)) {
11541 wmi_buf_free(buf);
11542 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11543 }
11544
11545 return error;
11546}
11547
11548/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011549 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11550 * @wmi_handle: wmi handle
11551 * @param: pointer to pdev_qvit_params
11552 *
11553 * Return: 0 for success or error code
11554 */
11555static QDF_STATUS
11556send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11557 struct pdev_qvit_params *param)
11558{
11559 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011560 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011561 uint8_t *cmd;
11562 static uint8_t msgref = 1;
11563 uint8_t segnumber = 0, seginfo, numsegments;
11564 uint16_t chunk_len, total_bytes;
11565 uint8_t *bufpos;
11566 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11567
11568 bufpos = param->utf_payload;
11569 total_bytes = param->len;
11570 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11571 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11572 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11573
11574 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11575 numsegments++;
11576
11577 while (param->len) {
11578 if (param->len > MAX_WMI_QVIT_LEN)
11579 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11580 else
11581 chunk_len = param->len;
11582
11583 buf = wmi_buf_alloc(wmi_handle,
11584 (chunk_len + sizeof(seghdrinfo) +
11585 WMI_TLV_HDR_SIZE));
11586 if (!buf) {
11587 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11588 return QDF_STATUS_E_NOMEM;
11589 }
11590
11591 cmd = (uint8_t *) wmi_buf_data(buf);
11592
11593 seghdrinfo.len = total_bytes;
11594 seghdrinfo.msgref = msgref;
11595 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11596 seghdrinfo.segmentInfo = seginfo;
11597
11598 segnumber++;
11599
11600 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11601 (chunk_len + sizeof(seghdrinfo)));
11602 cmd += WMI_TLV_HDR_SIZE;
11603 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11604 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11605
11606 ret = wmi_unified_cmd_send(wmi_handle, buf,
11607 (chunk_len + sizeof(seghdrinfo) +
11608 WMI_TLV_HDR_SIZE),
11609 WMI_PDEV_QVIT_CMDID);
11610
11611 if (ret != 0) {
11612 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11613 wmi_buf_free(buf);
11614 break;
11615 }
11616
11617 param->len -= chunk_len;
11618 bufpos += chunk_len;
11619 }
11620 msgref++;
11621
11622 return ret;
11623}
11624
11625/**
11626 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11627 * @wmi_handle: wmi handle
11628 * @param: pointer to wmm update param
11629 *
11630 * Return: 0 for success or error code
11631 */
11632static QDF_STATUS
11633send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11634 struct wmm_update_params *param)
11635{
11636 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11637 wmi_wmm_params *wmm_param;
11638 wmi_buf_t buf;
11639 QDF_STATUS ret;
11640 int32_t len;
11641 int ac = 0;
11642 struct wmi_host_wmeParams *wmep;
11643 uint8_t *buf_ptr;
11644
11645 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11646 buf = wmi_buf_alloc(wmi_handle, len);
11647 if (!buf) {
11648 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11649 return QDF_STATUS_E_FAILURE;
11650 }
11651
11652 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11653 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11654 WMITLV_SET_HDR(&cmd->tlv_header,
11655 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11656 WMITLV_GET_STRUCT_TLVLEN
11657 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11658
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011659 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011660
11661 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11662
11663 for (ac = 0; ac < WME_NUM_AC; ac++) {
11664 wmep = &param->wmep_array[ac];
11665 wmm_param = (wmi_wmm_params *)buf_ptr;
11666 WMITLV_SET_HDR(&wmm_param->tlv_header,
11667 WMITLV_TAG_STRUC_wmi_wmm_params,
11668 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11669 wmm_param->aifs = wmep->wmep_aifsn;
11670 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11671 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11672 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11673 wmm_param->acm = wmep->wmep_acm;
11674 wmm_param->no_ack = wmep->wmep_noackPolicy;
11675 buf_ptr += sizeof(wmi_wmm_params);
11676 }
11677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11678 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11679
11680 if (ret != 0) {
11681 WMI_LOGE("Sending WMM update CMD failed\n");
11682 wmi_buf_free(buf);
11683 }
11684
11685 return ret;
11686}
11687
Sathish Kumar80f4f382017-04-24 11:36:00 +053011688/**
11689 * send_coex_config_cmd_tlv() - send coex config command to fw
11690 * @wmi_handle: wmi handle
11691 * @param: pointer to coex config param
11692 *
11693 * Return: 0 for success or error code
11694 */
11695static QDF_STATUS
11696send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
11697 struct coex_config_params *param)
11698{
11699 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
11700 wmi_buf_t buf;
11701 QDF_STATUS ret;
11702 int32_t len;
11703
11704 len = sizeof(*cmd);
11705 buf = wmi_buf_alloc(wmi_handle, len);
11706 if (!buf) {
11707 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11708 return QDF_STATUS_E_FAILURE;
11709 }
11710
11711 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
11712 WMITLV_SET_HDR(&cmd->tlv_header,
11713 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
11714 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053011715 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053011716
11717 cmd->vdev_id = param->vdev_id;
11718 cmd->config_type = param->config_type;
11719 cmd->config_arg1 = param->config_arg1;
11720 cmd->config_arg2 = param->config_arg2;
11721 cmd->config_arg3 = param->config_arg3;
11722 cmd->config_arg4 = param->config_arg4;
11723 cmd->config_arg5 = param->config_arg5;
11724 cmd->config_arg6 = param->config_arg6;
11725
11726 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11727 WMI_COEX_CONFIG_CMDID);
11728
11729 if (ret != 0) {
11730 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
11731 wmi_buf_free(buf);
11732 }
11733
11734 return ret;
11735}
11736
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011737static
Govind Singh9ddd5162016-03-07 16:30:32 +053011738void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011739 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011740{
Govind Singhe7f2f342016-05-23 12:12:52 +053011741 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011742 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11743 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11744 resource_cfg->num_offload_reorder_buffs =
11745 tgt_res_cfg->num_offload_reorder_buffs;
11746 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11747 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11748 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11749 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11750 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11751 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11752 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11753 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11754 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11755 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11756 resource_cfg->scan_max_pending_req =
11757 tgt_res_cfg->scan_max_pending_req;
11758 resource_cfg->bmiss_offload_max_vdev =
11759 tgt_res_cfg->bmiss_offload_max_vdev;
11760 resource_cfg->roam_offload_max_vdev =
11761 tgt_res_cfg->roam_offload_max_vdev;
11762 resource_cfg->roam_offload_max_ap_profiles =
11763 tgt_res_cfg->roam_offload_max_ap_profiles;
11764 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11765 resource_cfg->num_mcast_table_elems =
11766 tgt_res_cfg->num_mcast_table_elems;
11767 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11768 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11769 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11770 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11771 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11772 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11773 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11774 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11775 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11776 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11777 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11778 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11779 resource_cfg->num_tdls_conn_table_entries =
11780 tgt_res_cfg->num_tdls_conn_table_entries;
11781 resource_cfg->beacon_tx_offload_max_vdev =
11782 tgt_res_cfg->beacon_tx_offload_max_vdev;
11783 resource_cfg->num_multicast_filter_entries =
11784 tgt_res_cfg->num_multicast_filter_entries;
11785 resource_cfg->num_wow_filters =
11786 tgt_res_cfg->num_wow_filters;
11787 resource_cfg->num_keep_alive_pattern =
11788 tgt_res_cfg->num_keep_alive_pattern;
11789 resource_cfg->keep_alive_pattern_size =
11790 tgt_res_cfg->keep_alive_pattern_size;
11791 resource_cfg->max_tdls_concurrent_sleep_sta =
11792 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11793 resource_cfg->max_tdls_concurrent_buffer_sta =
11794 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11795 resource_cfg->wmi_send_separate =
11796 tgt_res_cfg->wmi_send_separate;
11797 resource_cfg->num_ocb_vdevs =
11798 tgt_res_cfg->num_ocb_vdevs;
11799 resource_cfg->num_ocb_channels =
11800 tgt_res_cfg->num_ocb_channels;
11801 resource_cfg->num_ocb_schedules =
11802 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011803 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11804 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11805 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011806
11807 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
11808 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053011809}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011810#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011811/**
11812 * send_init_cmd_tlv() - wmi init command
11813 * @wmi_handle: pointer to wmi handle
11814 * @res_cfg: resource config
11815 * @num_mem_chunks: no of mem chunck
11816 * @mem_chunk: pointer to mem chunck structure
11817 *
11818 * This function sends IE information to firmware
11819 *
Govind Singhb53420c2016-03-09 14:32:57 +053011820 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011821 *
11822 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011823static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011824 wmi_resource_config *tgt_res_cfg,
11825 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11826 bool action)
11827{
11828 wmi_buf_t buf;
11829 wmi_init_cmd_fixed_param *cmd;
11830 wmi_abi_version my_vers;
11831 int num_whitelist;
11832 uint8_t *buf_ptr;
11833 wmi_resource_config *resource_cfg;
11834 wlan_host_memory_chunk *host_mem_chunks;
11835 uint32_t mem_chunk_len = 0;
11836 uint16_t idx;
11837 int len;
11838 int ret;
11839
11840 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11841 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11842 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11843 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011844 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11845 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011846 }
11847
11848 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11849 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11850 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11851
11852 host_mem_chunks = (wlan_host_memory_chunk *)
11853 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11854 + WMI_TLV_HDR_SIZE);
11855
11856 WMITLV_SET_HDR(&cmd->tlv_header,
11857 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11858 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11859
Govind Singhb53420c2016-03-09 14:32:57 +053011860 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011861 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11862 WMITLV_TAG_STRUC_wmi_resource_config,
11863 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11864
11865 for (idx = 0; idx < num_mem_chunks; ++idx) {
11866 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11867 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11868 WMITLV_GET_STRUCT_TLVLEN
11869 (wlan_host_memory_chunk));
11870 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11871 host_mem_chunks[idx].size = mem_chunks[idx].len;
11872 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011873 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011874 idx, host_mem_chunks[idx].size,
11875 host_mem_chunks[idx].ptr);
11876 }
11877 cmd->num_host_mem_chunks = num_mem_chunks;
11878 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11879 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11880 WMITLV_TAG_ARRAY_STRUC,
11881 (sizeof(wlan_host_memory_chunk) *
11882 num_mem_chunks));
11883
11884 num_whitelist = sizeof(version_whitelist) /
11885 sizeof(wmi_whitelist_version_info);
11886 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11887 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11888 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11889 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11890 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11891 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011892#ifdef CONFIG_MCL
11893 /* This needs to be enabled for WIN Lithium after removing dependency
11894 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011895 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11896 &my_vers,
11897 &wmi_handle->fw_abi_version,
11898 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011899#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011900 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011901 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11902 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11903 cmd->host_abi_vers.abi_version_ns_0,
11904 cmd->host_abi_vers.abi_version_ns_1,
11905 cmd->host_abi_vers.abi_version_ns_2,
11906 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011907#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011908 /* Save version sent from host -
11909 * Will be used to check ready event
11910 */
Govind Singhb53420c2016-03-09 14:32:57 +053011911 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011912 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011913#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011914 if (action) {
11915 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11916 WMI_INIT_CMDID);
11917 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011918 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011919 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011920 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011921 }
11922 } else {
11923 wmi_handle->saved_wmi_init_cmd.buf = buf;
11924 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11925 }
11926
Govind Singhb53420c2016-03-09 14:32:57 +053011927 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011928
11929}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011930#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011931/**
11932 * send_saved_init_cmd_tlv() - wmi init command
11933 * @wmi_handle: pointer to wmi handle
11934 *
11935 * This function sends IE information to firmware
11936 *
Govind Singhb53420c2016-03-09 14:32:57 +053011937 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011938 *
11939 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011940static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011941{
11942 int status;
11943
11944 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11945 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011946 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11947 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011948 }
11949 status = wmi_unified_cmd_send(wmi_handle,
11950 wmi_handle->saved_wmi_init_cmd.buf,
11951 wmi_handle->saved_wmi_init_cmd.buf_len,
11952 WMI_INIT_CMDID);
11953 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011954 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011955 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011956 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011957 }
11958 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11959 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11960
Govind Singhb53420c2016-03-09 14:32:57 +053011961 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011962}
11963
Sathish Kumarfd347372017-02-13 12:29:09 +053011964static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011965{
11966 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11967 wmi_service_ready_event_fixed_param *ev;
11968
11969
11970 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11971
11972 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11973 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011974 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011975
Govind Singh87542482016-06-08 19:40:11 +053011976#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011977 /*Save fw version from service ready message */
11978 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011979 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011980 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011981#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011982 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011983}
11984
11985/**
11986 * wmi_unified_save_fw_version_cmd() - save fw version
11987 * @wmi_handle: pointer to wmi handle
11988 * @res_cfg: resource config
11989 * @num_mem_chunks: no of mem chunck
11990 * @mem_chunk: pointer to mem chunck structure
11991 *
11992 * This function sends IE information to firmware
11993 *
Govind Singhb53420c2016-03-09 14:32:57 +053011994 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011995 *
11996 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011997static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011998 void *evt_buf)
11999{
12000 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12001 wmi_ready_event_fixed_param *ev = NULL;
12002
12003 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12004 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053012005#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012006 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
12007 &ev->fw_abi_vers)) {
12008 /*
12009 * Error: Our host version and the given firmware version
12010 * are incompatible.
12011 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012012 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012013 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12014 __func__,
12015 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12016 abi_version_0),
12017 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12018 abi_version_0),
12019 wmi_handle->final_abi_vers.abi_version_ns_0,
12020 wmi_handle->final_abi_vers.abi_version_ns_1,
12021 wmi_handle->final_abi_vers.abi_version_ns_2,
12022 wmi_handle->final_abi_vers.abi_version_ns_3,
12023 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12024 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12025 ev->fw_abi_vers.abi_version_ns_0,
12026 ev->fw_abi_vers.abi_version_ns_1,
12027 ev->fw_abi_vers.abi_version_ns_2,
12028 ev->fw_abi_vers.abi_version_ns_3);
12029
Govind Singhb53420c2016-03-09 14:32:57 +053012030 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012031 }
Govind Singhb53420c2016-03-09 14:32:57 +053012032 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012033 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012034 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012035 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012036#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012037
Govind Singhb53420c2016-03-09 14:32:57 +053012038 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012039}
Govind Singha4836fd2016-03-07 16:45:38 +053012040
12041/**
12042 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12043 * @wmi_handle: wmi handle
12044 * @custom_addr: base mac address
12045 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012046 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012047 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012048static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012049 uint8_t *custom_addr)
12050{
12051 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12052 wmi_buf_t buf;
12053 int err;
12054
12055 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12056 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012057 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012058 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012059 }
12060
12061 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012062 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012063
12064 WMITLV_SET_HDR(&cmd->tlv_header,
12065 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12066 WMITLV_GET_STRUCT_TLVLEN
12067 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12068 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012069 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12070 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012071 err = wmi_unified_cmd_send(wmi_handle, buf,
12072 sizeof(*cmd),
12073 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12074 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012075 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012076 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012077 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012078 }
12079
12080 return 0;
12081}
12082
12083/**
12084 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12085 * @handle: wmi handle
12086 * @event: Event received from FW
12087 * @len: Length of the event
12088 *
12089 * Enables the low frequency events and disables the high frequency
12090 * events. Bit 17 indicates if the event if low/high frequency.
12091 * 1 - high frequency, 0 - low frequency
12092 *
12093 * Return: 0 on successfully enabling/disabling the events
12094 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012095static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012096 uint8_t *event,
12097 uint32_t len)
12098{
12099 uint32_t num_of_diag_events_logs;
12100 wmi_diag_event_log_config_fixed_param *cmd;
12101 wmi_buf_t buf;
12102 uint8_t *buf_ptr;
12103 uint32_t *cmd_args, *evt_args;
12104 uint32_t buf_len, i;
12105
12106 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12107 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12108
Govind Singhb53420c2016-03-09 14:32:57 +053012109 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012110
12111 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12112 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012113 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012114 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012115 }
12116 wmi_event = param_buf->fixed_param;
12117 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12118 evt_args = param_buf->diag_events_logs_list;
12119 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012120 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012121 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012122 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012123 }
12124
Govind Singhb53420c2016-03-09 14:32:57 +053012125 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012126 __func__, num_of_diag_events_logs);
12127
12128 /* Free any previous allocation */
12129 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012130 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012131
12132 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012133 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012134 sizeof(uint32_t));
12135 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012136 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012137 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012138 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012139 }
12140 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12141
12142 /* Prepare the send buffer */
12143 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12144 (num_of_diag_events_logs * sizeof(uint32_t));
12145
12146 buf = wmi_buf_alloc(wmi_handle, buf_len);
12147 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012148 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12149 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012150 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012151 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012152 }
12153
12154 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12155 buf_ptr = (uint8_t *) cmd;
12156
12157 WMITLV_SET_HDR(&cmd->tlv_header,
12158 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12159 WMITLV_GET_STRUCT_TLVLEN(
12160 wmi_diag_event_log_config_fixed_param));
12161
12162 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12163
12164 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12165
12166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12167 (num_of_diag_events_logs * sizeof(uint32_t)));
12168
12169 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12170
12171 /* Populate the events */
12172 for (i = 0; i < num_of_diag_events_logs; i++) {
12173 /* Low freq (0) - Enable (1) the event
12174 * High freq (1) - Disable (0) the event
12175 */
12176 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12177 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12178 /* Set the event ID */
12179 WMI_DIAG_ID_SET(cmd_args[i],
12180 WMI_DIAG_ID_GET(evt_args[i]));
12181 /* Set the type */
12182 WMI_DIAG_TYPE_SET(cmd_args[i],
12183 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012184 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012185 wmi_handle->events_logs_list[i] = evt_args[i];
12186 }
12187
12188 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12189 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012190 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012191 __func__);
12192 wmi_buf_free(buf);
12193 /* Not clearing events_logs_list, though wmi cmd failed.
12194 * Host can still have this list
12195 */
Govind Singh67922e82016-04-01 16:48:57 +053012196 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012197 }
12198
12199 return 0;
12200}
12201
12202/**
12203 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12204 * @wmi_handle: wmi handle
12205 * @start_log: Start logging related parameters
12206 *
12207 * Send the command to the FW based on which specific logging of diag
12208 * event/log id can be started/stopped
12209 *
12210 * Return: None
12211 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012212static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012213 struct wmi_wifi_start_log *start_log)
12214{
12215 wmi_diag_event_log_config_fixed_param *cmd;
12216 wmi_buf_t buf;
12217 uint8_t *buf_ptr;
12218 uint32_t len, count, log_level, i;
12219 uint32_t *cmd_args;
12220 uint32_t total_len;
12221 count = 0;
12222
12223 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012224 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012225 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012226 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012227 }
12228 /* total_len stores the number of events where BITS 17 and 18 are set.
12229 * i.e., events of high frequency (17) and for extended debugging (18)
12230 */
12231 total_len = 0;
12232 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12233 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12234 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12235 total_len++;
12236 }
12237
12238 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12239 (total_len * sizeof(uint32_t));
12240
12241 buf = wmi_buf_alloc(wmi_handle, len);
12242 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012243 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012244 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012245 }
12246 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12247 buf_ptr = (uint8_t *) cmd;
12248
12249 WMITLV_SET_HDR(&cmd->tlv_header,
12250 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12251 WMITLV_GET_STRUCT_TLVLEN(
12252 wmi_diag_event_log_config_fixed_param));
12253
12254 cmd->num_of_diag_events_logs = total_len;
12255
12256 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12257
12258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12259 (total_len * sizeof(uint32_t)));
12260
12261 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12262
Govind Singh224a7312016-06-21 14:33:26 +053012263 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012264 log_level = 1;
12265 else
12266 log_level = 0;
12267
Govind Singhb53420c2016-03-09 14:32:57 +053012268 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012269 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12270 uint32_t val = wmi_handle->events_logs_list[i];
12271 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12272 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12273
12274 WMI_DIAG_ID_SET(cmd_args[count],
12275 WMI_DIAG_ID_GET(val));
12276 WMI_DIAG_TYPE_SET(cmd_args[count],
12277 WMI_DIAG_TYPE_GET(val));
12278 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12279 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012280 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012281 count++;
12282 }
12283 }
12284
12285 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12286 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012287 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012288 __func__);
12289 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012290 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012291 }
12292
Govind Singhb53420c2016-03-09 14:32:57 +053012293 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012294}
12295
12296/**
12297 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12298 * @wmi_handle: WMI handle
12299 *
12300 * This function is used to send the flush command to the FW,
12301 * that will flush the fw logs that are residue in the FW
12302 *
12303 * Return: None
12304 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012305static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012306{
12307 wmi_debug_mesg_flush_fixed_param *cmd;
12308 wmi_buf_t buf;
12309 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012310 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012311
12312 buf = wmi_buf_alloc(wmi_handle, len);
12313 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012314 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012315 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012316 }
12317
12318 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12319 WMITLV_SET_HDR(&cmd->tlv_header,
12320 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12321 WMITLV_GET_STRUCT_TLVLEN(
12322 wmi_debug_mesg_flush_fixed_param));
12323 cmd->reserved0 = 0;
12324
12325 ret = wmi_unified_cmd_send(wmi_handle,
12326 buf,
12327 len,
12328 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012329 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012330 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012331 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012332 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012333 }
Govind Singhb53420c2016-03-09 14:32:57 +053012334 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012335
Govind Singh67922e82016-04-01 16:48:57 +053012336 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012337}
12338
12339/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012340 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012341 * @wmi_handle: wmi handle
12342 * @msg: PCL structure containing the PCL and the number of channels
12343 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012344 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012345 * firmware. The DBS Manager is the consumer of this information in the WLAN
12346 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12347 * to migrate to a new channel without host driver involvement. An example of
12348 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12349 * manage the channel selection without firmware involvement.
12350 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012351 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12352 * channel list. The weights corresponds to the channels sent in
12353 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12354 * weightage compared to the non PCL channels.
12355 *
Govind Singha4836fd2016-03-07 16:45:38 +053012356 * Return: Success if the cmd is sent successfully to the firmware
12357 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012358static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012359 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012360{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012361 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012362 wmi_buf_t buf;
12363 uint8_t *buf_ptr;
12364 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012365 uint32_t chan_len;
12366
12367 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012368
12369 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012370 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012371
12372 buf = wmi_buf_alloc(wmi_handle, len);
12373 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012374 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12375 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012376 }
12377
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012378 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012379 buf_ptr = (uint8_t *) cmd;
12380 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012381 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12382 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012383
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012384 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12385 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012386 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012387 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012388
12389 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012391 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012392 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012393 for (i = 0; i < chan_len ; i++) {
12394 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012395 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012396 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012397 }
12398 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012399 WMI_PDEV_SET_PCL_CMDID)) {
12400 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012401 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012402 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012403 }
Govind Singhb53420c2016-03-09 14:32:57 +053012404 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012405}
12406
12407/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012408 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012409 * @wmi_handle: wmi handle
12410 * @msg: Structure containing the following parameters
12411 *
12412 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12413 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12414 *
12415 * Provides notification to the WLAN firmware that host driver is requesting a
12416 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12417 * configurations that include the Dual Band Simultaneous (DBS) feature.
12418 *
12419 * Return: Success if the cmd is sent successfully to the firmware
12420 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012421static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012422 uint32_t hw_mode_index)
12423{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012424 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012425 wmi_buf_t buf;
12426 uint32_t len;
12427
12428 len = sizeof(*cmd);
12429
12430 buf = wmi_buf_alloc(wmi_handle, len);
12431 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012432 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12433 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012434 }
12435
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012436 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012437 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012438 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12439 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12440
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012441 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12442 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012443 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012444 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012445
12446 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012447 WMI_PDEV_SET_HW_MODE_CMDID)) {
12448 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012449 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012450 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012451 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012452 }
12453
Govind Singhb53420c2016-03-09 14:32:57 +053012454 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012455}
12456
12457/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012458 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012459 * @wmi_handle: wmi handle
12460 * @msg: Dual MAC config parameters
12461 *
12462 * Configures WLAN firmware with the dual MAC features
12463 *
Govind Singhb53420c2016-03-09 14:32:57 +053012464 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012465 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012466static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012467QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012468 struct wmi_dual_mac_config *msg)
12469{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012470 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012471 wmi_buf_t buf;
12472 uint32_t len;
12473
12474 len = sizeof(*cmd);
12475
12476 buf = wmi_buf_alloc(wmi_handle, len);
12477 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012478 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12479 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012480 }
12481
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012482 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012483 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012484 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012485 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012486 wmi_pdev_set_mac_config_cmd_fixed_param));
12487
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012488 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12489 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012490 cmd->concurrent_scan_config_bits = msg->scan_config;
12491 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012492 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012493 __func__, msg->scan_config, msg->fw_mode_config);
12494
12495 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012496 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12497 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012498 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012499 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012500 }
Govind Singhb53420c2016-03-09 14:32:57 +053012501 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012502}
12503
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012504#ifdef BIG_ENDIAN_HOST
12505/**
12506* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12507* @param data_len - data length
12508* @param data - pointer to data
12509*
12510* Return: QDF_STATUS - success or error status
12511*/
12512static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12513 struct fips_params *param)
12514{
12515 unsigned char *key_unaligned, *data_unaligned;
12516 int c;
12517 u_int8_t *key_aligned = NULL;
12518 u_int8_t *data_aligned = NULL;
12519
12520 /* Assigning unaligned space to copy the key */
12521 key_unaligned = qdf_mem_malloc(
12522 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12523 data_unaligned = qdf_mem_malloc(
12524 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12525
12526 /* Checking if kmalloc is succesful to allocate space */
12527 if (key_unaligned == NULL)
12528 return QDF_STATUS_SUCCESS;
12529 /* Checking if space is aligned */
12530 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12531 /* align to 4 */
12532 key_aligned =
12533 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12534 FIPS_ALIGN);
12535 } else {
12536 key_aligned = (u_int8_t *)key_unaligned;
12537 }
12538
12539 /* memset and copy content from key to key aligned */
12540 OS_MEMSET(key_aligned, 0, param->key_len);
12541 OS_MEMCPY(key_aligned, param->key, param->key_len);
12542
12543 /* print a hexdump for host debug */
12544 print_hex_dump(KERN_DEBUG,
12545 "\t Aligned and Copied Key:@@@@ ",
12546 DUMP_PREFIX_NONE,
12547 16, 1, key_aligned, param->key_len, true);
12548
12549 /* Checking if kmalloc is succesful to allocate space */
12550 if (data_unaligned == NULL)
12551 return QDF_STATUS_SUCCESS;
12552 /* Checking of space is aligned */
12553 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12554 /* align to 4 */
12555 data_aligned =
12556 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12557 FIPS_ALIGN);
12558 } else {
12559 data_aligned = (u_int8_t *)data_unaligned;
12560 }
12561
12562 /* memset and copy content from data to data aligned */
12563 OS_MEMSET(data_aligned, 0, param->data_len);
12564 OS_MEMCPY(data_aligned, param->data, param->data_len);
12565
12566 /* print a hexdump for host debug */
12567 print_hex_dump(KERN_DEBUG,
12568 "\t Properly Aligned and Copied Data:@@@@ ",
12569 DUMP_PREFIX_NONE,
12570 16, 1, data_aligned, param->data_len, true);
12571
12572 /* converting to little Endian both key_aligned and
12573 * data_aligned*/
12574 for (c = 0; c < param->key_len/4; c++) {
12575 *((u_int32_t *)key_aligned+c) =
12576 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12577 }
12578 for (c = 0; c < param->data_len/4; c++) {
12579 *((u_int32_t *)data_aligned+c) =
12580 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12581 }
12582
12583 /* update endian data to key and data vectors */
12584 OS_MEMCPY(param->key, key_aligned, param->key_len);
12585 OS_MEMCPY(param->data, data_aligned, param->data_len);
12586
12587 /* clean up allocated spaces */
12588 qdf_mem_free(key_unaligned);
12589 key_unaligned = NULL;
12590 key_aligned = NULL;
12591
12592 qdf_mem_free(data_unaligned);
12593 data_unaligned = NULL;
12594 data_aligned = NULL;
12595
12596 return QDF_STATUS_SUCCESS;
12597}
12598#else
12599/**
12600* fips_align_data_be() - DUMMY for LE platform
12601*
12602* Return: QDF_STATUS - success
12603*/
12604static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12605 struct fips_params *param)
12606{
12607 return QDF_STATUS_SUCCESS;
12608}
12609#endif
12610
12611
12612/**
12613 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12614 * @wmi_handle: wmi handle
12615 * @param: pointer to hold pdev fips param
12616 *
12617 * Return: 0 for success or error code
12618 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012619static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012620send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12621 struct fips_params *param)
12622{
12623 wmi_pdev_fips_cmd_fixed_param *cmd;
12624 wmi_buf_t buf;
12625 uint8_t *buf_ptr;
12626 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12627 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12628
12629 /* Length TLV placeholder for array of bytes */
12630 len += WMI_TLV_HDR_SIZE;
12631 if (param->data_len)
12632 len += (param->data_len*sizeof(uint8_t));
12633
12634 /*
12635 * Data length must be multiples of 16 bytes - checked against 0xF -
12636 * and must be less than WMI_SVC_MSG_SIZE - static size of
12637 * wmi_pdev_fips_cmd structure
12638 */
12639
12640 /* do sanity on the input */
12641 if (!(((param->data_len & 0xF) == 0) &&
12642 ((param->data_len > 0) &&
12643 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12644 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12645 return QDF_STATUS_E_INVAL;
12646 }
12647
12648 buf = wmi_buf_alloc(wmi_handle, len);
12649 if (!buf) {
12650 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12651 return QDF_STATUS_E_FAILURE;
12652 }
12653
12654 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12655 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12656 WMITLV_SET_HDR(&cmd->tlv_header,
12657 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12658 WMITLV_GET_STRUCT_TLVLEN
12659 (wmi_pdev_fips_cmd_fixed_param));
12660
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012661 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12662 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012663 if (param->key != NULL && param->data != NULL) {
12664 cmd->key_len = param->key_len;
12665 cmd->data_len = param->data_len;
12666 cmd->fips_cmd = !!(param->op);
12667
12668 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12669 return QDF_STATUS_E_FAILURE;
12670
12671 qdf_mem_copy(cmd->key, param->key, param->key_len);
12672
12673 if (param->mode == FIPS_ENGINE_AES_CTR ||
12674 param->mode == FIPS_ENGINE_AES_MIC) {
12675 cmd->mode = param->mode;
12676 } else {
12677 cmd->mode = FIPS_ENGINE_AES_CTR;
12678 }
12679 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12680 cmd->key_len, cmd->data_len);
12681
12682 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12683 cmd->key, cmd->key_len, true);
12684 buf_ptr += sizeof(*cmd);
12685
12686 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12687
12688 buf_ptr += WMI_TLV_HDR_SIZE;
12689 if (param->data_len)
12690 qdf_mem_copy(buf_ptr,
12691 (uint8_t *) param->data, param->data_len);
12692
12693 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12694 16, 1, buf_ptr, cmd->data_len, true);
12695
12696 buf_ptr += param->data_len;
12697
12698 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12699 WMI_PDEV_FIPS_CMDID);
12700 qdf_print("%s return value %d\n", __func__, retval);
12701 } else {
12702 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12703 wmi_buf_free(buf);
12704 retval = -QDF_STATUS_E_BADMSG;
12705 }
12706
12707 return retval;
12708}
12709
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012710#ifdef WLAN_PMO_ENABLE
12711/**
12712 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12713 * @wmi_handle: wmi handle
12714 * @vdev_id: vdev id
12715 * @bitmap: Event bitmap
12716 * @enable: enable/disable
12717 *
12718 * Return: CDF status
12719 */
12720static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12721 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012722 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012723 bool enable)
12724{
12725 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12726 uint16_t len;
12727 wmi_buf_t buf;
12728 int ret;
12729
12730 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12731 buf = wmi_buf_alloc(wmi_handle, len);
12732 if (!buf) {
12733 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12734 return QDF_STATUS_E_NOMEM;
12735 }
12736 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12737 WMITLV_SET_HDR(&cmd->tlv_header,
12738 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12739 WMITLV_GET_STRUCT_TLVLEN
12740 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12741 cmd->vdev_id = vdev_id;
12742 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012743 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
12744 WMI_WOW_MAX_EVENT_BM_LEN);
12745
12746 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
12747 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
12748 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012749
12750 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12751 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12752 if (ret) {
12753 WMI_LOGE("Failed to config wow wakeup event");
12754 wmi_buf_free(buf);
12755 return QDF_STATUS_E_FAILURE;
12756 }
12757
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012758 return QDF_STATUS_SUCCESS;
12759}
12760
12761/**
12762 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12763 * @wmi_handle: wmi handle
12764 * @vdev_id: vdev id
12765 * @ptrn_id: pattern id
12766 * @ptrn: pattern
12767 * @ptrn_len: pattern length
12768 * @ptrn_offset: pattern offset
12769 * @mask: mask
12770 * @mask_len: mask length
12771 * @user: true for user configured pattern and false for default pattern
12772 * @default_patterns: default patterns
12773 *
12774 * Return: CDF status
12775 */
12776static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12777 uint8_t vdev_id, uint8_t ptrn_id,
12778 const uint8_t *ptrn, uint8_t ptrn_len,
12779 uint8_t ptrn_offset, const uint8_t *mask,
12780 uint8_t mask_len, bool user,
12781 uint8_t default_patterns)
12782{
12783 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12784 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12785 wmi_buf_t buf;
12786 uint8_t *buf_ptr;
12787 int32_t len;
12788 int ret;
12789
12790 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12791 WMI_TLV_HDR_SIZE +
12792 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12793 WMI_TLV_HDR_SIZE +
12794 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12795 WMI_TLV_HDR_SIZE +
12796 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12797 WMI_TLV_HDR_SIZE +
12798 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12799 WMI_TLV_HDR_SIZE +
12800 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12801
12802 buf = wmi_buf_alloc(wmi_handle, len);
12803 if (!buf) {
12804 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12805 return QDF_STATUS_E_NOMEM;
12806 }
12807
12808 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12809 buf_ptr = (uint8_t *) cmd;
12810
12811 WMITLV_SET_HDR(&cmd->tlv_header,
12812 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12813 WMITLV_GET_STRUCT_TLVLEN
12814 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12815 cmd->vdev_id = vdev_id;
12816 cmd->pattern_id = ptrn_id;
12817
12818 cmd->pattern_type = WOW_BITMAP_PATTERN;
12819 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12820
12821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12822 sizeof(WOW_BITMAP_PATTERN_T));
12823 buf_ptr += WMI_TLV_HDR_SIZE;
12824 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12825
12826 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12827 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12828 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12829
12830 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12831 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12832
12833 bitmap_pattern->pattern_offset = ptrn_offset;
12834 bitmap_pattern->pattern_len = ptrn_len;
12835
12836 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12837 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12838
12839 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12840 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12841
12842 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12843 bitmap_pattern->pattern_id = ptrn_id;
12844
12845 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12846 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12847 bitmap_pattern->pattern_offset, user);
12848 WMI_LOGI("Pattern : ");
12849 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12850 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12851
12852 WMI_LOGI("Mask : ");
12853 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12854 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12855
12856 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12857
12858 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12859 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12860 buf_ptr += WMI_TLV_HDR_SIZE;
12861
12862 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12864 buf_ptr += WMI_TLV_HDR_SIZE;
12865
12866 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12867 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12868 buf_ptr += WMI_TLV_HDR_SIZE;
12869
12870 /* Fill TLV for pattern_info_timeout but no data. */
12871 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12872 buf_ptr += WMI_TLV_HDR_SIZE;
12873
12874 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12875 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12876 buf_ptr += WMI_TLV_HDR_SIZE;
12877 *(A_UINT32 *) buf_ptr = 0;
12878
12879 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12880 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12881 if (ret) {
12882 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12883 wmi_buf_free(buf);
12884 return QDF_STATUS_E_FAILURE;
12885 }
12886
12887 return QDF_STATUS_SUCCESS;
12888}
12889
Govind Singha4836fd2016-03-07 16:45:38 +053012890/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012891 * fill_arp_offload_params_tlv() - Fill ARP offload data
12892 * @wmi_handle: wmi handle
12893 * @offload_req: offload request
12894 * @buf_ptr: buffer pointer
12895 *
12896 * To fill ARP offload data to firmware
12897 * when target goes to wow mode.
12898 *
12899 * Return: None
12900 */
12901static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012902 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012903{
12904
12905 int i;
12906 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012907 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012908
12909 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12910 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12911 *buf_ptr += WMI_TLV_HDR_SIZE;
12912 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12913 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12914 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12915 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12916 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12917
12918 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012919 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012920 /* Copy the target ip addr and flags */
12921 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12922 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012923 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012924 WMI_IPV4_ADDR_LEN);
12925 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012926 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012927 }
12928 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12929 }
12930}
12931
12932#ifdef WLAN_NS_OFFLOAD
12933/**
12934 * fill_ns_offload_params_tlv() - Fill NS offload data
12935 * @wmi|_handle: wmi handle
12936 * @offload_req: offload request
12937 * @buf_ptr: buffer pointer
12938 *
12939 * To fill NS offload data to firmware
12940 * when target goes to wow mode.
12941 *
12942 * Return: None
12943 */
12944static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012945 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012946{
12947
12948 int i;
12949 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012950
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012951 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12952 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12953 *buf_ptr += WMI_TLV_HDR_SIZE;
12954 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12955 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12956 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12957 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12958 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12959
12960 /*
12961 * Fill data only for NS offload in the first ARP tuple for LA
12962 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012963 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012964 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12965 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012966 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012967 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012968 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012969 sizeof(WMI_IPV6_ADDR));
12970 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012971 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012972 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012973 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012974 ns_tuple->flags |=
12975 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12976 }
12977 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012978 i, &ns_req->self_ipv6_addr[i],
12979 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012980
12981 /* target MAC is optional, check if it is valid,
12982 * if this is not valid, the target will use the known
12983 * local MAC address rather than the tuple
12984 */
12985 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012986 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012987 &ns_tuple->target_mac);
12988 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12989 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12990 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12991 }
12992 }
12993 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12994 }
12995}
12996
12997
12998/**
12999 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13000 * @wmi: wmi handle
13001 * @offload_req: offload request
13002 * @buf_ptr: buffer pointer
13003 *
13004 * To fill extended NS offload extended data to firmware
13005 * when target goes to wow mode.
13006 *
13007 * Return: None
13008 */
13009static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013010 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013011{
13012 int i;
13013 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13014 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013015
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013016 count = ns_req->num_ns_offload_count;
13017 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013018 WMI_MAX_NS_OFFLOADS;
13019
13020 /* Populate extended NS offload tuples */
13021 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13022 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13023 *buf_ptr += WMI_TLV_HDR_SIZE;
13024 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13025 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13026 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13027 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13028 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13029
13030 /*
13031 * Fill data only for NS offload in the first ARP tuple for LA
13032 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013033 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013034 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13035 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013036 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013037 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013038 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013039 sizeof(WMI_IPV6_ADDR));
13040 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013041 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013042 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013043 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013044 ns_tuple->flags |=
13045 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13046 }
13047 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013048 i, &ns_req->self_ipv6_addr[i],
13049 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013050
13051 /* target MAC is optional, check if it is valid,
13052 * if this is not valid, the target will use the
13053 * known local MAC address rather than the tuple
13054 */
13055 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013056 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013057 &ns_tuple->target_mac);
13058 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13059 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13060 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13061 }
13062 }
13063 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13064 }
13065}
13066#else
13067static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013068 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013069{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013070}
13071
13072static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013073 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013074{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013075}
13076#endif
13077
13078/**
Govind Singha4836fd2016-03-07 16:45:38 +053013079 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13080 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013081 * @arp_offload_req: arp offload request
13082 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013083 * @arp_only: flag
13084 *
13085 * To configure ARP NS off load data to firmware
13086 * when target goes to wow mode.
13087 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013088 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013089 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013090static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013091 struct pmo_arp_offload_params *arp_offload_req,
13092 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013093 uint8_t vdev_id)
13094{
Govind Singha4836fd2016-03-07 16:45:38 +053013095 int32_t res;
13096 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013097 A_UINT8 *buf_ptr;
13098 wmi_buf_t buf;
13099 int32_t len;
13100 uint32_t count = 0, num_ns_ext_tuples = 0;
13101
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013102 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013103
Govind Singha4836fd2016-03-07 16:45:38 +053013104 /*
13105 * TLV place holder size for array of NS tuples
13106 * TLV place holder size for array of ARP tuples
13107 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013108 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13109 WMI_TLV_HDR_SIZE +
13110 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13111 WMI_TLV_HDR_SIZE +
13112 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013113
13114 /*
13115 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13116 * extra length for extended NS offload tuples which follows ARP offload
13117 * tuples. Host needs to fill this structure in following format:
13118 * 2 NS ofload tuples
13119 * 2 ARP offload tuples
13120 * N numbers of extended NS offload tuples if HDD has given more than
13121 * 2 NS offload addresses
13122 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013123 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013124 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013125 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13126 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013127 }
13128
13129 buf = wmi_buf_alloc(wmi_handle, len);
13130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013131 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013132 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013133 }
13134
13135 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13136 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13137 WMITLV_SET_HDR(&cmd->tlv_header,
13138 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13139 WMITLV_GET_STRUCT_TLVLEN
13140 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13141 cmd->flags = 0;
13142 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013143 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013144
Govind Singhb53420c2016-03-09 14:32:57 +053013145 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013146
Govind Singha4836fd2016-03-07 16:45:38 +053013147 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013148 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13149 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13150 if (num_ns_ext_tuples)
13151 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013152
13153 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13154 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13155 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013156 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013157 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013158 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013159 }
13160
Govind Singhb53420c2016-03-09 14:32:57 +053013161 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013162}
13163
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013164/**
13165 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13166 * @wmi_handle: wmi handle
13167 * @vdev_id: vdev id
13168 * @action: true for enable else false
13169 *
13170 * To enable enhance multicast offload to firmware
13171 * when target goes to wow mode.
13172 *
13173 * Return: QDF Status
13174 */
13175
13176static
13177QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13178 wmi_unified_t wmi_handle,
13179 uint8_t vdev_id, bool action)
13180{
13181 QDF_STATUS status;
13182 wmi_buf_t buf;
13183 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13184
13185 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13186 if (!buf) {
13187 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13188 return QDF_STATUS_E_NOMEM;
13189 }
13190
13191 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13192 wmi_buf_data(buf);
13193
13194 WMITLV_SET_HDR(&cmd->tlv_header,
13195 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13196 WMITLV_GET_STRUCT_TLVLEN(
13197 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13198
13199 cmd->vdev_id = vdev_id;
13200 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13201 ENHANCED_MCAST_FILTER_ENABLED);
13202 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13203 __func__, action, vdev_id);
13204 status = wmi_unified_cmd_send(wmi_handle, buf,
13205 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13206 if (status != QDF_STATUS_SUCCESS) {
13207 qdf_nbuf_free(buf);
13208 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13209 __func__);
13210 }
13211
13212 return status;
13213}
13214
13215/**
13216 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13217 * @wmi_handle: wmi handle
13218 * @param evt_buf: pointer to event buffer
13219 * @param hdr: Pointer to hold header
13220 * @param bufp: Pointer to hold pointer to rx param buffer
13221 *
13222 * Return: QDF_STATUS_SUCCESS for success or error code
13223 */
13224static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13225 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13226{
13227 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13228 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13229
13230 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13231 if (!param_buf) {
13232 WMI_LOGE("gtk param_buf is NULL");
13233 return QDF_STATUS_E_INVAL;
13234 }
13235
13236 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13237 WMI_LOGE("Invalid length for GTK status");
13238 return QDF_STATUS_E_INVAL;
13239 }
13240
13241 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13242 param_buf->fixed_param;
13243 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13244 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13245 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13246 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13247 &fixed_param->replay_counter,
13248 GTK_REPLAY_COUNTER_BYTES);
13249
13250 return QDF_STATUS_SUCCESS;
13251
13252}
13253
13254#ifdef FEATURE_WLAN_RA_FILTERING
13255/**
13256 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13257 * @wmi_handle: wmi handle
13258 * @vdev_id: vdev id
13259 *
13260 * Return: CDF status
13261 */
13262static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13263 uint8_t vdev_id, uint8_t default_pattern,
13264 uint16_t rate_limit_interval)
13265{
13266
13267 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13268 wmi_buf_t buf;
13269 uint8_t *buf_ptr;
13270 int32_t len;
13271 int ret;
13272
13273 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13274 WMI_TLV_HDR_SIZE +
13275 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13276 WMI_TLV_HDR_SIZE +
13277 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13278 WMI_TLV_HDR_SIZE +
13279 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13280 WMI_TLV_HDR_SIZE +
13281 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13282 WMI_TLV_HDR_SIZE +
13283 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13284
13285 buf = wmi_buf_alloc(wmi_handle, len);
13286 if (!buf) {
13287 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13288 return QDF_STATUS_E_NOMEM;
13289 }
13290
13291 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13292 buf_ptr = (uint8_t *) cmd;
13293
13294 WMITLV_SET_HDR(&cmd->tlv_header,
13295 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13296 WMITLV_GET_STRUCT_TLVLEN
13297 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13298 cmd->vdev_id = vdev_id;
13299 cmd->pattern_id = default_pattern,
13300 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13301 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13302
13303 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13304 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13305 buf_ptr += WMI_TLV_HDR_SIZE;
13306
13307 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13308 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13309 buf_ptr += WMI_TLV_HDR_SIZE;
13310
13311 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13313 buf_ptr += WMI_TLV_HDR_SIZE;
13314
13315 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13316 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13317 buf_ptr += WMI_TLV_HDR_SIZE;
13318
13319 /* Fill TLV for pattern_info_timeout but no data. */
13320 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13321 buf_ptr += WMI_TLV_HDR_SIZE;
13322
13323 /* Fill TLV for ra_ratelimit_interval. */
13324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13325 buf_ptr += WMI_TLV_HDR_SIZE;
13326
13327 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13328
13329 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13330 rate_limit_interval, vdev_id);
13331
13332 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13333 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13334 if (ret) {
13335 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13336 wmi_buf_free(buf);
13337 return QDF_STATUS_E_FAILURE;
13338 }
13339
13340 return QDF_STATUS_SUCCESS;
13341
13342}
13343#endif /* FEATURE_WLAN_RA_FILTERING */
13344
13345/**
13346 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13347 * @wmi_handle: wmi handle
13348 * @vdev_id: vdev id
13349 * @multicastAddr: mcast address
13350 * @clearList: clear list flag
13351 *
13352 * Return: QDF_STATUS_SUCCESS for success or error code
13353 */
13354static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13355 uint8_t vdev_id,
13356 struct qdf_mac_addr multicast_addr,
13357 bool clearList)
13358{
13359 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13360 wmi_buf_t buf;
13361 int err;
13362
13363 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13364 if (!buf) {
13365 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13366 return QDF_STATUS_E_NOMEM;
13367 }
13368
13369 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13370 qdf_mem_zero(cmd, sizeof(*cmd));
13371
13372 WMITLV_SET_HDR(&cmd->tlv_header,
13373 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13374 WMITLV_GET_STRUCT_TLVLEN
13375 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13376 cmd->action =
13377 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13378 cmd->vdev_id = vdev_id;
13379 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13380
13381 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13382 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13383
13384 err = wmi_unified_cmd_send(wmi_handle, buf,
13385 sizeof(*cmd),
13386 WMI_SET_MCASTBCAST_FILTER_CMDID);
13387 if (err) {
13388 WMI_LOGE("Failed to send set_param cmd");
13389 wmi_buf_free(buf);
13390 return QDF_STATUS_E_FAILURE;
13391 }
13392
13393 return QDF_STATUS_SUCCESS;
13394}
13395
13396/**
13397 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13398 * @wmi_handle: wmi handle
13399 * @vdev_id: vdev id
13400 * @params: GTK offload parameters
13401 *
13402 * Return: CDF status
13403 */
13404static
13405QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13406 struct pmo_gtk_req *params,
13407 bool enable_offload,
13408 uint32_t gtk_offload_opcode)
13409{
13410 int len;
13411 wmi_buf_t buf;
13412 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13413 QDF_STATUS status = QDF_STATUS_SUCCESS;
13414
13415 WMI_LOGD("%s Enter", __func__);
13416
13417 len = sizeof(*cmd);
13418
13419 /* alloc wmi buffer */
13420 buf = wmi_buf_alloc(wmi_handle, len);
13421 if (!buf) {
13422 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13423 status = QDF_STATUS_E_NOMEM;
13424 goto out;
13425 }
13426
13427 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13428 WMITLV_SET_HDR(&cmd->tlv_header,
13429 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13430 WMITLV_GET_STRUCT_TLVLEN
13431 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13432
13433 cmd->vdev_id = vdev_id;
13434
13435 /* Request target to enable GTK offload */
13436 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13437 cmd->flags = gtk_offload_opcode;
13438
13439 /* Copy the keys and replay counter */
13440 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13441 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13442 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13443 GTK_REPLAY_COUNTER_BYTES);
13444 } else {
13445 cmd->flags = gtk_offload_opcode;
13446 }
13447
13448 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13449
13450 /* send the wmi command */
13451 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13452 WMI_GTK_OFFLOAD_CMDID)) {
13453 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13454 wmi_buf_free(buf);
13455 status = QDF_STATUS_E_FAILURE;
13456 }
13457
13458out:
13459 WMI_LOGD("%s Exit", __func__);
13460 return status;
13461}
13462
13463/**
13464 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13465 * @wmi_handle: wmi handle
13466 * @params: GTK offload params
13467 *
13468 * Return: CDF status
13469 */
13470static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13471 wmi_unified_t wmi_handle,
13472 uint8_t vdev_id,
13473 uint64_t offload_req_opcode)
13474{
13475 int len;
13476 wmi_buf_t buf;
13477 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13478 QDF_STATUS status = QDF_STATUS_SUCCESS;
13479
13480 len = sizeof(*cmd);
13481
13482 /* alloc wmi buffer */
13483 buf = wmi_buf_alloc(wmi_handle, len);
13484 if (!buf) {
13485 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13486 status = QDF_STATUS_E_NOMEM;
13487 goto out;
13488 }
13489
13490 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13491 WMITLV_SET_HDR(&cmd->tlv_header,
13492 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13493 WMITLV_GET_STRUCT_TLVLEN
13494 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13495
13496 /* Request for GTK offload status */
13497 cmd->flags = offload_req_opcode;
13498 cmd->vdev_id = vdev_id;
13499
13500 /* send the wmi command */
13501 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13502 WMI_GTK_OFFLOAD_CMDID)) {
13503 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13504 wmi_buf_free(buf);
13505 status = QDF_STATUS_E_FAILURE;
13506 }
13507
13508out:
13509 return status;
13510}
13511
13512/**
13513 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13514 * @wmi_handle: wmi handler
13515 * @action_params: pointer to action_params
13516 *
13517 * Return: 0 for success, otherwise appropriate error code
13518 */
13519static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13520 struct pmo_action_wakeup_set_params *action_params)
13521{
13522 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13523 wmi_buf_t buf;
13524 int i;
13525 int32_t err;
13526
13527 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13528 if (!buf) {
13529 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13530 return QDF_STATUS_E_NOMEM;
13531 }
13532 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13533 WMITLV_SET_HDR(&cmd->tlv_header,
13534 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13535 WMITLV_GET_STRUCT_TLVLEN(
13536 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13537
13538 cmd->vdev_id = action_params->vdev_id;
13539 cmd->operation = action_params->operation;
13540
13541 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13542 cmd->action_category_map[i] =
13543 action_params->action_category_map[i];
13544
13545 err = wmi_unified_cmd_send(wmi_handle, buf,
13546 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13547 if (err) {
13548 WMI_LOGE("Failed to send ap_ps_egap cmd");
13549 wmi_buf_free(buf);
13550 return QDF_STATUS_E_FAILURE;
13551 }
13552
13553 return QDF_STATUS_SUCCESS;
13554}
13555
13556#ifdef FEATURE_WLAN_LPHB
13557
13558/**
13559 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13560 * @wmi_handle: wmi handle
13561 * @lphb_conf_req: configuration info
13562 *
13563 * Return: CDF status
13564 */
13565static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13566 wmi_hb_set_enable_cmd_fixed_param *params)
13567{
13568 QDF_STATUS status;
13569 wmi_buf_t buf = NULL;
13570 uint8_t *buf_ptr;
13571 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13572 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13573
13574
13575 buf = wmi_buf_alloc(wmi_handle, len);
13576 if (!buf) {
13577 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13578 return QDF_STATUS_E_NOMEM;
13579 }
13580
13581 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13582 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13583 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13584 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13585 WMITLV_GET_STRUCT_TLVLEN
13586 (wmi_hb_set_enable_cmd_fixed_param));
13587
13588 /* fill in values */
13589 hb_enable_fp->vdev_id = params->session;
13590 hb_enable_fp->enable = params->enable;
13591 hb_enable_fp->item = params->item;
13592 hb_enable_fp->session = params->session;
13593
13594 status = wmi_unified_cmd_send(wmi_handle, buf,
13595 len, WMI_HB_SET_ENABLE_CMDID);
13596 if (QDF_IS_STATUS_ERROR(status)) {
13597 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13598 status);
13599 wmi_buf_free(buf);
13600 }
13601
13602 return status;
13603}
13604
13605/**
13606 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13607 * @wmi_handle: wmi handle
13608 * @lphb_conf_req: lphb config request
13609 *
13610 * Return: CDF status
13611 */
13612static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13613 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13614{
13615 QDF_STATUS status;
13616 wmi_buf_t buf = NULL;
13617 uint8_t *buf_ptr;
13618 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13619 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13620
13621 buf = wmi_buf_alloc(wmi_handle, len);
13622 if (!buf) {
13623 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13624 return QDF_STATUS_E_NOMEM;
13625 }
13626
13627 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13628 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13629 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13630 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13631 WMITLV_GET_STRUCT_TLVLEN
13632 (wmi_hb_set_tcp_params_cmd_fixed_param));
13633
13634 /* fill in values */
13635 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13636 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13637 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13638 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13639 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13640 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13641 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13642 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13643 hb_tcp_params_fp->session = lphb_conf_req->session;
13644 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13645 &lphb_conf_req->gateway_mac,
13646 sizeof(hb_tcp_params_fp->gateway_mac));
13647
13648 status = wmi_unified_cmd_send(wmi_handle, buf,
13649 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13650 if (QDF_IS_STATUS_ERROR(status)) {
13651 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13652 status);
13653 wmi_buf_free(buf);
13654 }
13655
13656 return status;
13657}
13658
13659/**
13660 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13661 * @wmi_handle: wmi handle
13662 * @lphb_conf_req: lphb config request
13663 *
13664 * Return: CDF status
13665 */
13666static
13667QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13668 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13669{
13670 QDF_STATUS status;
13671 wmi_buf_t buf = NULL;
13672 uint8_t *buf_ptr;
13673 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13674 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13675
13676 buf = wmi_buf_alloc(wmi_handle, len);
13677 if (!buf) {
13678 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13679 return QDF_STATUS_E_NOMEM;
13680 }
13681
13682 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13683 hb_tcp_filter_fp =
13684 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13685 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13686 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13687 WMITLV_GET_STRUCT_TLVLEN
13688 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13689
13690 /* fill in values */
13691 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13692 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13693 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13694 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13695 memcpy((void *)&hb_tcp_filter_fp->filter,
13696 (void *)&g_hb_tcp_filter_fp->filter,
13697 WMI_WLAN_HB_MAX_FILTER_SIZE);
13698
13699 status = wmi_unified_cmd_send(wmi_handle, buf,
13700 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13701 if (QDF_IS_STATUS_ERROR(status)) {
13702 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13703 status);
13704 wmi_buf_free(buf);
13705 }
13706
13707 return status;
13708}
13709
13710/**
13711 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13712 * @wmi_handle: wmi handle
13713 * @lphb_conf_req: lphb config request
13714 *
13715 * Return: CDF status
13716 */
13717static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13718 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13719{
13720 QDF_STATUS status;
13721 wmi_buf_t buf = NULL;
13722 uint8_t *buf_ptr;
13723 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13724 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13725
13726 buf = wmi_buf_alloc(wmi_handle, len);
13727 if (!buf) {
13728 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13729 return QDF_STATUS_E_NOMEM;
13730 }
13731
13732 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13733 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13734 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13735 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13736 WMITLV_GET_STRUCT_TLVLEN
13737 (wmi_hb_set_udp_params_cmd_fixed_param));
13738
13739 /* fill in values */
13740 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13741 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13742 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13743 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13744 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13745 hb_udp_params_fp->interval = lphb_conf_req->interval;
13746 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13747 hb_udp_params_fp->session = lphb_conf_req->session;
13748 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13749 &lphb_conf_req->gateway_mac,
13750 sizeof(lphb_conf_req->gateway_mac));
13751
13752 status = wmi_unified_cmd_send(wmi_handle, buf,
13753 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13754 if (QDF_IS_STATUS_ERROR(status)) {
13755 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13756 status);
13757 wmi_buf_free(buf);
13758 }
13759
13760 return status;
13761}
13762
13763/**
13764 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13765 * @wmi_handle: wmi handle
13766 * @lphb_conf_req: lphb config request
13767 *
13768 * Return: CDF status
13769 */
13770static
13771QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13772 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13773{
13774 QDF_STATUS status;
13775 wmi_buf_t buf = NULL;
13776 uint8_t *buf_ptr;
13777 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13778 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13779
13780 buf = wmi_buf_alloc(wmi_handle, len);
13781 if (!buf) {
13782 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13783 return QDF_STATUS_E_NOMEM;
13784 }
13785
13786 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13787 hb_udp_filter_fp =
13788 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13789 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13790 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13791 WMITLV_GET_STRUCT_TLVLEN
13792 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13793
13794 /* fill in values */
13795 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13796 hb_udp_filter_fp->length = lphb_conf_req->length;
13797 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13798 hb_udp_filter_fp->session = lphb_conf_req->session;
13799 memcpy((void *)&hb_udp_filter_fp->filter,
13800 (void *)&lphb_conf_req->filter,
13801 WMI_WLAN_HB_MAX_FILTER_SIZE);
13802
13803 status = wmi_unified_cmd_send(wmi_handle, buf,
13804 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13805 if (QDF_IS_STATUS_ERROR(status)) {
13806 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13807 status);
13808 wmi_buf_free(buf);
13809 }
13810
13811 return status;
13812}
13813#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013814
Dustin Brownf31f88b2017-05-12 14:01:44 -070013815static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
13816 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013817{
Dustin Brownf31f88b2017-05-12 14:01:44 -070013818 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013819 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070013820 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013821
Dustin Brownf31f88b2017-05-12 14:01:44 -070013822 if (!req) {
13823 WMI_LOGE("req is null");
13824 return QDF_STATUS_E_INVAL;
13825 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013826
Dustin Brownf31f88b2017-05-12 14:01:44 -070013827 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
13828 if (!wmi_buf) {
13829 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013830 return QDF_STATUS_E_NOMEM;
13831 }
13832
Dustin Brownf31f88b2017-05-12 14:01:44 -070013833 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013834 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070013835 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13836 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
13837 cmd->vdev_id = req->vdev_id;
13838 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
13839 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013840
Dustin Brownf31f88b2017-05-12 14:01:44 -070013841 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
13842 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013843
Dustin Brownf31f88b2017-05-12 14:01:44 -070013844 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
13845 WMI_HW_DATA_FILTER_CMDID);
13846 if (QDF_IS_STATUS_ERROR(status)) {
13847 WMI_LOGE("Failed to configure hw filter");
13848 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013849 }
13850
Dustin Brownf31f88b2017-05-12 14:01:44 -070013851 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013852}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053013853
13854/**
13855 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
13856 * @wmi_handle: wmi handle
13857 * @vdev_id: vdev id
13858 * @enable: Flag to enable/disable packet filter
13859 *
13860 * Return: QDF_STATUS_SUCCESS for success or error code
13861 */
13862static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
13863 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
13864{
13865 int32_t len;
13866 int ret = 0;
13867 wmi_buf_t buf;
13868 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
13869
13870 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
13871
13872 buf = wmi_buf_alloc(wmi_handle, len);
13873 if (!buf) {
13874 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13875 return QDF_STATUS_E_NOMEM;
13876 }
13877
13878 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
13879 WMITLV_SET_HDR(&cmd->tlv_header,
13880 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
13881 WMITLV_GET_STRUCT_TLVLEN(
13882 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
13883
13884 cmd->vdev_id = vdev_id;
13885 if (enable)
13886 cmd->enable = PACKET_FILTER_SET_ENABLE;
13887 else
13888 cmd->enable = PACKET_FILTER_SET_DISABLE;
13889
13890 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
13891 __func__, cmd->enable, vdev_id);
13892
13893 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13894 WMI_PACKET_FILTER_ENABLE_CMDID);
13895 if (ret) {
13896 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
13897 wmi_buf_free(buf);
13898 }
13899
13900 return ret;
13901}
13902
13903/**
13904 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
13905 * @wmi_handle: wmi handle
13906 * @vdev_id: vdev id
13907 * @rcv_filter_param: Packet filter parameters
13908 * @filter_id: Filter id
13909 * @enable: Flag to add/delete packet filter configuration
13910 *
13911 * Return: QDF_STATUS_SUCCESS for success or error code
13912 */
13913static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
13914 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
13915 uint8_t filter_id, bool enable)
13916{
13917 int len, i;
13918 int err = 0;
13919 wmi_buf_t buf;
13920 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
13921
13922
13923 /* allocate the memory */
13924 len = sizeof(*cmd);
13925 buf = wmi_buf_alloc(wmi_handle, len);
13926 if (!buf) {
13927 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13928 return QDF_STATUS_E_NOMEM;
13929 }
13930
13931 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13932 WMITLV_SET_HDR(&cmd->tlv_header,
13933 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
13934 WMITLV_GET_STRUCT_TLVLEN
13935 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
13936
13937 cmd->vdev_id = vdev_id;
13938 cmd->filter_id = filter_id;
13939 if (enable)
13940 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
13941 else
13942 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
13943
13944 if (enable) {
13945 cmd->num_params = QDF_MIN(
13946 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
13947 rcv_filter_param->num_params);
13948 cmd->filter_type = rcv_filter_param->filter_type;
13949 cmd->coalesce_time = rcv_filter_param->coalesce_time;
13950
13951 for (i = 0; i < cmd->num_params; i++) {
13952 cmd->paramsData[i].proto_type =
13953 rcv_filter_param->params_data[i].protocol_layer;
13954 cmd->paramsData[i].cmp_type =
13955 rcv_filter_param->params_data[i].compare_flag;
13956 cmd->paramsData[i].data_length =
13957 rcv_filter_param->params_data[i].data_length;
13958 cmd->paramsData[i].data_offset =
13959 rcv_filter_param->params_data[i].data_offset;
13960 memcpy(&cmd->paramsData[i].compareData,
13961 rcv_filter_param->params_data[i].compare_data,
13962 sizeof(cmd->paramsData[i].compareData));
13963 memcpy(&cmd->paramsData[i].dataMask,
13964 rcv_filter_param->params_data[i].data_mask,
13965 sizeof(cmd->paramsData[i].dataMask));
13966 }
13967 }
13968
13969 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
13970 cmd->filter_action, cmd->filter_id, cmd->num_params);
13971 /* send the command along with data */
13972 err = wmi_unified_cmd_send(wmi_handle, buf, len,
13973 WMI_PACKET_FILTER_CONFIG_CMDID);
13974 if (err) {
13975 WMI_LOGE("Failed to send pkt_filter cmd");
13976 wmi_buf_free(buf);
13977 return QDF_STATUS_E_FAILURE;
13978 }
13979
13980 return QDF_STATUS_SUCCESS;
13981}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053013982#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013983
Govind Singha4836fd2016-03-07 16:45:38 +053013984/**
13985 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13986 * @wmi_handle: wmi handle
13987 * @request: SSID hotlist set request
13988 *
Govind Singhb53420c2016-03-09 14:32:57 +053013989 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013990 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013991static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013992send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13993 struct ssid_hotlist_request_params *request)
13994{
13995 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13996 wmi_buf_t wmi_buf;
13997 uint32_t len;
13998 uint32_t array_size;
13999 uint8_t *buf_ptr;
14000
14001 /* length of fixed portion */
14002 len = sizeof(*cmd);
14003
14004 /* length of variable portion */
14005 array_size =
14006 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14007 len += WMI_TLV_HDR_SIZE + array_size;
14008
14009 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14010 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014011 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14012 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014013 }
14014
14015 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14016 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14017 buf_ptr;
14018 WMITLV_SET_HDR
14019 (&cmd->tlv_header,
14020 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14021 WMITLV_GET_STRUCT_TLVLEN
14022 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14023
14024 cmd->request_id = request->request_id;
14025 cmd->requestor_id = 0;
14026 cmd->vdev_id = request->session_id;
14027 cmd->table_id = 0;
14028 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14029 cmd->total_entries = request->ssid_count;
14030 cmd->num_entries_in_page = request->ssid_count;
14031 cmd->first_entry_index = 0;
14032
14033 buf_ptr += sizeof(*cmd);
14034 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14035
14036 if (request->ssid_count) {
14037 wmi_extscan_hotlist_ssid_entry *entry;
14038 int i;
14039
14040 buf_ptr += WMI_TLV_HDR_SIZE;
14041 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14042 for (i = 0; i < request->ssid_count; i++) {
14043 WMITLV_SET_HDR
14044 (entry,
14045 WMITLV_TAG_ARRAY_STRUC,
14046 WMITLV_GET_STRUCT_TLVLEN
14047 (wmi_extscan_hotlist_ssid_entry));
14048 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014049 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014050 request->ssids[i].ssid.mac_ssid,
14051 request->ssids[i].ssid.length);
14052 entry->band = request->ssids[i].band;
14053 entry->min_rssi = request->ssids[i].rssi_low;
14054 entry->max_rssi = request->ssids[i].rssi_high;
14055 entry++;
14056 }
14057 cmd->mode = WMI_EXTSCAN_MODE_START;
14058 } else {
14059 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14060 }
14061
14062 if (wmi_unified_cmd_send
14063 (wmi_handle, wmi_buf, len,
14064 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014065 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014066 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014067 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014068 }
14069
Govind Singhb53420c2016-03-09 14:32:57 +053014070 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014071}
14072
14073/**
14074 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14075 * @wmi_handle: wmi handle
14076 * @vdev_id: vdev id
14077 *
14078 * This function sends roam synch complete event to fw.
14079 *
14080 * Return: CDF STATUS
14081 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014082static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014083 uint8_t vdev_id)
14084{
14085 wmi_roam_synch_complete_fixed_param *cmd;
14086 wmi_buf_t wmi_buf;
14087 uint8_t *buf_ptr;
14088 uint16_t len;
14089 len = sizeof(wmi_roam_synch_complete_fixed_param);
14090
14091 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14092 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014093 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14094 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014095 }
14096 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14097 buf_ptr = (uint8_t *) cmd;
14098 WMITLV_SET_HDR(&cmd->tlv_header,
14099 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14100 WMITLV_GET_STRUCT_TLVLEN
14101 (wmi_roam_synch_complete_fixed_param));
14102 cmd->vdev_id = vdev_id;
14103 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14104 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014105 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014106 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014107 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014108 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014109 }
14110
Govind Singhb53420c2016-03-09 14:32:57 +053014111 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014112}
14113
14114/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014115 * send_fw_test_cmd_tlv() - send fw test command to fw.
14116 * @wmi_handle: wmi handle
14117 * @wmi_fwtest: fw test command
14118 *
14119 * This function sends fw test command to fw.
14120 *
14121 * Return: CDF STATUS
14122 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014123static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014124QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14125 struct set_fwtest_params *wmi_fwtest)
14126{
14127 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14128 wmi_buf_t wmi_buf;
14129 uint16_t len;
14130
14131 len = sizeof(*cmd);
14132
14133 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14134 if (!wmi_buf) {
14135 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14136 return QDF_STATUS_E_NOMEM;
14137 }
14138
14139 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14140 WMITLV_SET_HDR(&cmd->tlv_header,
14141 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14142 WMITLV_GET_STRUCT_TLVLEN(
14143 wmi_fwtest_set_param_cmd_fixed_param));
14144 cmd->param_id = wmi_fwtest->arg;
14145 cmd->param_value = wmi_fwtest->value;
14146
14147 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14148 WMI_FWTEST_CMDID)) {
14149 WMI_LOGP("%s: failed to send fw test command", __func__);
14150 qdf_nbuf_free(wmi_buf);
14151 return QDF_STATUS_E_FAILURE;
14152 }
14153
14154 return QDF_STATUS_SUCCESS;
14155}
14156
14157/**
Govind Singha4836fd2016-03-07 16:45:38 +053014158 * send_unit_test_cmd_tlv() - send unit test command to fw.
14159 * @wmi_handle: wmi handle
14160 * @wmi_utest: unit test command
14161 *
14162 * This function send unit test command to fw.
14163 *
14164 * Return: CDF STATUS
14165 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014166static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014167 struct wmi_unit_test_cmd *wmi_utest)
14168{
14169 wmi_unit_test_cmd_fixed_param *cmd;
14170 wmi_buf_t wmi_buf;
14171 uint8_t *buf_ptr;
14172 int i;
14173 uint16_t len, args_tlv_len;
14174 A_UINT32 *unit_test_cmd_args;
14175
14176 args_tlv_len =
14177 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14178 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14179
14180 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14181 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014182 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14183 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014184 }
14185
14186 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14187 buf_ptr = (uint8_t *) cmd;
14188 WMITLV_SET_HDR(&cmd->tlv_header,
14189 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14190 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14191 cmd->vdev_id = wmi_utest->vdev_id;
14192 cmd->module_id = wmi_utest->module_id;
14193 cmd->num_args = wmi_utest->num_args;
14194 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14195 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14196 (wmi_utest->num_args * sizeof(uint32_t)));
14197 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014198 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014199 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14200 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014201 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014202 }
14203 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14204 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014205 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014206 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014207 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014208 }
14209
Govind Singhb53420c2016-03-09 14:32:57 +053014210 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014211}
14212
14213/**
14214 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14215 * @wmi_handle: wma handle
14216 * @roaminvoke: roam invoke command
14217 *
14218 * Send roam invoke command to fw for fastreassoc.
14219 *
14220 * Return: CDF STATUS
14221 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014222static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014223 struct wmi_roam_invoke_cmd *roaminvoke,
14224 uint32_t ch_hz)
14225{
14226 wmi_roam_invoke_cmd_fixed_param *cmd;
14227 wmi_buf_t wmi_buf;
14228 u_int8_t *buf_ptr;
14229 u_int16_t len, args_tlv_len;
14230 A_UINT32 *channel_list;
14231 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014232 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014233
14234 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014235 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14236 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14237 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014238 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14239 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14240 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014241 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14242 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014243 }
14244
14245 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14246 buf_ptr = (u_int8_t *) cmd;
14247 WMITLV_SET_HDR(&cmd->tlv_header,
14248 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14249 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14250 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014251 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014252
14253 if (roaminvoke->frame_len)
14254 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
14255 else
14256 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
14257
Govind Singha4836fd2016-03-07 16:45:38 +053014258 cmd->roam_ap_sel_mode = 0;
14259 cmd->roam_delay = 0;
14260 cmd->num_chan = 1;
14261 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014262 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14263 cmd->num_buf = 1;
14264
Govind Singha4836fd2016-03-07 16:45:38 +053014265 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14266 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14267 (sizeof(u_int32_t)));
14268 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14269 *channel_list = ch_hz;
14270 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14271 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14272 (sizeof(wmi_mac_addr)));
14273 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14274 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014275
14276 /* move to next tlv i.e. bcn_prb_buf_list */
14277 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14278
14279 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14280 sizeof(wmi_tlv_buf_len_param));
14281
14282 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14283 buf_len_tlv->buf_len = roaminvoke->frame_len;
14284
14285 /* move to next tlv i.e. bcn_prb_frm */
14286 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14288 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14289
14290 /* copy frame after the header */
14291 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14292 roaminvoke->frame_buf,
14293 roaminvoke->frame_len);
14294
14295 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14296 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14297 buf_ptr + WMI_TLV_HDR_SIZE,
14298 roaminvoke->frame_len);
Varun Reddy Yeturu1ad240c2017-03-21 10:44:28 -070014299 WMI_LOGD(FL("flags:%d, scan_mode:%d"), cmd->flags, cmd->roam_scan_mode);
Naveen Rawat77797922017-01-20 17:00:07 -080014300
Govind Singha4836fd2016-03-07 16:45:38 +053014301 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14302 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014303 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014304 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014305 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014306 }
14307
Govind Singhb53420c2016-03-09 14:32:57 +053014308 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014309}
14310
14311/**
14312 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14313 * @wmi_handle: wmi handle
14314 * @command: command
14315 * @vdev_id: vdev id
14316 *
14317 * This function set roam offload command to fw.
14318 *
14319 * Return: CDF status
14320 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014321static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014322 uint32_t command, uint32_t vdev_id)
14323{
Govind Singh67922e82016-04-01 16:48:57 +053014324 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014325 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14326 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014327 int len;
14328 uint8_t *buf_ptr;
14329
14330 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14331 buf = wmi_buf_alloc(wmi_handle, len);
14332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014333 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14334 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014335 }
14336
14337 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14338
14339 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14340 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14341 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14342 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14343 cmd_fp->vdev_id = vdev_id;
14344 cmd_fp->command_arg = command;
14345
14346 status = wmi_unified_cmd_send(wmi_handle, buf,
14347 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014348 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014349 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014350 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014351 goto error;
14352 }
14353
Govind Singhb53420c2016-03-09 14:32:57 +053014354 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14355 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014356
14357error:
14358 wmi_buf_free(buf);
14359
Govind Singh67922e82016-04-01 16:48:57 +053014360 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014361}
14362
14363/**
14364 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14365 * @wmi_handle: wmi handle
14366 * @ap_profile_p: ap profile
14367 * @vdev_id: vdev id
14368 *
14369 * Send WMI_ROAM_AP_PROFILE to firmware
14370 *
14371 * Return: CDF status
14372 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014373static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014374 wmi_ap_profile *ap_profile_p,
14375 uint32_t vdev_id)
14376{
Govind Singha4836fd2016-03-07 16:45:38 +053014377 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014378 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014379 int len;
14380 uint8_t *buf_ptr;
14381 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14382
14383 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14384
14385 buf = wmi_buf_alloc(wmi_handle, len);
14386 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014387 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14388 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014389 }
14390
14391 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14392 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14393 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14394 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14395 WMITLV_GET_STRUCT_TLVLEN
14396 (wmi_roam_ap_profile_fixed_param));
14397 /* fill in threshold values */
14398 roam_ap_profile_fp->vdev_id = vdev_id;
14399 roam_ap_profile_fp->id = 0;
14400 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14401
Govind Singhb53420c2016-03-09 14:32:57 +053014402 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014403 WMITLV_SET_HDR(buf_ptr,
14404 WMITLV_TAG_STRUC_wmi_ap_profile,
14405 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14406 status = wmi_unified_cmd_send(wmi_handle, buf,
14407 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014408 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014409 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014410 status);
Govind Singh67922e82016-04-01 16:48:57 +053014411 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014412 }
14413
Govind Singhb53420c2016-03-09 14:32:57 +053014414 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014415
Govind Singh67922e82016-04-01 16:48:57 +053014416 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014417}
14418
14419/**
14420 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14421 * @wmi_handle: wmi handle
14422 * @scan_period: scan period
14423 * @scan_age: scan age
14424 * @vdev_id: vdev id
14425 *
14426 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14427 *
14428 * Return: CDF status
14429 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014430static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014431 uint32_t scan_period,
14432 uint32_t scan_age,
14433 uint32_t vdev_id)
14434{
Govind Singh67922e82016-04-01 16:48:57 +053014435 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014436 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014437 int len;
14438 uint8_t *buf_ptr;
14439 wmi_roam_scan_period_fixed_param *scan_period_fp;
14440
14441 /* Send scan period values */
14442 len = sizeof(wmi_roam_scan_period_fixed_param);
14443 buf = wmi_buf_alloc(wmi_handle, len);
14444 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014445 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14446 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014447 }
14448
14449 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14450 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14451 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14452 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14453 WMITLV_GET_STRUCT_TLVLEN
14454 (wmi_roam_scan_period_fixed_param));
14455 /* fill in scan period values */
14456 scan_period_fp->vdev_id = vdev_id;
14457 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14458 scan_period_fp->roam_scan_age = scan_age;
14459
14460 status = wmi_unified_cmd_send(wmi_handle, buf,
14461 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014462 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014463 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014464 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014465 goto error;
14466 }
14467
Govind Singhb53420c2016-03-09 14:32:57 +053014468 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014469 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014470 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014471error:
14472 wmi_buf_free(buf);
14473
Govind Singh67922e82016-04-01 16:48:57 +053014474 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014475}
14476
14477/**
14478 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14479 * @wmi_handle: wmi handle
14480 * @chan_count: channel count
14481 * @chan_list: channel list
14482 * @list_type: list type
14483 * @vdev_id: vdev id
14484 *
14485 * Set roam offload channel list.
14486 *
14487 * Return: CDF status
14488 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014489static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014490 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014491 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014492 uint8_t list_type, uint32_t vdev_id)
14493{
Govind Singha4836fd2016-03-07 16:45:38 +053014494 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014495 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014496 int len, list_tlv_len;
14497 int i;
14498 uint8_t *buf_ptr;
14499 wmi_roam_chan_list_fixed_param *chan_list_fp;
14500 A_UINT32 *roam_chan_list_array;
14501
14502 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014503 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014504 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014505 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014506 }
14507 /* Channel list is a table of 2 TLV's */
14508 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14509 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14510 buf = wmi_buf_alloc(wmi_handle, len);
14511 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014512 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14513 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014514 }
14515
14516 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14517 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14518 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14519 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14520 WMITLV_GET_STRUCT_TLVLEN
14521 (wmi_roam_chan_list_fixed_param));
14522 chan_list_fp->vdev_id = vdev_id;
14523 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014524 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014525 /* external app is controlling channel list */
14526 chan_list_fp->chan_list_type =
14527 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14528 } else {
14529 /* umac supplied occupied channel list in LFR */
14530 chan_list_fp->chan_list_type =
14531 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14532 }
14533
14534 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14536 (chan_list_fp->num_chan * sizeof(uint32_t)));
14537 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014538 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014539 for (i = 0; ((i < chan_list_fp->num_chan) &&
14540 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14541 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014542 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014543 }
14544
14545 status = wmi_unified_cmd_send(wmi_handle, buf,
14546 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014547 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014548 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014549 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014550 goto error;
14551 }
14552
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014553 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014554 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014555error:
14556 wmi_buf_free(buf);
14557
Govind Singh67922e82016-04-01 16:48:57 +053014558 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014559}
14560
14561/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014562 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14563 * @wmi_handle: wmi handle
14564 * @req_buf: per roam config buffer
14565 *
14566 * Return: QDF status
14567 */
14568static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14569 struct wmi_per_roam_config_req *req_buf)
14570{
14571 wmi_buf_t buf = NULL;
14572 QDF_STATUS status;
14573 int len;
14574 uint8_t *buf_ptr;
14575 wmi_roam_per_config_fixed_param *wmi_per_config;
14576
14577 len = sizeof(wmi_roam_per_config_fixed_param);
14578 buf = wmi_buf_alloc(wmi_handle, len);
14579 if (!buf) {
14580 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14581 return QDF_STATUS_E_NOMEM;
14582 }
14583
14584 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14585 wmi_per_config =
14586 (wmi_roam_per_config_fixed_param *) buf_ptr;
14587 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14588 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14589 WMITLV_GET_STRUCT_TLVLEN
14590 (wmi_roam_per_config_fixed_param));
14591
14592 /* fill in per roam config values */
14593 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014594
14595 wmi_per_config->enable = req_buf->per_config.enable;
14596 wmi_per_config->high_rate_thresh =
14597 (req_buf->per_config.tx_high_rate_thresh << 16) |
14598 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14599 wmi_per_config->low_rate_thresh =
14600 (req_buf->per_config.tx_low_rate_thresh << 16) |
14601 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14602 wmi_per_config->pkt_err_rate_thresh_pct =
14603 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14604 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14605 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014606 wmi_per_config->pkt_err_rate_mon_time =
14607 (req_buf->per_config.tx_per_mon_time << 16) |
14608 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014609 wmi_per_config->min_candidate_rssi =
14610 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014611
14612 /* Send per roam config parameters */
14613 status = wmi_unified_cmd_send(wmi_handle, buf,
14614 len, WMI_ROAM_PER_CONFIG_CMDID);
14615 if (QDF_IS_STATUS_ERROR(status)) {
14616 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14617 status);
14618 wmi_buf_free(buf);
14619 return status;
14620 }
14621
14622 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14623 req_buf->per_config.enable, req_buf->vdev_id);
14624 return QDF_STATUS_SUCCESS;
14625}
14626
14627/**
Govind Singha4836fd2016-03-07 16:45:38 +053014628 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14629 * @wmi_handle: wmi handle
14630 * @rssi_change_thresh: RSSI Change threshold
14631 * @bcn_rssi_weight: beacon RSSI weight
14632 * @vdev_id: vdev id
14633 *
14634 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14635 *
14636 * Return: CDF status
14637 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014638static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014639 uint32_t vdev_id,
14640 int32_t rssi_change_thresh,
14641 uint32_t bcn_rssi_weight,
14642 uint32_t hirssi_delay_btw_scans)
14643{
Govind Singha4836fd2016-03-07 16:45:38 +053014644 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014645 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014646 int len;
14647 uint8_t *buf_ptr;
14648 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14649
14650 /* Send rssi change parameters */
14651 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14652 buf = wmi_buf_alloc(wmi_handle, len);
14653 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014654 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14655 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014656 }
14657
14658 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14659 rssi_change_fp =
14660 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14661 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14662 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14663 WMITLV_GET_STRUCT_TLVLEN
14664 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14665 /* fill in rssi change threshold (hysteresis) values */
14666 rssi_change_fp->vdev_id = vdev_id;
14667 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14668 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14669 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14670
14671 status = wmi_unified_cmd_send(wmi_handle, buf,
14672 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014673 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014674 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014675 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014676 goto error;
14677 }
14678
Govind Singhb53420c2016-03-09 14:32:57 +053014679 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014680 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014681 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14682 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014683error:
14684 wmi_buf_free(buf);
14685
Govind Singh67922e82016-04-01 16:48:57 +053014686 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014687}
14688
14689/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14690 * @wmi_handle: wmi handle.
14691 * @cmd: size of command structure.
14692 * @per_entry_size: per entry size.
14693 *
14694 * This utility function calculates how many hotlist entries can
14695 * fit in one page.
14696 *
14697 * Return: number of entries
14698 */
14699static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14700 size_t cmd_size,
14701 size_t per_entry_size)
14702{
14703 uint32_t avail_space = 0;
14704 int num_entries = 0;
14705 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14706
14707 /* Calculate number of hotlist entries that can
14708 * be passed in wma message request.
14709 */
14710 avail_space = max_msg_len - cmd_size;
14711 num_entries = avail_space / per_entry_size;
14712 return num_entries;
14713}
14714
14715/**
14716 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14717 * @wmi_handle: wmi handle
14718 * @photlist: hotlist command params
14719 * @buf_len: buffer length
14720 *
14721 * This function fills individual elements for hotlist request and
14722 * TLV for bssid entries
14723 *
14724 * Return: CDF Status.
14725 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014726static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014727 struct ext_scan_setbssi_hotlist_params *
14728 photlist, int *buf_len)
14729{
14730 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14731 wmi_extscan_hotlist_entry *dest_hotlist;
14732 struct ap_threshold_params *src_ap = photlist->ap;
14733 wmi_buf_t buf;
14734 uint8_t *buf_ptr;
14735
14736 int j, index = 0;
14737 int cmd_len = 0;
14738 int num_entries;
14739 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014740 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014741 int len = sizeof(*cmd);
14742
14743 len += WMI_TLV_HDR_SIZE;
14744 cmd_len = len;
14745
14746 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14747 cmd_len,
14748 sizeof(*dest_hotlist));
14749 /* setbssid hotlist expects the bssid list
14750 * to be non zero value
14751 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014752 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014753 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014754 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014755 }
14756
14757 /* Split the hot list entry pages and send multiple command
14758 * requests if the buffer reaches the maximum request size
14759 */
14760 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014761 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014762 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14763 buf = wmi_buf_alloc(wmi_handle, len);
14764 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014765 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14766 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014767 }
14768 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14769 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14770 buf_ptr;
14771 WMITLV_SET_HDR(&cmd->tlv_header,
14772 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14773 WMITLV_GET_STRUCT_TLVLEN
14774 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14775
14776 /* Multiple requests are sent until the num_entries_in_page
14777 * matches the total_entries
14778 */
14779 cmd->request_id = photlist->requestId;
14780 cmd->vdev_id = photlist->sessionId;
14781 cmd->total_entries = numap;
14782 cmd->mode = 1;
14783 cmd->num_entries_in_page = min_entries;
14784 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14785 cmd->first_entry_index = index;
14786
Govind Singhb53420c2016-03-09 14:32:57 +053014787 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014788 __func__, cmd->vdev_id, cmd->total_entries,
14789 cmd->num_entries_in_page,
14790 cmd->lost_ap_scan_count);
14791
14792 buf_ptr += sizeof(*cmd);
14793 WMITLV_SET_HDR(buf_ptr,
14794 WMITLV_TAG_ARRAY_STRUC,
14795 min_entries * sizeof(wmi_extscan_hotlist_entry));
14796 dest_hotlist = (wmi_extscan_hotlist_entry *)
14797 (buf_ptr + WMI_TLV_HDR_SIZE);
14798
14799 /* Populate bssid, channel info and rssi
14800 * for the bssid's that are sent as hotlists.
14801 */
14802 for (j = 0; j < min_entries; j++) {
14803 WMITLV_SET_HDR(dest_hotlist,
14804 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14805 WMITLV_GET_STRUCT_TLVLEN
14806 (wmi_extscan_hotlist_entry));
14807
14808 dest_hotlist->min_rssi = src_ap->low;
14809 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14810 &dest_hotlist->bssid);
14811
Govind Singhb53420c2016-03-09 14:32:57 +053014812 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014813 __func__, dest_hotlist->channel,
14814 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014815 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014816 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14817 __func__, dest_hotlist->bssid.mac_addr31to0,
14818 dest_hotlist->bssid.mac_addr47to32);
14819 dest_hotlist++;
14820 src_ap++;
14821 }
14822 buf_ptr += WMI_TLV_HDR_SIZE +
14823 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14824
14825 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14826 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014827 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014828 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014829 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014830 }
14831 index = index + min_entries;
14832 num_entries = numap - min_entries;
14833 len = cmd_len;
14834 }
Govind Singhb53420c2016-03-09 14:32:57 +053014835 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014836}
14837
Govind Singhbca3b1b2016-05-02 17:59:24 +053014838/**
Dustin Brown4423f632017-01-13 15:24:07 -080014839 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14840 * @wmi_handle: the WMI handle
14841 * @vdev_id: the Id of the vdev to apply the configuration to
14842 * @ucast_mode: the active BPF mode to configure for unicast packets
14843 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14844 * packets
14845 *
14846 * Return: QDF status
14847 */
14848static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14849 uint8_t vdev_id,
14850 enum wmi_host_active_bpf_mode ucast_mode,
14851 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14852{
14853 const WMITLV_TAG_ID tag_id =
14854 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14855 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14856 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14857 QDF_STATUS status;
14858 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14859 wmi_buf_t buf;
14860
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014861 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080014862 vdev_id, ucast_mode, mcast_bcast_mode);
14863
14864 /* allocate command buffer */
14865 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14866 if (!buf) {
14867 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14868 return QDF_STATUS_E_NOMEM;
14869 }
14870
14871 /* set TLV header */
14872 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14873 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14874
14875 /* populate data */
14876 cmd->vdev_id = vdev_id;
14877 cmd->uc_mode = ucast_mode;
14878 cmd->mcbc_mode = mcast_bcast_mode;
14879
14880 /* send to FW */
14881 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14882 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14883 if (QDF_IS_STATUS_ERROR(status)) {
14884 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14885 status);
14886 wmi_buf_free(buf);
14887 return status;
14888 }
14889
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014890 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080014891
14892 return QDF_STATUS_SUCCESS;
14893}
14894
14895/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014896 * send_power_dbg_cmd_tlv() - send power debug commands
14897 * @wmi_handle: wmi handle
14898 * @param: wmi power debug parameter
14899 *
14900 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14901 *
14902 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14903 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014904static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14905 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014906{
14907 wmi_buf_t buf = NULL;
14908 QDF_STATUS status;
14909 int len, args_tlv_len;
14910 uint8_t *buf_ptr;
14911 uint8_t i;
14912 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14913 uint32_t *cmd_args;
14914
14915 /* Prepare and send power debug cmd parameters */
14916 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14917 len = sizeof(*cmd) + args_tlv_len;
14918 buf = wmi_buf_alloc(wmi_handle, len);
14919 if (!buf) {
14920 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14921 return QDF_STATUS_E_NOMEM;
14922 }
14923
14924 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14925 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14926 WMITLV_SET_HDR(&cmd->tlv_header,
14927 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14928 WMITLV_GET_STRUCT_TLVLEN
14929 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14930
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014931 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14932 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053014933 cmd->module_id = param->module_id;
14934 cmd->num_args = param->num_args;
14935 buf_ptr += sizeof(*cmd);
14936 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14937 (param->num_args * sizeof(uint32_t)));
14938 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14939 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14940 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14941 cmd_args[i] = param->args[i];
14942 WMI_LOGI("%d,", param->args[i]);
14943 }
14944
14945 status = wmi_unified_cmd_send(wmi_handle, buf,
14946 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14947 if (QDF_IS_STATUS_ERROR(status)) {
14948 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14949 status);
14950 goto error;
14951 }
14952
14953 return QDF_STATUS_SUCCESS;
14954error:
14955 wmi_buf_free(buf);
14956
14957 return status;
14958}
14959
Kiran Venkatappa26117052016-12-23 19:58:54 +053014960/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014961 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014962 * @buf_ptr: pointer to current position in init command buffer
14963 * @len: pointer to length. This will be updated with current lenght of cmd
14964 * @param: point host parameters for init command
14965 *
14966 * Return: Updated pointer of buf_ptr.
14967 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014968static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
14969 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053014970{
14971 uint16_t idx;
14972
14973 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14974 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14975 wmi_pdev_band_to_mac *band_to_mac;
14976
14977 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14978 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14979 sizeof(wmi_resource_config) +
14980 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14981 sizeof(wlan_host_memory_chunk)));
14982
14983 WMITLV_SET_HDR(&hw_mode->tlv_header,
14984 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14985 (WMITLV_GET_STRUCT_TLVLEN
14986 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14987
14988 hw_mode->hw_mode_index = param->hw_mode_id;
14989 hw_mode->num_band_to_mac = param->num_band_to_mac;
14990
14991 buf_ptr = (uint8_t *) (hw_mode + 1);
14992 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14993 WMI_TLV_HDR_SIZE);
14994 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14995 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14996 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14997 WMITLV_GET_STRUCT_TLVLEN
14998 (wmi_pdev_band_to_mac));
14999 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015000 wmi_handle->ops->convert_pdev_id_host_to_target(
15001 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015002 band_to_mac[idx].start_freq =
15003 param->band_to_mac[idx].start_freq;
15004 band_to_mac[idx].end_freq =
15005 param->band_to_mac[idx].end_freq;
15006 }
15007 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15008 (param->num_band_to_mac *
15009 sizeof(wmi_pdev_band_to_mac)) +
15010 WMI_TLV_HDR_SIZE;
15011
15012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
15013 (param->num_band_to_mac *
15014 sizeof(wmi_pdev_band_to_mac)));
15015 }
15016
15017 return buf_ptr;
15018}
15019
Govind Singhe7f2f342016-05-23 12:12:52 +053015020/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015021 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15022 * @wmi_handle: wmi handle
15023 * @param: wmi multiple vdev restart req param
15024 *
15025 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15026 *
15027 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15028 */
15029static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15030 wmi_unified_t wmi_handle,
15031 struct multiple_vdev_restart_params *param)
15032{
15033 wmi_buf_t buf;
15034 QDF_STATUS qdf_status;
15035 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15036 int i;
15037 uint8_t *buf_ptr;
15038 uint32_t *vdev_ids;
15039 wmi_channel *chan_info;
15040 struct channel_param *tchan_info;
15041 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15042
15043 len += sizeof(wmi_channel);
15044 if (param->num_vdevs)
15045 len += sizeof(uint32_t) * param->num_vdevs;
15046
15047 buf = wmi_buf_alloc(wmi_handle, len);
15048 if (!buf) {
15049 WMI_LOGE("Failed to allocate memory\n");
15050 qdf_status = QDF_STATUS_E_NOMEM;
15051 goto end;
15052 }
15053
15054 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15055 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15056 buf_ptr;
15057
15058 WMITLV_SET_HDR(&cmd->tlv_header,
15059 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15060 WMITLV_GET_STRUCT_TLVLEN
15061 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015062 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15063 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015064 cmd->requestor_id = param->requestor_id;
15065 cmd->disable_hw_ack = param->disable_hw_ack;
15066 cmd->cac_duration_ms = param->cac_duration_ms;
15067 cmd->num_vdevs = param->num_vdevs;
15068
15069 buf_ptr += sizeof(*cmd);
15070
15071 WMITLV_SET_HDR(buf_ptr,
15072 WMITLV_TAG_ARRAY_UINT32,
15073 sizeof(A_UINT32) * param->num_vdevs);
15074 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15075 for (i = 0; i < param->num_vdevs; i++) {
15076 vdev_ids[i] = param->vdev_ids[i];
15077 }
15078
15079 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
15080
15081 WMITLV_SET_HDR(buf_ptr,
15082 WMITLV_TAG_STRUC_wmi_channel,
15083 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015084 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015085 tchan_info = &(param->ch_param);
15086 chan_info->mhz = tchan_info->mhz;
15087 chan_info->band_center_freq1 = tchan_info->cfreq1;
15088 chan_info->band_center_freq2 = tchan_info->cfreq2;
15089 if (tchan_info->is_chan_passive)
15090 WMI_SET_CHANNEL_FLAG(chan_info,
15091 WMI_CHAN_FLAG_PASSIVE);
15092 if (tchan_info->allow_vht)
15093 WMI_SET_CHANNEL_FLAG(chan_info,
15094 WMI_CHAN_FLAG_ALLOW_VHT);
15095 else if (tchan_info->allow_ht)
15096 WMI_SET_CHANNEL_FLAG(chan_info,
15097 WMI_CHAN_FLAG_ALLOW_HT);
15098 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15099 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15100 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15101 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15102 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15103 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
15104
15105 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15106 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15107
15108 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15109 WMI_LOGE("%s: Failed to send\n", __func__);
15110 wmi_buf_free(buf);
15111 }
15112
15113end:
15114 return qdf_status;
15115}
15116
15117/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015118 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15119 * @wmi_handle: wmi handle
15120 * @pdev_id: pdev id
15121 *
15122 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15123 *
15124 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15125 */
15126static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15127 uint32_t pdev_id)
15128{
15129 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15130 wmi_buf_t buf;
15131 uint16_t len;
15132 QDF_STATUS ret;
15133
15134 len = sizeof(*cmd);
15135 buf = wmi_buf_alloc(wmi_handle, len);
15136
15137 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15138
15139 if (!buf) {
15140 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15141 return QDF_STATUS_E_NOMEM;
15142 }
15143
15144 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15145 wmi_buf_data(buf);
15146
15147 WMITLV_SET_HDR(&cmd->tlv_header,
15148 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15149 WMITLV_GET_STRUCT_TLVLEN(
15150 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15151
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015152 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15154 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15155 if (QDF_IS_STATUS_ERROR(ret)) {
15156 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15157 __func__, ret, pdev_id);
15158 wmi_buf_free(buf);
15159 return QDF_STATUS_E_FAILURE;
15160 }
15161
15162 return QDF_STATUS_SUCCESS;
15163}
15164
15165/**
15166 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15167 * @wmi_handle: wmi handle
15168 * @pdev_id: pdev id
15169 *
15170 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15171 *
15172 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15173 */
15174static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15175 uint32_t pdev_id)
15176{
15177 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15178 wmi_buf_t buf;
15179 uint16_t len;
15180 QDF_STATUS ret;
15181
15182 len = sizeof(*cmd);
15183 buf = wmi_buf_alloc(wmi_handle, len);
15184
15185 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15186
15187 if (!buf) {
15188 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15189 return QDF_STATUS_E_NOMEM;
15190 }
15191
15192 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15193 wmi_buf_data(buf);
15194
15195 WMITLV_SET_HDR(&cmd->tlv_header,
15196 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15197 WMITLV_GET_STRUCT_TLVLEN(
15198 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15199
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015200 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015201 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15202 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15203 if (QDF_IS_STATUS_ERROR(ret)) {
15204 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15205 __func__, ret, pdev_id);
15206 wmi_buf_free(buf);
15207 return QDF_STATUS_E_FAILURE;
15208 }
15209
15210 return QDF_STATUS_SUCCESS;
15211}
15212
15213/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015214 * init_cmd_send_tlv() - send initialization cmd to fw
15215 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015216 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015217 *
15218 * Return: QDF_STATUS_SUCCESS for success or error code
15219 */
15220static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015221 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015222{
15223 wmi_buf_t buf;
15224 wmi_init_cmd_fixed_param *cmd;
15225 wmi_abi_version my_vers;
15226 int num_whitelist;
15227 uint8_t *buf_ptr;
15228 wmi_resource_config *resource_cfg;
15229 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015230 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015231 uint16_t idx;
15232 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015233 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015234
Kiran Venkatappa26117052016-12-23 19:58:54 +053015235 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15236 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015237 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015238
15239 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15240 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15241 WMI_TLV_HDR_SIZE +
15242 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15243
15244 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015245 if (!buf) {
15246 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15247 return QDF_STATUS_E_FAILURE;
15248 }
15249
15250 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15251 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15252 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15253
15254 host_mem_chunks = (wlan_host_memory_chunk *)
15255 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15256 + WMI_TLV_HDR_SIZE);
15257
15258 WMITLV_SET_HDR(&cmd->tlv_header,
15259 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15260 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15261
Kiran Venkatappa26117052016-12-23 19:58:54 +053015262 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015263 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15264 WMITLV_TAG_STRUC_wmi_resource_config,
15265 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15266
Kiran Venkatappa26117052016-12-23 19:58:54 +053015267 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015268 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15269 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15270 WMITLV_GET_STRUCT_TLVLEN
15271 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015272 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15273 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15274 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015275 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15276 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015277 idx, host_mem_chunks[idx].size,
15278 host_mem_chunks[idx].ptr);
15279 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015280 cmd->num_host_mem_chunks = param->num_mem_chunks;
15281 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15282
Govind Singhe7f2f342016-05-23 12:12:52 +053015283 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15284 WMITLV_TAG_ARRAY_STRUC,
15285 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015286 param->num_mem_chunks));
15287
15288 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015289 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015290
15291 num_whitelist = sizeof(version_whitelist) /
15292 sizeof(wmi_whitelist_version_info);
15293 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15294 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15295 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15296 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15297 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15298 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15299
Govind Singh87542482016-06-08 19:40:11 +053015300#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015301 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15302 &my_vers,
15303 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15304 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015305#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015306 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15307 __func__,
15308 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15309 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15310 cmd->host_abi_vers.abi_version_ns_0,
15311 cmd->host_abi_vers.abi_version_ns_1,
15312 cmd->host_abi_vers.abi_version_ns_2,
15313 cmd->host_abi_vers.abi_version_ns_3);
15314
15315 /* Save version sent from host -
15316 * Will be used to check ready event
15317 */
Govind Singh87542482016-06-08 19:40:11 +053015318#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015319 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15320 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015321#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015322 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15323 if (QDF_IS_STATUS_ERROR(ret)) {
15324 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15325 ret);
15326 wmi_buf_free(buf);
15327 }
15328 return ret;
15329
Govind Singhe7f2f342016-05-23 12:12:52 +053015330}
15331
15332/**
15333 * save_service_bitmap_tlv() - save service bitmap
15334 * @wmi_handle: wmi handle
15335 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015336 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015337 *
15338 * Return: None
15339 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015340#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015341static
Rajeev Kumar77901472017-02-12 02:12:17 -080015342void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15343 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015344{
15345 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15346 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15347
15348 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15349 param_buf->wmi_service_bitmap,
15350 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015351
15352 if (bitmap_buf)
15353 qdf_mem_copy(bitmap_buf,
15354 param_buf->wmi_service_bitmap,
15355 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015356}
15357#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015358static
Rajeev Kumar77901472017-02-12 02:12:17 -080015359void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15360 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015361{
Rajeev Kumar77901472017-02-12 02:12:17 -080015362 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15363 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015364
Rajeev Kumar77901472017-02-12 02:12:17 -080015365 if (bitmap_buf)
15366 qdf_mem_copy(bitmap_buf,
15367 param_buf->wmi_service_bitmap,
15368 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15369}
Govind Singhe7f2f342016-05-23 12:12:52 +053015370#endif
15371
15372/**
15373 * is_service_enabled_tlv() - Check if service enabled
15374 * @param wmi_handle: wmi handle
15375 * @param service_id: service identifier
15376 *
15377 * Return: 1 enabled, 0 disabled
15378 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015379#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015380static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15381 uint32_t service_id)
15382{
15383 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15384 service_id);
15385}
15386#else
15387static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15388 uint32_t service_id)
15389{
15390 return false;
15391}
15392#endif
15393
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015394static inline void copy_ht_cap_info(uint32_t ev_target_cap,
15395 struct wlan_psoc_target_capability_info *cap)
15396{
15397 /* except LDPC all flags are common betwen legacy and here
15398 * also IBFEER is not defined for TLV
15399 */
15400 cap->ht_cap_info |= ev_target_cap & (
15401 WMI_HT_CAP_ENABLED
15402 | WMI_HT_CAP_HT20_SGI
15403 | WMI_HT_CAP_DYNAMIC_SMPS
15404 | WMI_HT_CAP_TX_STBC
15405 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
15406 | WMI_HT_CAP_RX_STBC
15407 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
15408 | WMI_HT_CAP_LDPC
15409 | WMI_HT_CAP_L_SIG_TXOP_PROT
15410 | WMI_HT_CAP_MPDU_DENSITY
15411 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
15412 | WMI_HT_CAP_HT40_SGI);
15413 if (ev_target_cap & WMI_HT_CAP_LDPC)
15414 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
15415 WMI_HOST_HT_CAP_TX_LDPC;
15416}
Govind Singhe7f2f342016-05-23 12:12:52 +053015417/**
15418 * extract_service_ready_tlv() - extract service ready event
15419 * @wmi_handle: wmi handle
15420 * @param evt_buf: pointer to received event buffer
15421 * @param cap: pointer to hold target capability information extracted from even
15422 *
15423 * Return: QDF_STATUS_SUCCESS for success or error code
15424 */
15425static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015426 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015427{
15428 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15429 wmi_service_ready_event_fixed_param *ev;
15430
15431
15432 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15433
15434 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15435 if (!ev) {
15436 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15437 return QDF_STATUS_E_FAILURE;
15438 }
15439
15440 cap->phy_capability = ev->phy_capability;
15441 cap->max_frag_entry = ev->max_frag_entry;
15442 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015443 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053015444 cap->vht_cap_info = ev->vht_cap_info;
15445 cap->vht_supp_mcs = ev->vht_supp_mcs;
15446 cap->hw_min_tx_power = ev->hw_min_tx_power;
15447 cap->hw_max_tx_power = ev->hw_max_tx_power;
15448 cap->sys_cap_info = ev->sys_cap_info;
15449 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15450 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15451 cap->max_num_scan_channels = ev->max_num_scan_channels;
15452 cap->max_supported_macs = ev->max_supported_macs;
15453 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15454 cap->txrx_chainmask = ev->txrx_chainmask;
15455 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15456 cap->num_msdu_desc = ev->num_msdu_desc;
15457
15458 return QDF_STATUS_SUCCESS;
15459}
15460
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015461/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15462 * to host internal WMI_HOST_REGDMN_MODE values.
15463 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15464 * host currently. Add this in the future if required.
15465 * 11AX (Phase II) : 11ax related values are not currently
15466 * advertised separately by FW. As part of phase II regulatory bring-up,
15467 * finalize the advertisement mechanism.
15468 * @target_wireless_mode: target wireless mode received in message
15469 *
15470 * Return: returns the host internal wireless mode.
15471 */
15472static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15473{
15474
15475 uint32_t wireless_modes = 0;
15476
15477 if (target_wireless_mode & REGDMN_MODE_11A)
15478 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15479
15480 if (target_wireless_mode & REGDMN_MODE_TURBO)
15481 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15482
15483 if (target_wireless_mode & REGDMN_MODE_11B)
15484 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15485
15486 if (target_wireless_mode & REGDMN_MODE_PUREG)
15487 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15488
15489 if (target_wireless_mode & REGDMN_MODE_11G)
15490 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15491
15492 if (target_wireless_mode & REGDMN_MODE_108G)
15493 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15494
15495 if (target_wireless_mode & REGDMN_MODE_108A)
15496 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15497
15498 if (target_wireless_mode & REGDMN_MODE_XR)
15499 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15500
15501 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15502 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15503
15504 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15505 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15506
15507 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15508 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15509
15510 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15511 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15512
15513 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15514 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15515
15516 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15517 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15518
15519 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15520 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15521
15522 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15523 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15524
15525 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15526 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15527
15528 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15529 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15530
15531 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15532 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15533
15534 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15535 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15536
15537 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15538 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15539
15540 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15541 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15542
15543 return wireless_modes;
15544}
15545
Govind Singhe7f2f342016-05-23 12:12:52 +053015546/**
15547 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15548 * @wmi_handle: wmi handle
15549 * @param evt_buf: Pointer to event buffer
15550 * @param cap: pointer to hold HAL reg capabilities
15551 *
15552 * Return: QDF_STATUS_SUCCESS for success or error code
15553 */
15554static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015555 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015556{
15557 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15558
15559 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15560
15561 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15562 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015563 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015564
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015565 cap->wireless_modes = convert_wireless_modes_tlv(
15566 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015567
Govind Singhe7f2f342016-05-23 12:12:52 +053015568 return QDF_STATUS_SUCCESS;
15569}
15570
15571/**
15572 * extract_host_mem_req_tlv() - Extract host memory request event
15573 * @wmi_handle: wmi handle
15574 * @param evt_buf: pointer to event buffer
15575 * @param num_entries: pointer to hold number of entries requested
15576 *
15577 * Return: Number of entries requested
15578 */
15579static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15580 void *evt_buf, uint8_t *num_entries)
15581{
15582 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15583 wmi_service_ready_event_fixed_param *ev;
15584
15585 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15586
15587 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15588 if (!ev) {
15589 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15590 return NULL;
15591 }
15592
15593 *num_entries = ev->num_mem_reqs;
15594
15595 return (host_mem_req *)param_buf->mem_reqs;
15596}
15597
15598/**
15599 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15600 * ready function
15601 * @wmi_handle: wmi handle
15602 * @param evt_buf: pointer to event buffer
15603 *
15604 * Return: QDF_STATUS_SUCCESS for success or error code
15605 */
15606static QDF_STATUS
15607save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15608{
15609 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15610 wmi_service_ready_event_fixed_param *ev;
15611
15612
15613 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15614
15615 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15616 if (!ev) {
15617 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15618 return QDF_STATUS_E_FAILURE;
15619 }
15620
Govind Singh87542482016-06-08 19:40:11 +053015621#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015622 /*Save fw version from service ready message */
15623 /*This will be used while sending INIT message */
15624 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15625 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015626#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015627 return QDF_STATUS_SUCCESS;
15628}
15629
15630/**
15631 * ready_extract_init_status_tlv() - Extract init status from ready event
15632 * @wmi_handle: wmi handle
15633 * @param evt_buf: Pointer to event buffer
15634 *
15635 * Return: ready status
15636 */
15637static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15638 void *evt_buf)
15639{
15640 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15641 wmi_ready_event_fixed_param *ev = NULL;
15642
15643
15644 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15645 ev = param_buf->fixed_param;
15646
15647 qdf_print("%s:%d\n", __func__, ev->status);
15648
15649 return ev->status;
15650}
15651
15652/**
15653 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15654 * @wmi_handle: wmi handle
15655 * @param evt_buf: pointer to event buffer
15656 * @param macaddr: Pointer to hold MAC address
15657 *
15658 * Return: QDF_STATUS_SUCCESS for success or error code
15659 */
15660static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15661 void *evt_buf, uint8_t *macaddr)
15662{
15663 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15664 wmi_ready_event_fixed_param *ev = NULL;
15665
15666
15667 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15668 ev = param_buf->fixed_param;
15669
15670 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15671
15672 return QDF_STATUS_SUCCESS;
15673}
15674
15675/**
15676 * extract_dbglog_data_len_tlv() - extract debuglog data length
15677 * @wmi_handle: wmi handle
15678 * @param evt_buf: pointer to event buffer
15679 *
15680 * Return: length
15681 */
15682static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015683 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015684{
15685 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15686
15687 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15688
15689 *len = param_buf->num_bufp;
15690
15691 return param_buf->bufp;
15692}
15693
15694/**
15695 * extract_vdev_start_resp_tlv() - extract vdev start response
15696 * @wmi_handle: wmi handle
15697 * @param evt_buf: pointer to event buffer
15698 * @param vdev_rsp: Pointer to hold vdev response
15699 *
15700 * Return: QDF_STATUS_SUCCESS for success or error code
15701 */
15702static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15703 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15704{
15705 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15706 wmi_vdev_start_response_event_fixed_param *ev;
15707
15708 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15709 if (!param_buf) {
15710 qdf_print("Invalid start response event buffer\n");
15711 return QDF_STATUS_E_INVAL;
15712 }
15713
15714 ev = param_buf->fixed_param;
15715 if (!ev) {
15716 qdf_print("Invalid start response event buffer\n");
15717 return QDF_STATUS_E_INVAL;
15718 }
15719
15720 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15721
15722 vdev_rsp->vdev_id = ev->vdev_id;
15723 vdev_rsp->requestor_id = ev->requestor_id;
15724 vdev_rsp->resp_type = ev->resp_type;
15725 vdev_rsp->status = ev->status;
15726 vdev_rsp->chain_mask = ev->chain_mask;
15727 vdev_rsp->smps_mode = ev->smps_mode;
15728 vdev_rsp->mac_id = ev->mac_id;
15729 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15730 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15731
15732 return QDF_STATUS_SUCCESS;
15733}
15734
15735/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015736 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053015737 * @wmi_handle: wmi handle
15738 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015739 * @param num_vdevs: Pointer to hold num vdev
15740 *
15741 * Return: QDF_STATUS_SUCCESS for success or error code
15742 */
15743static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15744 void *evt_buf, uint32_t *num_vdevs)
15745{
15746 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15747 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15748 uint32_t vdev_map;
15749
15750 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
15751 if (!param_buf) {
15752 qdf_print("Invalid tbtt update ext event buffer\n");
15753 return QDF_STATUS_E_INVAL;
15754 }
15755 tbtt_offset_event = param_buf->fixed_param;
15756 vdev_map = tbtt_offset_event->vdev_map;
15757 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
15758
15759 return QDF_STATUS_SUCCESS;
15760}
15761
15762/**
15763 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
15764 * @wmi_handle: wmi handle
15765 * @param evt_buf: pointer to event buffer
15766 * @param num_vdevs: Pointer to hold num vdev
15767 *
15768 * Return: QDF_STATUS_SUCCESS for success or error code
15769 */
15770static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15771 void *evt_buf, uint32_t *num_vdevs)
15772{
15773 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15774 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
15775
15776 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15777 if (!param_buf) {
15778 qdf_print("Invalid tbtt update ext event buffer\n");
15779 return QDF_STATUS_E_INVAL;
15780 }
15781 tbtt_offset_ext_event = param_buf->fixed_param;
15782
15783 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
15784
15785 return QDF_STATUS_SUCCESS;
15786}
15787
15788/**
15789 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
15790 * @wmi_handle: wmi handle
15791 * @param evt_buf: pointer to event buffer
15792 * @param idx: Index refering to a vdev
15793 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053015794 *
15795 * Return: QDF_STATUS_SUCCESS for success or error code
15796 */
15797static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015798 void *evt_buf, uint8_t idx,
15799 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015800{
15801 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15802 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015803 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053015804
15805 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15806 if (!param_buf) {
15807 qdf_print("Invalid tbtt update event buffer\n");
15808 return QDF_STATUS_E_INVAL;
15809 }
Govind Singhe7f2f342016-05-23 12:12:52 +053015810
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015811 tbtt_offset_event = param_buf->fixed_param;
15812 vdev_map = tbtt_offset_event->vdev_map;
15813 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
15814 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
15815 return QDF_STATUS_E_INVAL;
15816 tbtt_param->tbttoffset =
15817 param_buf->tbttoffset_list[tbtt_param->vdev_id];
15818
15819 return QDF_STATUS_SUCCESS;
15820}
15821
15822/**
15823 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
15824 * @wmi_handle: wmi handle
15825 * @param evt_buf: pointer to event buffer
15826 * @param idx: Index refering to a vdev
15827 * @param tbtt_param: Pointer to tbttoffset event param
15828 *
15829 * Return: QDF_STATUS_SUCCESS for success or error code
15830 */
15831static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
15832 void *evt_buf, uint8_t idx,
15833 struct tbttoffset_params *tbtt_param)
15834{
15835 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15836 wmi_tbtt_offset_info *tbtt_offset_info;
15837
15838 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15839 if (!param_buf) {
15840 qdf_print("Invalid tbtt update event buffer\n");
15841 return QDF_STATUS_E_INVAL;
15842 }
15843 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
15844
15845 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
15846 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053015847
15848 return QDF_STATUS_SUCCESS;
15849}
15850
15851/**
15852 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15853 * @wmi_handle: wmi handle
15854 * @param evt_buf: pointer to event buffer
15855 * @param hdr: Pointer to hold header
15856 * @param bufp: Pointer to hold pointer to rx param buffer
15857 *
15858 * Return: QDF_STATUS_SUCCESS for success or error code
15859 */
15860static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015861 void *evt_buf, struct mgmt_rx_event_params *hdr,
15862 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015863{
15864 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15865 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15866
15867 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15868 if (!param_tlvs) {
15869 WMI_LOGE("Get NULL point message from FW");
15870 return QDF_STATUS_E_INVAL;
15871 }
15872
15873 ev_hdr = param_tlvs->hdr;
15874 if (!hdr) {
15875 WMI_LOGE("Rx event is NULL");
15876 return QDF_STATUS_E_INVAL;
15877 }
15878
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015879 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15880 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015881
15882 hdr->channel = ev_hdr->channel;
15883 hdr->snr = ev_hdr->snr;
15884 hdr->rate = ev_hdr->rate;
15885 hdr->phy_mode = ev_hdr->phy_mode;
15886 hdr->buf_len = ev_hdr->buf_len;
15887 hdr->status = ev_hdr->status;
15888 hdr->flags = ev_hdr->flags;
15889 hdr->rssi = ev_hdr->rssi;
15890 hdr->tsf_delta = ev_hdr->tsf_delta;
15891 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15892
15893 *bufp = param_tlvs->bufp;
15894
15895 return QDF_STATUS_SUCCESS;
15896}
15897
15898/**
15899 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15900 * @wmi_handle: wmi handle
15901 * @param evt_buf: pointer to event buffer
15902 * @param vdev_id: Pointer to hold vdev identifier
15903 *
15904 * Return: QDF_STATUS_SUCCESS for success or error code
15905 */
15906static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15907 void *evt_buf, uint32_t *vdev_id)
15908{
15909 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15910 wmi_vdev_stopped_event_fixed_param *resp_event;
15911
15912 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15913 if (!param_buf) {
15914 WMI_LOGE("Invalid event buffer");
15915 return QDF_STATUS_E_INVAL;
15916 }
15917 resp_event = param_buf->fixed_param;
15918 *vdev_id = resp_event->vdev_id;
15919
15920 return QDF_STATUS_SUCCESS;
15921}
15922
15923/**
15924 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15925 * @wmi_handle: wmi handle
15926 * @param evt_buf: pointer to event buffer
15927 * @param param: Pointer to hold roam param
15928 *
15929 * Return: QDF_STATUS_SUCCESS for success or error code
15930 */
15931static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15932 void *evt_buf, wmi_host_roam_event *param)
15933{
15934 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15935 wmi_roam_event_fixed_param *evt;
15936
15937 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15938 if (!param_buf) {
15939 WMI_LOGE("Invalid roam event buffer");
15940 return QDF_STATUS_E_INVAL;
15941 }
15942
15943 evt = param_buf->fixed_param;
15944 qdf_mem_zero(param, sizeof(*param));
15945
15946 param->vdev_id = evt->vdev_id;
15947 param->reason = evt->reason;
15948 param->rssi = evt->rssi;
15949
15950 return QDF_STATUS_SUCCESS;
15951}
15952
15953/**
15954 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15955 * @wmi_handle: wmi handle
15956 * @param evt_buf: pointer to event buffer
15957 * @param param: Pointer to hold vdev scan param
15958 *
15959 * Return: QDF_STATUS_SUCCESS for success or error code
15960 */
15961static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015962 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015963{
15964 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15965 wmi_scan_event_fixed_param *evt = NULL;
15966
15967 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15968 evt = param_buf->fixed_param;
15969
15970 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015971
Govind Singhe7f2f342016-05-23 12:12:52 +053015972 switch (evt->event) {
15973 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015974 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015975 break;
15976 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015977 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015978 break;
15979 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015980 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015981 break;
15982 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015983 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015984 break;
15985 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015986 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015987 break;
15988 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015989 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015990 break;
15991 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015992 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015993 break;
15994 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015995 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015996 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053015997 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015998 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015999 break;
16000 case WMI_SCAN_EVENT_MAX:
16001 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016002 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016003 break;
16004 };
16005
16006 switch (evt->reason) {
16007 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016008 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016009 break;
16010 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016011 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016012 break;
16013 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016014 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016015 break;
16016 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016017 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016018 break;
16019 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016020 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016021 break;
16022 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016023 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016024 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016025 case WMI_SCAN_REASON_SUSPENDED:
16026 param->reason = SCAN_REASON_SUSPENDED;
16027 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016028 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016029 param->reason = SCAN_REASON_MAX;
16030 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016031 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016032 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016033 break;
16034 };
16035
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016036 param->chan_freq = evt->channel_freq;
16037 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053016038 param->scan_id = evt->scan_id;
16039 param->vdev_id = evt->vdev_id;
16040
16041 return QDF_STATUS_SUCCESS;
16042}
16043
Frank Liu3d5e9992017-03-15 17:51:43 +080016044#ifdef CONVERGED_TDLS_ENABLE
16045/**
16046 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
16047 * @wmi_handle: wmi handle
16048 * @param evt_buf: pointer to event buffer
16049 * @param param: Pointer to hold vdev tdls param
16050 *
16051 * Return: QDF_STATUS_SUCCESS for success or error code
16052 */
16053static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
16054 void *evt_buf, struct tdls_event_info *param)
16055{
16056 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
16057 wmi_tdls_peer_event_fixed_param *evt;
16058
16059 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
16060 if (!param_buf) {
16061 WMI_LOGE("%s: NULL param_buf", __func__);
16062 return QDF_STATUS_E_NULL_VALUE;
16063 }
16064
16065 evt = param_buf->fixed_param;
16066
16067 qdf_mem_zero(param, sizeof(*param));
16068
16069 param->vdev_id = evt->vdev_id;
16070 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
16071 param->peermac.bytes);
16072 switch (evt->peer_status) {
16073 case WMI_TDLS_SHOULD_DISCOVER:
16074 param->message_type = TDLS_SHOULD_DISCOVER;
16075 break;
16076 case WMI_TDLS_SHOULD_TEARDOWN:
16077 param->message_type = TDLS_SHOULD_TEARDOWN;
16078 break;
16079 case WMI_TDLS_PEER_DISCONNECTED:
16080 param->message_type = TDLS_PEER_DISCONNECTED;
16081 break;
16082 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
16083 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
16084 break;
16085 default:
16086 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
16087 __func__, evt->peer_status);
16088 return QDF_STATUS_E_INVAL;
16089 };
16090
16091 switch (evt->peer_reason) {
16092 case WMI_TDLS_TEARDOWN_REASON_TX:
16093 param->peer_reason = TDLS_TEARDOWN_TX;
16094 break;
16095 case WMI_TDLS_TEARDOWN_REASON_RSSI:
16096 param->peer_reason = TDLS_TEARDOWN_RSSI;
16097 break;
16098 case WMI_TDLS_TEARDOWN_REASON_SCAN:
16099 param->peer_reason = TDLS_TEARDOWN_SCAN;
16100 break;
16101 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
16102 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
16103 break;
16104 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
16105 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
16106 break;
16107 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
16108 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
16109 break;
16110 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
16111 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
16112 break;
16113 case WMI_TDLS_ENTER_BUF_STA:
16114 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
16115 break;
16116 case WMI_TDLS_EXIT_BUF_STA:
16117 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
16118 break;
16119 case WMI_TDLS_ENTER_BT_BUSY_MODE:
16120 param->peer_reason = TDLS_ENTER_BT_BUSY;
16121 break;
16122 case WMI_TDLS_EXIT_BT_BUSY_MODE:
16123 param->peer_reason = TDLS_EXIT_BT_BUSY;
16124 break;
16125 case WMI_TDLS_SCAN_STARTED_EVENT:
16126 param->peer_reason = TDLS_SCAN_STARTED;
16127 break;
16128 case WMI_TDLS_SCAN_COMPLETED_EVENT:
16129 param->peer_reason = TDLS_SCAN_COMPLETED;
16130 break;
16131
16132 default:
16133 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16134 __func__, evt->peer_reason, evt->peer_status);
16135 return QDF_STATUS_E_INVAL;
16136 };
16137
16138 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16139 __func__, param->peermac.bytes, param->message_type,
16140 param->peer_reason, param->vdev_id);
16141
16142 return QDF_STATUS_SUCCESS;
16143}
16144#endif
16145
Govind Singhe7f2f342016-05-23 12:12:52 +053016146/**
16147 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16148 * @wmi_handle: wmi handle
16149 * @param evt_buf: pointer to event buffer
16150 * @param param: Pointer to hold MGMT TX completion params
16151 *
16152 * Return: QDF_STATUS_SUCCESS for success or error code
16153 */
16154static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16155 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16156{
16157 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16158 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16159
16160 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16161 evt_buf;
16162 if (!param_buf) {
16163 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16164 return QDF_STATUS_E_INVAL;
16165 }
16166 cmpl_params = param_buf->fixed_param;
16167
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016168 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16169 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016170 param->desc_id = cmpl_params->desc_id;
16171 param->status = cmpl_params->status;
16172
16173 return QDF_STATUS_SUCCESS;
16174}
16175
16176/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016177 * extract_offchan_data_tx_compl_param_tlv() -
16178 * extract Offchan data tx completion event params
16179 * @wmi_handle: wmi handle
16180 * @param evt_buf: pointer to event buffer
16181 * @param param: Pointer to hold offchan data TX completion params
16182 *
16183 * Return: QDF_STATUS_SUCCESS for success or error code
16184 */
16185static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16186 wmi_unified_t wmi_handle, void *evt_buf,
16187 struct wmi_host_offchan_data_tx_compl_event *param)
16188{
16189 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16190 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16191
16192 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16193 evt_buf;
16194 if (!param_buf) {
16195 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16196 return QDF_STATUS_E_INVAL;
16197 }
16198 cmpl_params = param_buf->fixed_param;
16199
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016200 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16201 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016202 param->desc_id = cmpl_params->desc_id;
16203 param->status = cmpl_params->status;
16204
16205 return QDF_STATUS_SUCCESS;
16206}
16207
16208/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016209 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16210 * status tlv
16211 * @wmi_handle: wmi handle
16212 * @param evt_buf: pointer to event buffer
16213 * @param param: Pointer to hold csa switch count status event param
16214 *
16215 * Return: QDF_STATUS_SUCCESS for success or error code
16216 */
16217static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16218 wmi_unified_t wmi_handle,
16219 void *evt_buf,
16220 struct pdev_csa_switch_count_status *param)
16221{
16222 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16223 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16224
16225 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16226 evt_buf;
16227 if (!param_buf) {
16228 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16229 return QDF_STATUS_E_INVAL;
16230 }
16231
16232 csa_status = param_buf->fixed_param;
16233
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016234 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16235 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016236 param->current_switch_count = csa_status->current_switch_count;
16237 param->num_vdevs = csa_status->num_vdevs;
16238 param->vdev_ids = param_buf->vdev_ids;
16239
16240 return QDF_STATUS_SUCCESS;
16241}
16242
16243/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016244 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016245 * @wmi_handle: wmi handle
16246 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016247 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016248 *
16249 * Return: QDF_STATUS_SUCCESS for success or error code
16250 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016251static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16252 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016253{
16254 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16255 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016256 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016257
16258 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16259 if (!param_buf) {
16260 WMI_LOGE("Invalid swba event buffer");
16261 return QDF_STATUS_E_INVAL;
16262 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016263
Govind Singhe7f2f342016-05-23 12:12:52 +053016264 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016265 *num_vdevs = swba_event->num_vdevs;
16266 if (!(*num_vdevs)) {
16267 vdev_map = swba_event->vdev_map;
16268 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16269 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016270
16271 return QDF_STATUS_SUCCESS;
16272}
16273
16274/**
16275 * extract_swba_tim_info_tlv() - extract swba tim info from event
16276 * @wmi_handle: wmi handle
16277 * @param evt_buf: pointer to event buffer
16278 * @param idx: Index to bcn info
16279 * @param tim_info: Pointer to hold tim info
16280 *
16281 * Return: QDF_STATUS_SUCCESS for success or error code
16282 */
16283static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16284 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16285{
16286 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16287 wmi_tim_info *tim_info_ev;
16288
16289 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16290 if (!param_buf) {
16291 WMI_LOGE("Invalid swba event buffer");
16292 return QDF_STATUS_E_INVAL;
16293 }
16294
16295 tim_info_ev = &param_buf->tim_info[idx];
16296
16297 tim_info->tim_len = tim_info_ev->tim_len;
16298 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16299 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16300 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16301 tim_info->tim_changed = tim_info_ev->tim_changed;
16302 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016303 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016304
16305 return QDF_STATUS_SUCCESS;
16306}
16307
16308/**
16309 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16310 * @wmi_handle: wmi handle
16311 * @param evt_buf: pointer to event buffer
16312 * @param idx: Index to bcn info
16313 * @param p2p_desc: Pointer to hold p2p NoA info
16314 *
16315 * Return: QDF_STATUS_SUCCESS for success or error code
16316 */
16317static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16318 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16319{
16320 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16321 wmi_p2p_noa_info *p2p_noa_info;
16322 uint8_t i = 0;
16323
16324 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16325 if (!param_buf) {
16326 WMI_LOGE("Invalid swba event buffer");
16327 return QDF_STATUS_E_INVAL;
16328 }
16329
16330 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16331
16332 p2p_desc->modified = false;
16333 p2p_desc->num_descriptors = 0;
16334 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16335 p2p_desc->modified = true;
16336 p2p_desc->index =
16337 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16338 p2p_desc->oppPS =
16339 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16340 p2p_desc->ctwindow =
16341 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16342 p2p_desc->num_descriptors =
16343 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16344 (p2p_noa_info);
16345 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16346 p2p_desc->noa_descriptors[i].type_count =
16347 (uint8_t) p2p_noa_info->noa_descriptors[i].
16348 type_count;
16349 p2p_desc->noa_descriptors[i].duration =
16350 p2p_noa_info->noa_descriptors[i].duration;
16351 p2p_desc->noa_descriptors[i].interval =
16352 p2p_noa_info->noa_descriptors[i].interval;
16353 p2p_desc->noa_descriptors[i].start_time =
16354 p2p_noa_info->noa_descriptors[i].start_time;
16355 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016356 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016357 }
16358
16359 return QDF_STATUS_SUCCESS;
16360}
16361
Wu Gaocd3a8512017-03-13 20:17:34 +080016362#ifdef CONVERGED_P2P_ENABLE
16363/**
16364 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16365 * @wmi_handle: wmi handle
16366 * @param evt_buf: pointer to event buffer
16367 * @param param: Pointer to hold p2p noa info
16368 *
16369 * Return: QDF_STATUS_SUCCESS for success or error code
16370 */
16371static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16372 wmi_unified_t wmi_handle, void *evt_buf,
16373 struct p2p_noa_info *param)
16374{
16375 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16376 wmi_p2p_noa_event_fixed_param *fixed_param;
16377 uint8_t i;
16378 wmi_p2p_noa_info *wmi_noa_info;
16379 uint8_t *buf_ptr;
16380 uint32_t descriptors;
16381
16382 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16383 if (!param_tlvs) {
16384 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16385 return QDF_STATUS_E_INVAL;
16386 }
16387
16388 if (!param) {
16389 WMI_LOGE("noa information param is null");
16390 return QDF_STATUS_E_INVAL;
16391 }
16392
16393 fixed_param = param_tlvs->fixed_param;
16394 buf_ptr = (uint8_t *) fixed_param;
16395 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16396 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16397
16398 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16399 WMI_LOGE("%s: noa attr is not modified", __func__);
16400 return QDF_STATUS_E_INVAL;
16401 }
16402
16403 param->vdev_id = fixed_param->vdev_id;
16404 param->index =
16405 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16406 param->opps_ps =
16407 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16408 param->ct_window =
16409 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16410 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16411 param->num_desc = (uint8_t) descriptors;
16412
16413 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16414 param->index, param->opps_ps, param->ct_window,
16415 param->num_desc);
16416 for (i = 0; i < param->num_desc; i++) {
16417 param->noa_desc[i].type_count =
16418 (uint8_t) wmi_noa_info->noa_descriptors[i].
16419 type_count;
16420 param->noa_desc[i].duration =
16421 wmi_noa_info->noa_descriptors[i].duration;
16422 param->noa_desc[i].interval =
16423 wmi_noa_info->noa_descriptors[i].interval;
16424 param->noa_desc[i].start_time =
16425 wmi_noa_info->noa_descriptors[i].start_time;
16426 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16427 __func__, i, param->noa_desc[i].type_count,
16428 param->noa_desc[i].duration,
16429 param->noa_desc[i].interval,
16430 param->noa_desc[i].start_time);
16431 }
16432
16433 return QDF_STATUS_SUCCESS;
16434}
16435
16436/**
16437 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16438 * information from event
16439 * @wmi_handle: wmi handle
16440 * @param evt_buf: pointer to event buffer
16441 * @param param: Pointer to hold p2p lo stop event information
16442 *
16443 * Return: QDF_STATUS_SUCCESS for success or error code
16444 */
16445static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16446 wmi_unified_t wmi_handle, void *evt_buf,
16447 struct p2p_lo_event *param)
16448{
16449 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16450 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16451
16452 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16453 evt_buf;
16454 if (!param_tlvs) {
16455 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16456 return QDF_STATUS_E_INVAL;
16457 }
16458
16459 if (!param) {
16460 WMI_LOGE("lo stop event param is null");
16461 return QDF_STATUS_E_INVAL;
16462 }
16463
16464 lo_param = param_tlvs->fixed_param;
16465 param->vdev_id = lo_param->vdev_id;
16466 param->reason_code = lo_param->reason;
16467 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16468 param->vdev_id, param->reason_code);
16469
16470 return QDF_STATUS_SUCCESS;
16471}
16472#endif /* End of CONVERGED_P2P_ENABLE */
16473
Govind Singhe7f2f342016-05-23 12:12:52 +053016474/**
16475 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16476 * @wmi_handle: wmi handle
16477 * @param evt_buf: pointer to event buffer
16478 * @param ev: Pointer to hold peer param
16479 *
16480 * Return: QDF_STATUS_SUCCESS for success or error code
16481 */
16482static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16483 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16484{
16485 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16486 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16487
16488 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16489 kickout_event = param_buf->fixed_param;
16490
16491 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16492 ev->peer_macaddr);
16493
16494 ev->reason = kickout_event->reason;
16495 ev->rssi = kickout_event->rssi;
16496
16497 return QDF_STATUS_SUCCESS;
16498}
16499
16500/**
16501 * extract_all_stats_counts_tlv() - extract all stats count from event
16502 * @wmi_handle: wmi handle
16503 * @param evt_buf: pointer to event buffer
16504 * @param stats_param: Pointer to hold stats count
16505 *
16506 * Return: QDF_STATUS_SUCCESS for success or error code
16507 */
16508static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16509 void *evt_buf, wmi_host_stats_event *stats_param)
16510{
16511 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16512 wmi_stats_event_fixed_param *ev;
16513
16514 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16515
16516 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16517 if (!ev) {
16518 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16519 return QDF_STATUS_E_FAILURE;
16520 }
16521
16522 switch (ev->stats_id) {
16523 case WMI_REQUEST_PEER_STAT:
16524 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16525 break;
16526
16527 case WMI_REQUEST_AP_STAT:
16528 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16529 break;
16530
16531 case WMI_REQUEST_PDEV_STAT:
16532 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16533 break;
16534
16535 case WMI_REQUEST_VDEV_STAT:
16536 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16537 break;
16538
16539 case WMI_REQUEST_BCNFLT_STAT:
16540 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16541 break;
16542
16543 case WMI_REQUEST_VDEV_RATE_STAT:
16544 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16545 break;
16546
16547 default:
16548 stats_param->stats_id = 0;
16549 break;
16550
16551 }
16552
16553 stats_param->num_pdev_stats = ev->num_pdev_stats;
16554 stats_param->num_pdev_ext_stats = 0;
16555 stats_param->num_vdev_stats = ev->num_vdev_stats;
16556 stats_param->num_peer_stats = ev->num_peer_stats;
16557 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16558 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016559 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016560
16561 return QDF_STATUS_SUCCESS;
16562}
16563
16564/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016565 * extract_pdev_tx_stats() - extract pdev tx stats from event
16566 */
16567static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16568{
16569 /* Tx Stats */
16570 tx->comp_queued = tx_stats->comp_queued;
16571 tx->comp_delivered = tx_stats->comp_delivered;
16572 tx->msdu_enqued = tx_stats->msdu_enqued;
16573 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16574 tx->wmm_drop = tx_stats->wmm_drop;
16575 tx->local_enqued = tx_stats->local_enqued;
16576 tx->local_freed = tx_stats->local_freed;
16577 tx->hw_queued = tx_stats->hw_queued;
16578 tx->hw_reaped = tx_stats->hw_reaped;
16579 tx->underrun = tx_stats->underrun;
16580 tx->tx_abort = tx_stats->tx_abort;
16581 tx->mpdus_requed = tx_stats->mpdus_requed;
16582 tx->data_rc = tx_stats->data_rc;
16583 tx->self_triggers = tx_stats->self_triggers;
16584 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16585 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16586 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16587 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16588 tx->pdev_resets = tx_stats->pdev_resets;
16589 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16590 tx->phy_underrun = tx_stats->phy_underrun;
16591 tx->txop_ovf = tx_stats->txop_ovf;
16592
16593 return;
16594}
16595
16596
16597/**
16598 * extract_pdev_rx_stats() - extract pdev rx stats from event
16599 */
16600static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16601{
16602 /* Rx Stats */
16603 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16604 rx->status_rcvd = rx_stats->status_rcvd;
16605 rx->r0_frags = rx_stats->r0_frags;
16606 rx->r1_frags = rx_stats->r1_frags;
16607 rx->r2_frags = rx_stats->r2_frags;
16608 /* Only TLV */
16609 rx->r3_frags = 0;
16610 rx->htt_msdus = rx_stats->htt_msdus;
16611 rx->htt_mpdus = rx_stats->htt_mpdus;
16612 rx->loc_msdus = rx_stats->loc_msdus;
16613 rx->loc_mpdus = rx_stats->loc_mpdus;
16614 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16615 rx->phy_errs = rx_stats->phy_errs;
16616 rx->phy_err_drop = rx_stats->phy_err_drop;
16617 rx->mpdu_errs = rx_stats->mpdu_errs;
16618
16619 return;
16620}
16621
16622/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016623 * extract_pdev_stats_tlv() - extract pdev stats from event
16624 * @wmi_handle: wmi handle
16625 * @param evt_buf: pointer to event buffer
16626 * @param index: Index into pdev stats
16627 * @param pdev_stats: Pointer to hold pdev stats
16628 *
16629 * Return: QDF_STATUS_SUCCESS for success or error code
16630 */
16631static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16632 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16633{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016634 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16635 wmi_stats_event_fixed_param *ev_param;
16636 uint8_t *data;
16637
16638 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16639 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16640
16641 data = param_buf->data;
16642
16643 if (index < ev_param->num_pdev_stats) {
16644 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
16645 (index * sizeof(wmi_pdev_stats)));
16646
16647 pdev_stats->chan_nf = ev->chan_nf;
16648 pdev_stats->tx_frame_count = ev->tx_frame_count;
16649 pdev_stats->rx_frame_count = ev->rx_frame_count;
16650 pdev_stats->rx_clear_count = ev->rx_clear_count;
16651 pdev_stats->cycle_count = ev->cycle_count;
16652 pdev_stats->phy_err_count = ev->phy_err_count;
16653 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
16654
16655 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
16656 &(ev->pdev_stats.tx));
16657 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
16658 &(ev->pdev_stats.rx));
16659 }
16660
Govind Singhe7f2f342016-05-23 12:12:52 +053016661 return QDF_STATUS_SUCCESS;
16662}
16663
16664/**
16665 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
16666 * @wmi_handle: wmi handle
16667 * @param evt_buf: pointer to event buffer
16668 * @param index: Index into extended pdev stats
16669 * @param pdev_ext_stats: Pointer to hold extended pdev stats
16670 *
16671 * Return: QDF_STATUS_SUCCESS for success or error code
16672 */
16673static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
16674 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
16675{
16676 return QDF_STATUS_SUCCESS;
16677}
16678
16679/**
16680 * extract_vdev_stats_tlv() - extract vdev stats from event
16681 * @wmi_handle: wmi handle
16682 * @param evt_buf: pointer to event buffer
16683 * @param index: Index into vdev stats
16684 * @param vdev_stats: Pointer to hold vdev stats
16685 *
16686 * Return: QDF_STATUS_SUCCESS for success or error code
16687 */
16688static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
16689 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
16690{
16691 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16692 wmi_stats_event_fixed_param *ev_param;
16693 uint8_t *data;
16694
16695 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16696 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16697 data = (uint8_t *) param_buf->data;
16698
16699 if (index < ev_param->num_vdev_stats) {
16700 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
16701 ((ev_param->num_pdev_stats) *
16702 sizeof(wmi_pdev_stats)) +
16703 (index * sizeof(wmi_vdev_stats)));
16704
16705 vdev_stats->vdev_id = ev->vdev_id;
16706 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
16707 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
16708
16709 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
16710 sizeof(ev->tx_frm_cnt));
16711 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
16712 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
16713 ev->multiple_retry_cnt,
16714 sizeof(ev->multiple_retry_cnt));
16715 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
16716 sizeof(ev->fail_cnt));
16717 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
16718 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
16719 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
16720 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
16721 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
16722 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
16723 sizeof(ev->tx_rate_history));
16724 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
16725 sizeof(ev->bcn_rssi_history));
16726
16727 }
16728
16729 return QDF_STATUS_SUCCESS;
16730}
16731
16732/**
16733 * extract_peer_stats_tlv() - extract peer stats from event
16734 * @wmi_handle: wmi handle
16735 * @param evt_buf: pointer to event buffer
16736 * @param index: Index into peer stats
16737 * @param peer_stats: Pointer to hold peer stats
16738 *
16739 * Return: QDF_STATUS_SUCCESS for success or error code
16740 */
16741static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
16742 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
16743{
16744 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16745 wmi_stats_event_fixed_param *ev_param;
16746 uint8_t *data;
16747
16748 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16749 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16750 data = (uint8_t *) param_buf->data;
16751
16752 if (index < ev_param->num_peer_stats) {
16753 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
16754 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16755 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16756 (index * sizeof(wmi_peer_stats)));
16757
16758 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
16759
16760 OS_MEMCPY(&(peer_stats->peer_macaddr),
16761 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
16762
16763 peer_stats->peer_rssi = ev->peer_rssi;
16764 peer_stats->peer_tx_rate = ev->peer_tx_rate;
16765 peer_stats->peer_rx_rate = ev->peer_rx_rate;
16766 }
16767
16768 return QDF_STATUS_SUCCESS;
16769}
16770
16771/**
16772 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
16773 * @wmi_handle: wmi handle
16774 * @param evt_buf: pointer to event buffer
16775 * @param index: Index into bcn fault stats
16776 * @param bcnflt_stats: Pointer to hold bcn fault stats
16777 *
16778 * Return: QDF_STATUS_SUCCESS for success or error code
16779 */
16780static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
16781 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
16782{
16783 return QDF_STATUS_SUCCESS;
16784}
16785
16786/**
16787 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
16788 * @wmi_handle: wmi handle
16789 * @param evt_buf: pointer to event buffer
16790 * @param index: Index into extended peer stats
16791 * @param peer_extd_stats: Pointer to hold extended peer stats
16792 *
16793 * Return: QDF_STATUS_SUCCESS for success or error code
16794 */
16795static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
16796 void *evt_buf, uint32_t index,
16797 wmi_host_peer_extd_stats *peer_extd_stats)
16798{
16799 return QDF_STATUS_SUCCESS;
16800}
16801
16802/**
16803 * extract_chan_stats_tlv() - extract chan stats from event
16804 * @wmi_handle: wmi handle
16805 * @param evt_buf: pointer to event buffer
16806 * @param index: Index into chan stats
16807 * @param vdev_extd_stats: Pointer to hold chan stats
16808 *
16809 * Return: QDF_STATUS_SUCCESS for success or error code
16810 */
16811static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
16812 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
16813{
16814 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16815 wmi_stats_event_fixed_param *ev_param;
16816 uint8_t *data;
16817
16818 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16819 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16820 data = (uint8_t *) param_buf->data;
16821
16822 if (index < ev_param->num_chan_stats) {
16823 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
16824 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16825 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16826 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
16827 (index * sizeof(wmi_chan_stats)));
16828
16829
16830 /* Non-TLV doesnt have num_chan_stats */
16831 chan_stats->chan_mhz = ev->chan_mhz;
16832 chan_stats->sampling_period_us = ev->sampling_period_us;
16833 chan_stats->rx_clear_count = ev->rx_clear_count;
16834 chan_stats->tx_duration_us = ev->tx_duration_us;
16835 chan_stats->rx_duration_us = ev->rx_duration_us;
16836 }
16837
16838 return QDF_STATUS_SUCCESS;
16839}
16840
16841/**
16842 * extract_profile_ctx_tlv() - extract profile context from event
16843 * @wmi_handle: wmi handle
16844 * @param evt_buf: pointer to event buffer
16845 * @idx: profile stats index to extract
16846 * @param profile_ctx: Pointer to hold profile context
16847 *
16848 * Return: QDF_STATUS_SUCCESS for success or error code
16849 */
16850static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
16851 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
16852{
16853 return QDF_STATUS_SUCCESS;
16854}
16855
16856/**
16857 * extract_profile_data_tlv() - extract profile data from event
16858 * @wmi_handle: wmi handle
16859 * @param evt_buf: pointer to event buffer
16860 * @param profile_data: Pointer to hold profile data
16861 *
16862 * Return: QDF_STATUS_SUCCESS for success or error code
16863 */
16864static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
16865 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
16866{
16867
16868 return QDF_STATUS_SUCCESS;
16869}
16870
16871/**
16872 * extract_chan_info_event_tlv() - extract chan information from event
16873 * @wmi_handle: wmi handle
16874 * @param evt_buf: pointer to event buffer
16875 * @param chan_info: Pointer to hold chan information
16876 *
16877 * Return: QDF_STATUS_SUCCESS for success or error code
16878 */
16879static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
16880 void *evt_buf, wmi_host_chan_info_event *chan_info)
16881{
16882 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
16883 wmi_chan_info_event_fixed_param *ev;
16884
16885 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
16886
16887 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
16888 if (!ev) {
16889 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
16890 return QDF_STATUS_E_FAILURE;
16891 }
16892
16893 chan_info->err_code = ev->err_code;
16894 chan_info->freq = ev->freq;
16895 chan_info->cmd_flags = ev->cmd_flags;
16896 chan_info->noise_floor = ev->noise_floor;
16897 chan_info->rx_clear_count = ev->rx_clear_count;
16898 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053016899 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
16900 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
16901 ev->vdev_id, WLAN_SCAN_ID);
Govind Singhe7f2f342016-05-23 12:12:52 +053016902
16903 return QDF_STATUS_SUCCESS;
16904}
16905
16906/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016907 * extract_pdev_utf_event_tlv() - extract UTF data info from event
16908 * @wmi_handle: WMI handle
16909 * @param evt_buf: Pointer to event buffer
16910 * @param param: Pointer to hold data
16911 *
16912 * Return : QDF_STATUS_SUCCESS for success or error code
16913 */
16914static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16915 uint8_t *evt_buf,
16916 struct wmi_host_pdev_utf_event *event)
16917{
16918 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016919 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016920
16921 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
16922 event->data = param_buf->data;
16923 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016924 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053016925 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016926 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016927 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016928
16929 return QDF_STATUS_SUCCESS;
16930}
Govind Singhe7f2f342016-05-23 12:12:52 +053016931
Kiran Venkatappa06520822016-08-10 23:55:40 +053016932/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016933 * extract_chainmask_tables_tlv() - extract chain mask tables from event
16934 * @wmi_handle: wmi handle
16935 * @param evt_buf: pointer to event buffer
16936 * @param param: Pointer to hold evt buf
16937 *
16938 * Return: QDF_STATUS_SUCCESS for success or error code
16939 */
16940static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
16941 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
16942{
16943 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16944 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
16945 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16946 uint8_t i = 0, j = 0;
16947
16948 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16949 if (!param_buf)
16950 return QDF_STATUS_E_INVAL;
16951
16952 hw_caps = param_buf->soc_hw_mode_caps;
16953 if (!hw_caps)
16954 return QDF_STATUS_E_INVAL;
16955
16956 if (!hw_caps->num_chainmask_tables)
16957 return QDF_STATUS_E_INVAL;
16958
16959 chainmask_caps = param_buf->mac_phy_chainmask_caps;
16960
16961 if (chainmask_caps == NULL)
16962 return QDF_STATUS_E_INVAL;
16963
16964 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16965
16966 qdf_print("Dumping chain mask combo data for table : %d\n", i);
16967 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
16968
16969 chainmask_table[i].cap_list[j].chainmask =
16970 chainmask_caps->chainmask;
16971
16972 chainmask_table[i].cap_list[j].supports_chan_width_20 =
16973 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
16974
16975 chainmask_table[i].cap_list[j].supports_chan_width_40 =
16976 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
16977
16978 chainmask_table[i].cap_list[j].supports_chan_width_80 =
16979 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
16980
16981 chainmask_table[i].cap_list[j].supports_chan_width_160 =
16982 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
16983
16984 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
16985 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
16986
16987 chainmask_table[i].cap_list[j].chain_mask_2G =
16988 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
16989
16990 chainmask_table[i].cap_list[j].chain_mask_5G =
16991 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
16992
16993 chainmask_table[i].cap_list[j].chain_mask_tx =
16994 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
16995
16996 chainmask_table[i].cap_list[j].chain_mask_rx =
16997 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
16998
16999 chainmask_table[i].cap_list[j].supports_aDFS =
17000 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
17001
17002 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
17003 chainmask_caps->supported_flags,
17004 chainmask_caps->chainmask
17005 );
17006 chainmask_caps++;
17007 }
17008 }
17009
17010 return QDF_STATUS_SUCCESS;
17011}
17012
17013/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053017014 * extract_service_ready_ext_tlv() - extract basic extended service ready params
17015 * from event
17016 * @wmi_handle: wmi handle
17017 * @param evt_buf: pointer to event buffer
17018 * @param param: Pointer to hold evt buf
17019 *
17020 * Return: QDF_STATUS_SUCCESS for success or error code
17021 */
17022static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017023 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017024{
17025 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17026 wmi_service_ready_ext_event_fixed_param *ev;
17027 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17028 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017029 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
17030 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017031
17032 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17033 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017034 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017035
17036 ev = param_buf->fixed_param;
17037 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017038 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017039
17040 /* Move this to host based bitmap */
17041 param->default_conc_scan_config_bits =
17042 ev->default_conc_scan_config_bits;
17043 param->default_fw_config_bits = ev->default_fw_config_bits;
17044 param->he_cap_info = ev->he_cap_info;
17045 param->mpdu_density = ev->mpdu_density;
17046 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
17047 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
17048
17049 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017050 if (hw_caps)
17051 param->num_hw_modes = hw_caps->num_hw_modes;
17052 else
17053 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017054
17055 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017056 if (reg_caps)
17057 param->num_phy = reg_caps->num_phy;
17058 else
17059 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017060
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017061 if (hw_caps) {
17062 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
17063 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
17064 } else
17065 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017066
17067 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
17068
17069 if (chain_mask_combo == NULL)
17070 return QDF_STATUS_SUCCESS;
17071
17072 qdf_print("Dumping chain mask combo data\n");
17073
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017074 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017075
17076 qdf_print("table_id : %d Num valid chainmasks: %d\n",
17077 chain_mask_combo->chainmask_table_id,
17078 chain_mask_combo->num_valid_chainmask
17079 );
17080
17081 param->chainmask_table[i].table_id =
17082 chain_mask_combo->chainmask_table_id;
17083 param->chainmask_table[i].num_valid_chainmasks =
17084 chain_mask_combo->num_valid_chainmask;
17085 chain_mask_combo++;
17086 }
17087 qdf_print("chain mask combo end\n");
17088
Kiran Venkatappa06520822016-08-10 23:55:40 +053017089 return QDF_STATUS_SUCCESS;
17090}
17091
17092/**
17093 * extract_hw_mode_cap_service_ready_ext_tlv() -
17094 * extract HW mode cap from service ready event
17095 * @wmi_handle: wmi handle
17096 * @param evt_buf: pointer to event buffer
17097 * @param param: Pointer to hold evt buf
17098 * @param hw_mode_idx: hw mode idx should be less than num_mode
17099 *
17100 * Return: QDF_STATUS_SUCCESS for success or error code
17101 */
17102static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
17103 wmi_unified_t wmi_handle,
17104 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017105 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017106{
17107 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17108 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17109
17110 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17111 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017112 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017113
17114 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017115 if (!hw_caps)
17116 return QDF_STATUS_E_INVAL;
17117
Kiran Venkatappa06520822016-08-10 23:55:40 +053017118 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017119 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017120
17121 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
17122 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
17123
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017124 param->hw_mode_config_type =
17125 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
17126
Kiran Venkatappa06520822016-08-10 23:55:40 +053017127 return QDF_STATUS_SUCCESS;
17128}
17129
17130/**
17131 * extract_mac_phy_cap_service_ready_ext_tlv() -
17132 * extract MAC phy cap from service ready event
17133 * @wmi_handle: wmi handle
17134 * @param evt_buf: pointer to event buffer
17135 * @param param: Pointer to hold evt buf
17136 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017137 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017138 *
17139 * Return: QDF_STATUS_SUCCESS for success or error code
17140 */
17141static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17142 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017143 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017144 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017145{
17146 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017147 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017148 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17149 uint32_t phy_map;
17150 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017151
17152 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17153 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017154 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017155
17156 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017157 if (!hw_caps)
17158 return QDF_STATUS_E_INVAL;
17159
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017160 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17161 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17162 break;
17163
17164 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17165 while (phy_map) {
17166 phy_map >>= 1;
17167 phy_idx++;
17168 }
17169 }
17170
17171 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017172 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017173
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017174 phy_idx += phy_id;
17175 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017176 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017177
17178 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017179
17180 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017181 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17182 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017183 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017184 param->supports_11b =
17185 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17186 param->supports_11g =
17187 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17188 param->supports_11a =
17189 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17190 param->supports_11n =
17191 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17192 param->supports_11ac =
17193 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17194 param->supports_11ax =
17195 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017196
17197 param->supported_bands = mac_phy_caps->supported_bands;
17198 param->ampdu_density = mac_phy_caps->ampdu_density;
17199 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17200 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17201 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17202 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17203 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17204 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17205 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17206 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17207 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17208 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17209 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17210 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17211 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17212 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17213 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17214 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017215 qdf_mem_copy(&param->he_cap_phy_info_2G,
17216 &mac_phy_caps->he_cap_phy_info_2G,
17217 sizeof(param->he_cap_phy_info_2G));
17218 qdf_mem_copy(&param->he_cap_phy_info_5G,
17219 &mac_phy_caps->he_cap_phy_info_5G,
17220 sizeof(param->he_cap_phy_info_5G));
17221 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17222 sizeof(param->he_ppet2G));
17223 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17224 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017225 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017226
17227 return QDF_STATUS_SUCCESS;
17228}
17229
17230/**
17231 * extract_reg_cap_service_ready_ext_tlv() -
17232 * extract REG cap from service ready event
17233 * @wmi_handle: wmi handle
17234 * @param evt_buf: pointer to event buffer
17235 * @param param: Pointer to hold evt buf
17236 * @param phy_idx: phy idx should be less than num_mode
17237 *
17238 * Return: QDF_STATUS_SUCCESS for success or error code
17239 */
17240static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17241 wmi_unified_t wmi_handle,
17242 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017243 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017244{
17245 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17246 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17247 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17248
17249 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17250 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017251 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017252
17253 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017254 if (!reg_caps)
17255 return QDF_STATUS_E_INVAL;
17256
Kiran Venkatappa06520822016-08-10 23:55:40 +053017257 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017258 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017259
17260 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17261
17262 param->phy_id = ext_reg_cap->phy_id;
17263 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17264 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17265 param->regcap1 = ext_reg_cap->regcap1;
17266 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017267 param->wireless_modes = convert_wireless_modes_tlv(
17268 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017269 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17270 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17271 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17272 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17273
17274 return QDF_STATUS_SUCCESS;
17275}
17276
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017277/**
17278 * extract_dcs_interference_type_tlv() - extract dcs interference type
17279 * from event
17280 * @wmi_handle: wmi handle
17281 * @param evt_buf: pointer to event buffer
17282 * @param param: Pointer to hold dcs interference param
17283 *
17284 * Return: 0 for success or error code
17285 */
17286static QDF_STATUS extract_dcs_interference_type_tlv(
17287 wmi_unified_t wmi_handle,
17288 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17289{
17290 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17291
17292 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17293 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017294 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017295
17296 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017297 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17298 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017299
17300 return QDF_STATUS_SUCCESS;
17301}
17302
17303/*
17304 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17305 * @wmi_handle: wmi handle
17306 * @param evt_buf: pointer to event buffer
17307 * @param cw_int: Pointer to hold cw interference
17308 *
17309 * Return: 0 for success or error code
17310 */
17311static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17312 void *evt_buf,
17313 wmi_host_ath_dcs_cw_int *cw_int)
17314{
17315 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17316 wlan_dcs_cw_int *ev;
17317
17318 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17319 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017320 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017321
17322 ev = param_buf->cw_int;
17323
17324 cw_int->channel = ev->channel;
17325
17326 return QDF_STATUS_SUCCESS;
17327}
17328
17329/**
17330 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17331 * @wmi_handle: wmi handle
17332 * @param evt_buf: pointer to event buffer
17333 * @param wlan_stat: Pointer to hold wlan stats
17334 *
17335 * Return: 0 for success or error code
17336 */
17337static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17338 void *evt_buf,
17339 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17340{
17341 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17342 wlan_dcs_im_tgt_stats_t *ev;
17343
17344 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17345 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017346 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017347
17348 ev = param_buf->wlan_stat;
17349 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17350 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17351 wlan_stat->tx_waste_time = ev->tx_waste_time;
17352 wlan_stat->rx_time = ev->rx_time;
17353 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17354 wlan_stat->mib_stats.listen_time = ev->listen_time;
17355 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17356 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17357 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17358 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17359 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17360 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17361 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17362 wlan_stat->chan_nf = ev->chan_nf;
17363 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17364
17365 return QDF_STATUS_SUCCESS;
17366}
17367
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017368/**
17369 * extract_thermal_stats_tlv() - extract thermal stats from event
17370 * @wmi_handle: wmi handle
17371 * @param evt_buf: Pointer to event buffer
17372 * @param temp: Pointer to hold extracted temperature
17373 * @param level: Pointer to hold extracted level
17374 *
17375 * Return: 0 for success or error code
17376 */
17377static QDF_STATUS
17378extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17379 void *evt_buf, uint32_t *temp,
17380 uint32_t *level, uint32_t *pdev_id)
17381{
17382 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17383 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17384
17385 param_buf =
17386 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17387 if (!param_buf)
17388 return QDF_STATUS_E_INVAL;
17389
17390 tt_stats_event = param_buf->fixed_param;
17391
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017392 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17393 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017394 *temp = tt_stats_event->temp;
17395 *level = tt_stats_event->level;
17396
17397 return QDF_STATUS_SUCCESS;
17398}
17399
17400/**
17401 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17402 * @wmi_handle: wmi handle
17403 * @param evt_buf: pointer to event buffer
17404 * @param idx: Index to level stats
17405 * @param levelcount: Pointer to hold levelcount
17406 * @param dccount: Pointer to hold dccount
17407 *
17408 * Return: 0 for success or error code
17409 */
17410static QDF_STATUS
17411extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17412 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17413 uint32_t *dccount)
17414{
17415 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17416 wmi_therm_throt_level_stats_info *tt_level_info;
17417
17418 param_buf =
17419 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17420 if (!param_buf)
17421 return QDF_STATUS_E_INVAL;
17422
17423 tt_level_info = param_buf->therm_throt_level_stats_info;
17424
17425 if (idx < THERMAL_LEVELS) {
17426 *levelcount = tt_level_info[idx].level_count;
17427 *dccount = tt_level_info[idx].dc_count;
17428 return QDF_STATUS_SUCCESS;
17429 }
17430
17431 return QDF_STATUS_E_FAILURE;
17432}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017433#ifdef BIG_ENDIAN_HOST
17434/**
17435 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17436 * @param data_len - data length
17437 * @param data - pointer to data
17438 *
17439 * Return: QDF_STATUS - success or error status
17440 */
17441static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17442{
17443 uint8_t *data_aligned = NULL;
17444 int c;
17445 unsigned char *data_unaligned;
17446
17447 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17448 FIPS_ALIGN));
17449 /* Assigning unaligned space to copy the data */
17450 /* Checking if kmalloc does succesful allocation */
17451 if (data_unaligned == NULL)
17452 return QDF_STATUS_E_FAILURE;
17453
17454 /* Checking if space is alligned */
17455 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17456 /* align the data space */
17457 data_aligned =
17458 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17459 } else {
17460 data_aligned = (u_int8_t *)data_unaligned;
17461 }
17462
17463 /* memset and copy content from data to data aligned */
17464 OS_MEMSET(data_aligned, 0, data_len);
17465 OS_MEMCPY(data_aligned, data, data_len);
17466 /* Endianness to LE */
17467 for (c = 0; c < data_len/4; c++) {
17468 *((u_int32_t *)data_aligned + c) =
17469 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17470 }
17471
17472 /* Copy content to event->data */
17473 OS_MEMCPY(data, data_aligned, data_len);
17474
17475 /* clean up allocated space */
17476 qdf_mem_free(data_unaligned);
17477 data_aligned = NULL;
17478 data_unaligned = NULL;
17479
17480 /*************************************************************/
17481
17482 return QDF_STATUS_SUCCESS;
17483}
17484#else
17485/**
17486 * fips_conv_data_be() - DUMMY for LE platform
17487 *
17488 * Return: QDF_STATUS - success
17489 */
17490static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17491{
17492 return QDF_STATUS_SUCCESS;
17493}
17494#endif
17495
17496/**
17497 * extract_fips_event_data_tlv() - extract fips event data
17498 * @wmi_handle: wmi handle
17499 * @param evt_buf: pointer to event buffer
17500 * @param param: pointer FIPS event params
17501 *
17502 * Return: 0 for success or error code
17503 */
17504static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17505 void *evt_buf, struct wmi_host_fips_event_param *param)
17506{
17507 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17508 wmi_pdev_fips_event_fixed_param *event;
17509
17510 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17511 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17512
17513 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17514 QDF_STATUS_SUCCESS)
17515 return QDF_STATUS_E_FAILURE;
17516
17517 param->data = (uint32_t *)param_buf->data;
17518 param->data_len = event->data_len;
17519 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017520 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17521 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017522
17523 return QDF_STATUS_SUCCESS;
17524}
17525
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017526/*
17527 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17528 * @wmi_handle: wmi handle
17529 * @param evt_buf: pointer to event buffer
17530 * @param vdev_id: Pointer to hold vdev_id
17531 * @param mac_addr: Pointer to hold peer mac address
17532 *
17533 * Return: QDF_STATUS_SUCCESS for success or error code
17534 */
17535static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17536 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17537{
17538 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17539 wmi_peer_delete_resp_event_fixed_param *ev;
17540
17541 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17542
17543 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17544 if (!ev) {
17545 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17546 return QDF_STATUS_E_FAILURE;
17547 }
17548
17549 param->vdev_id = ev->vdev_id;
17550 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17551 &param->mac_address.bytes[0]);
17552
17553 return QDF_STATUS_SUCCESS;
17554}
17555
Govind Singhecf03cd2016-05-12 12:45:51 +053017556static bool is_management_record_tlv(uint32_t cmd_id)
17557{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017558 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017559 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017560
Govind Singhecf03cd2016-05-12 12:45:51 +053017561 return false;
17562}
17563
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017564static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17565{
17566 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17567
17568 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17569
17570 switch (set_cmd->param_id) {
17571 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17572 case WMI_VDEV_PARAM_DTIM_POLICY:
17573 return HTC_TX_PACKET_TAG_AUTO_PM;
17574 default:
17575 break;
17576 }
17577
17578 return 0;
17579}
17580
17581static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17582{
17583 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17584
17585 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17586
17587 switch (ps_cmd->param) {
17588 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17589 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17590 case WMI_STA_PS_ENABLE_QPOWER:
17591 return HTC_TX_PACKET_TAG_AUTO_PM;
17592 default:
17593 break;
17594 }
17595
17596 return 0;
17597}
17598
17599static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17600 uint32_t cmd_id)
17601{
17602 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17603 return 0;
17604
17605 switch (cmd_id) {
17606 case WMI_VDEV_SET_PARAM_CMDID:
17607 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17608 case WMI_STA_POWERSAVE_PARAM_CMDID:
17609 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17610 default:
17611 break;
17612 }
17613
17614 return 0;
17615}
17616
17617static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17618{
17619 uint16_t tag = 0;
17620
17621 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17622 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17623 __func__);
17624 return tag;
17625 }
17626
17627 if (wmi_handle->tag_crash_inject)
17628 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17629
17630 wmi_handle->tag_crash_inject = false;
17631 return tag;
17632}
17633
17634/**
17635 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17636 * @wmi_handle: WMI handle
17637 * @buf: WMI buffer
17638 * @cmd_id: WMI command Id
17639 *
17640 * Return htc_tx_tag
17641 */
17642static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17643 wmi_buf_t buf,
17644 uint32_t cmd_id)
17645{
17646 uint16_t htc_tx_tag = 0;
17647
17648 switch (cmd_id) {
17649 case WMI_WOW_ENABLE_CMDID:
17650 case WMI_PDEV_SUSPEND_CMDID:
17651 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
17652 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
17653 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
17654 case WMI_PDEV_RESUME_CMDID:
17655 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
17656 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
17657#ifdef FEATURE_WLAN_D0WOW
17658 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
17659#endif
17660 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
17661 break;
17662 case WMI_FORCE_FW_HANG_CMDID:
17663 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
17664 break;
17665 case WMI_VDEV_SET_PARAM_CMDID:
17666 case WMI_STA_POWERSAVE_PARAM_CMDID:
17667 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
17668 default:
17669 break;
17670 }
17671
17672 return htc_tx_tag;
17673}
17674
Sathish Kumard3ab1002017-02-07 17:10:59 +053017675/**
17676 * extract_channel_hopping_event_tlv() - extract channel hopping param
17677 * from event
17678 * @wmi_handle: wmi handle
17679 * @param evt_buf: pointer to event buffer
17680 * @param ch_hopping: Pointer to hold channel hopping param
17681 *
17682 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17683 */
17684static QDF_STATUS extract_channel_hopping_event_tlv(
17685 wmi_unified_t wmi_handle, void *evt_buf,
17686 wmi_host_pdev_channel_hopping_event *ch_hopping)
17687{
17688 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
17689 wmi_pdev_channel_hopping_event_fixed_param *event;
17690
17691 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
17692 event = (wmi_pdev_channel_hopping_event_fixed_param *)
17693 param_buf->fixed_param;
17694
17695 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
17696 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017697 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17698 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017699
17700 return QDF_STATUS_SUCCESS;
17701}
17702
17703/**
17704 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
17705 * @wmi_handle: wmi handle
17706 * @param evt_buf: pointer to event buffer
17707 * @param param: Pointer to hold tpc param
17708 *
17709 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17710 */
17711static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
17712 void *evt_buf,
17713 wmi_host_pdev_tpc_event *param)
17714{
17715 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
17716 wmi_pdev_tpc_event_fixed_param *event;
17717
17718 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
17719 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
17720
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017721 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17722 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017723 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
17724
17725 return QDF_STATUS_SUCCESS;
17726}
17727
17728
17729#ifdef BIG_ENDIAN_HOST
17730/**
17731 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
17732 * @param data_len - data length
17733 * @param data - pointer to data
17734 *
17735 * Return: QDF_STATUS - success or error status
17736 */
17737static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
17738{
17739 uint8_t *datap = (uint8_t *)ev;
17740 /* Skip swapping the first word */
17741 datap += sizeof(uint32_t);
17742 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
17743 i++, datap += sizeof(uint32_t)) {
17744 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
17745 }
17746
17747 return QDF_STATUS_SUCCESS;
17748}
17749#else
17750/**
17751 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
17752 * @param data_len - data length
17753 * @param data - pointer to data
17754 *
17755 * Return: QDF_STATUS - success or error status
17756 */
17757static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
17758{
17759 return QDF_STATUS_SUCCESS;
17760}
17761#endif
17762
17763/**
17764 * extract_wds_addr_event_tlv() - extract wds address from event
17765 * @wmi_handle: wmi handle
17766 * @param evt_buf: pointer to event buffer
17767 * @param wds_ev: Pointer to hold wds address
17768 *
17769 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17770 */
17771static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
17772 void *evt_buf,
17773 uint16_t len, wds_addr_event_t *wds_ev)
17774{
17775 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
17776 wmi_wds_addr_event_fixed_param *ev;
17777 int i;
17778
17779 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
17780 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
17781
17782 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
17783 return QDF_STATUS_E_FAILURE;
17784
17785 qdf_mem_copy(wds_ev->event_type, ev->event_type,
17786 sizeof(wds_ev->event_type));
17787 for (i = 0; i < 4; i++) {
17788 wds_ev->peer_mac[i] =
17789 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
17790 wds_ev->dest_mac[i] =
17791 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
17792 }
17793 for (i = 0; i < 2; i++) {
17794 wds_ev->peer_mac[4+i] =
17795 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
17796 wds_ev->dest_mac[4+i] =
17797 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
17798 }
17799 return QDF_STATUS_SUCCESS;
17800}
17801
17802/**
17803 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
17804 * from event
17805 * @wmi_handle: wmi handle
17806 * @param evt_buf: pointer to event buffer
17807 * @param ev: Pointer to hold peer param and ps state
17808 *
17809 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17810 */
17811static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
17812 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
17813{
17814 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
17815 wmi_peer_sta_ps_statechange_event_fixed_param *event;
17816
17817 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
17818 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
17819 param_buf->fixed_param;
17820
17821 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
17822 ev->peer_ps_state = event->peer_ps_state;
17823
17824 return QDF_STATUS_SUCCESS;
17825}
17826
17827/**
17828 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
17829 * @wmi_handle: wmi handle
17830 * @param evt_buf: pointer to event buffer
17831 * @param inst_rssi_resp: Pointer to hold inst rssi response
17832 *
17833 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17834 */
17835static QDF_STATUS extract_inst_rssi_stats_event_tlv(
17836 wmi_unified_t wmi_handle, void *evt_buf,
17837 wmi_host_inst_stats_resp *inst_rssi_resp)
17838{
17839 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
17840 wmi_inst_rssi_stats_resp_fixed_param *event;
17841
17842 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
17843 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
17844
17845 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
17846 &(event->peer_macaddr), sizeof(wmi_mac_addr));
17847 inst_rssi_resp->iRSSI = event->iRSSI;
17848
17849 return QDF_STATUS_SUCCESS;
17850}
17851
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017852static struct cur_reg_rule
17853*create_reg_rules_from_wmi(uint32_t num_reg_rules,
17854 wmi_regulatory_rule_struct *wmi_reg_rule)
17855{
17856 struct cur_reg_rule *reg_rule_ptr;
17857 uint32_t count;
17858
17859 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
17860
17861 if (NULL == reg_rule_ptr) {
17862 WMI_LOGE("memory allocation failure");
17863 return NULL;
17864 }
17865
17866 for (count = 0; count < num_reg_rules; count++) {
17867 reg_rule_ptr[count].start_freq =
17868 WMI_REG_RULE_START_FREQ_GET(
17869 wmi_reg_rule[count].freq_info);
17870 reg_rule_ptr[count].end_freq =
17871 WMI_REG_RULE_END_FREQ_GET(
17872 wmi_reg_rule[count].freq_info);
17873 reg_rule_ptr[count].max_bw =
17874 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017875 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017876 reg_rule_ptr[count].reg_power =
17877 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017878 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053017879 reg_rule_ptr[count].ant_gain =
17880 WMI_REG_RULE_ANTENNA_GAIN_GET(
17881 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017882 reg_rule_ptr[count].flags =
17883 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017884 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017885 }
17886
17887 return reg_rule_ptr;
17888}
17889
17890static QDF_STATUS extract_reg_chan_list_update_event_tlv(
17891 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17892 struct cur_regulatory_info *reg_info, uint32_t len)
17893{
17894 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
17895 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
17896 wmi_regulatory_rule_struct *wmi_reg_rule;
17897 uint32_t num_2g_reg_rules, num_5g_reg_rules;
17898
17899 WMI_LOGD("processing regulatory channel list");
17900
17901 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
17902 if (!param_buf) {
17903 WMI_LOGE("invalid channel list event buf");
17904 return QDF_STATUS_E_FAILURE;
17905 }
17906
17907 chan_list_event_hdr = param_buf->fixed_param;
17908
17909 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
17910 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
17911 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053017912 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017913 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
17914 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070017915 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070017916 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053017917 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070017918 reg_info->ctry_code = chan_list_event_hdr->country_id;
17919 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
17920 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
17921 reg_info->status_code = REG_SET_CC_STATUS_PASS;
17922 else if (chan_list_event_hdr->status_code ==
17923 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
17924 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
17925 else if (chan_list_event_hdr->status_code ==
17926 WMI_REG_INIT_ALPHA2_NOT_FOUND)
17927 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
17928 else if (chan_list_event_hdr->status_code ==
17929 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
17930 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
17931 else if (chan_list_event_hdr->status_code ==
17932 WMI_REG_SET_CC_STATUS_NO_MEMORY)
17933 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
17934 else if (chan_list_event_hdr->status_code ==
17935 WMI_REG_SET_CC_STATUS_FAIL)
17936 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
17937
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017938 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
17939 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
17940 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
17941 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
17942
17943 num_2g_reg_rules = reg_info->num_2g_reg_rules;
17944 num_5g_reg_rules = reg_info->num_5g_reg_rules;
17945
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017946 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
17947 __func__, reg_info->alpha2, reg_info->dfs_region,
17948 reg_info->min_bw_2g, reg_info->max_bw_2g,
17949 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017950
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017951 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
17952 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070017953 wmi_reg_rule =
17954 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
17955 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
17956 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017957 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
17958 wmi_reg_rule);
17959 wmi_reg_rule += num_2g_reg_rules;
17960
17961 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
17962 wmi_reg_rule);
17963
17964 WMI_LOGD("processed regulatory channel list");
17965
17966 return QDF_STATUS_SUCCESS;
17967}
17968
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070017969static QDF_STATUS extract_reg_11d_new_country_event_tlv(
17970 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17971 struct reg_11d_new_country *reg_11d_country, uint32_t len)
17972{
17973 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
17974 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
17975
17976 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
17977 if (!param_buf) {
17978 WMI_LOGE("invalid 11d country event buf");
17979 return QDF_STATUS_E_FAILURE;
17980 }
17981
17982 reg_11d_country_event = param_buf->fixed_param;
17983
17984 qdf_mem_copy(reg_11d_country->alpha2,
17985 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
17986
17987 WMI_LOGD("processed 11d country event, new cc %s",
17988 reg_11d_country->alpha2);
17989
17990 return QDF_STATUS_SUCCESS;
17991}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017992#ifdef DFS_COMPONENT_ENABLE
17993/**
17994 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
17995 * @wmi_handle: wma handle
17996 * @evt_buf: event buffer
17997 * @vdev_id: vdev id
17998 * @len: length of buffer
17999 *
18000 * Return: 0 for success or error code
18001 */
18002static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
18003 uint8_t *evt_buf,
18004 uint32_t *vdev_id,
18005 uint32_t len)
18006{
18007 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
18008 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
18009
18010 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
18011 if (!param_tlvs) {
18012 WMI_LOGE("invalid cac complete event buf");
18013 return QDF_STATUS_E_FAILURE;
18014 }
18015
18016 cac_event = param_tlvs->fixed_param;
18017 *vdev_id = cac_event->vdev_id;
18018 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
18019
18020 return QDF_STATUS_SUCCESS;
18021}
18022
18023/**
18024 * extract_dfs_radar_detection_event_tlv() - extract radar found event
18025 * @wmi_handle: wma handle
18026 * @evt_buf: event buffer
18027 * @radar_found: radar found event info
18028 * @len: length of buffer
18029 *
18030 * Return: 0 for success or error code
18031 */
18032static QDF_STATUS extract_dfs_radar_detection_event_tlv(
18033 wmi_unified_t wmi_handle,
18034 uint8_t *evt_buf,
18035 struct radar_found_info *radar_found,
18036 uint32_t len)
18037{
18038 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
18039 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
18040
18041 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
18042 if (!param_tlv) {
18043 WMI_LOGE("invalid radar detection event buf");
18044 return QDF_STATUS_E_FAILURE;
18045 }
18046
18047 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018048 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18049 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018050 radar_found->detection_mode = radar_event->detection_mode;
18051 radar_found->freq_offset = radar_event->chan_freq;
18052 radar_found->chan_width = radar_event->chan_width;
18053 radar_found->detector_id = radar_event->detector_id;
18054 radar_found->segment_id = radar_event->segment_id;
18055 radar_found->timestamp = radar_event->timestamp;
18056 radar_found->is_chirp = radar_event->is_chirp;
18057
18058 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
18059
18060 return QDF_STATUS_SUCCESS;
18061}
18062#endif
18063
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018064/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018065 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
18066 * host to target defines. For legacy there is not conversion
18067 * required. Just return pdev_id as it is.
18068 * @param pdev_id: host pdev_id to be converted.
18069 * Return: target pdev_id after conversion.
18070 */
18071static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
18072 uint32_t pdev_id)
18073{
18074 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
18075 return WMI_PDEV_ID_SOC;
18076
18077 /*No conversion required*/
18078 return pdev_id;
18079}
18080
18081/**
18082 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
18083 * target to host defines. For legacy there is not conversion
18084 * required. Just return pdev_id as it is.
18085 * @param pdev_id: target pdev_id to be converted.
18086 * Return: host pdev_id after conversion.
18087 */
18088static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
18089 uint32_t pdev_id)
18090{
18091 /*No conversion required*/
18092 return pdev_id;
18093}
18094
18095/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018096 * send_set_country_cmd_tlv() - WMI scan channel list function
18097 * @param wmi_handle : handle to WMI.
18098 * @param param : pointer to hold scan channel list parameter
18099 *
18100 * Return: 0 on success and -ve on failure.
18101 */
18102static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
18103 struct set_country *params)
18104{
18105 wmi_buf_t buf;
18106 QDF_STATUS qdf_status;
18107 wmi_set_current_country_cmd_fixed_param *cmd;
18108 uint16_t len = sizeof(*cmd);
18109
18110 buf = wmi_buf_alloc(wmi_handle, len);
18111 if (!buf) {
18112 WMI_LOGE("Failed to allocate memory");
18113 qdf_status = QDF_STATUS_E_NOMEM;
18114 goto end;
18115 }
18116
18117 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
18118 WMITLV_SET_HDR(&cmd->tlv_header,
18119 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
18120 WMITLV_GET_STRUCT_TLVLEN
18121 (wmi_set_current_country_cmd_fixed_param));
18122
18123 WMI_LOGD("setting cuurnet country to %s", params->country);
18124
18125 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
18126
18127 cmd->pdev_id = params->pdev_id;
18128
18129 qdf_status = wmi_unified_cmd_send(wmi_handle,
18130 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18131
18132 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18133 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18134 wmi_buf_free(buf);
18135 }
18136
18137end:
18138 return qdf_status;
18139}
18140
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018141#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
18142 WMI_SET_BITS(alpha, 0, 8, val0); \
18143 WMI_SET_BITS(alpha, 8, 8, val1); \
18144 WMI_SET_BITS(alpha, 16, 8, val2); \
18145 } while (0)
18146
18147static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
18148 uint8_t pdev_id, struct cc_regdmn_s *rd)
18149{
18150 wmi_set_init_country_cmd_fixed_param *cmd;
18151 uint16_t len;
18152 wmi_buf_t buf;
18153 int ret;
18154
18155 len = sizeof(wmi_set_init_country_cmd_fixed_param);
18156 buf = wmi_buf_alloc(wmi_handle, len);
18157 if (!buf) {
18158 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
18159 return QDF_STATUS_E_NOMEM;
18160 }
18161 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
18162 WMITLV_SET_HDR(&cmd->tlv_header,
18163 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
18164 WMITLV_GET_STRUCT_TLVLEN
18165 (wmi_set_init_country_cmd_fixed_param));
18166
18167 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
18168
18169 if (rd->flags == CC_IS_SET) {
18170 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
18171 cmd->country_code.country_id = rd->cc.country_code;
18172 } else if (rd->flags == ALPHA_IS_SET) {
18173 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
18174 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
18175 rd->cc.alpha[0],
18176 rd->cc.alpha[1],
18177 rd->cc.alpha[2]);
18178 } else if (rd->flags == REGDMN_IS_SET) {
18179 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
18180 cmd->country_code.domain_code = rd->cc.regdmn_id;
18181 }
18182
18183 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
18184 WMI_SET_INIT_COUNTRY_CMDID);
18185 if (ret) {
18186 WMI_LOGE("Failed to config wow wakeup event");
18187 wmi_buf_free(buf);
18188 return QDF_STATUS_E_FAILURE;
18189 }
18190
18191 return QDF_STATUS_SUCCESS;
18192}
18193
Govind Singh5eb51532016-03-09 11:34:12 +053018194struct wmi_ops tlv_ops = {
18195 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18196 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18197 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018198 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18199 .send_hidden_ssid_vdev_restart_cmd =
18200 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018201 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18202 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18203 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018204 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018205 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018206 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018207 .send_peer_rx_reorder_queue_setup_cmd =
18208 send_peer_rx_reorder_queue_setup_cmd_tlv,
18209 .send_peer_rx_reorder_queue_remove_cmd =
18210 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018211 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18212 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18213 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018214 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18215 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18216 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18217 .send_suspend_cmd = send_suspend_cmd_tlv,
18218 .send_resume_cmd = send_resume_cmd_tlv,
18219 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18220 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18221 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18222 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18223 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18224 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18225 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18226 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
18227 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018228 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018229 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18230 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18231 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18232 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018233 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018234 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018235 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18236 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018237 .send_set_sta_uapsd_auto_trig_cmd =
18238 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018239 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18240 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18241 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018242#ifdef CONVERGED_P2P_ENABLE
18243 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18244 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18245#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018246 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18247 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018248 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18249 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18250 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18251 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18252 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18253 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18254 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018255 .send_ocb_start_timing_advert_cmd =
18256 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018257 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18258 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18259 .send_set_mcc_channel_time_latency_cmd =
18260 send_set_mcc_channel_time_latency_cmd_tlv,
18261 .send_set_mcc_channel_time_quota_cmd =
18262 send_set_mcc_channel_time_quota_cmd_tlv,
18263 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18264 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018265 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018266 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18267 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18268 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018269 .send_probe_rsp_tmpl_send_cmd =
18270 send_probe_rsp_tmpl_send_cmd_tlv,
18271 .send_p2p_go_set_beacon_ie_cmd =
18272 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018273 .send_setup_install_key_cmd =
18274 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018275 .send_set_gateway_params_cmd =
18276 send_set_gateway_params_cmd_tlv,
18277 .send_set_rssi_monitoring_cmd =
18278 send_set_rssi_monitoring_cmd_tlv,
18279 .send_scan_probe_setoui_cmd =
18280 send_scan_probe_setoui_cmd_tlv,
18281 .send_reset_passpoint_network_list_cmd =
18282 send_reset_passpoint_network_list_cmd_tlv,
18283 .send_set_passpoint_network_list_cmd =
18284 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018285 .send_roam_scan_offload_rssi_thresh_cmd =
18286 send_roam_scan_offload_rssi_thresh_cmd_tlv,
18287 .send_roam_scan_filter_cmd =
18288 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018289 .send_set_epno_network_list_cmd =
18290 send_set_epno_network_list_cmd_tlv,
18291 .send_ipa_offload_control_cmd =
18292 send_ipa_offload_control_cmd_tlv,
18293 .send_extscan_get_capabilities_cmd =
18294 send_extscan_get_capabilities_cmd_tlv,
18295 .send_extscan_get_cached_results_cmd =
18296 send_extscan_get_cached_results_cmd_tlv,
18297 .send_extscan_stop_change_monitor_cmd =
18298 send_extscan_stop_change_monitor_cmd_tlv,
18299 .send_extscan_start_change_monitor_cmd =
18300 send_extscan_start_change_monitor_cmd_tlv,
18301 .send_extscan_stop_hotlist_monitor_cmd =
18302 send_extscan_stop_hotlist_monitor_cmd_tlv,
18303 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18304 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18305 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18306 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18307 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18308 .send_pno_start_cmd = send_pno_start_cmd_tlv,
18309 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18310 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18311 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18312 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18313 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018314 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018315 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18316 .send_snr_cmd = send_snr_cmd_tlv,
18317 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018318#ifdef WLAN_PMO_ENABLE
18319 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18320 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18321 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18322 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018323 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018324 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18325 .send_process_gtk_offload_getinfo_cmd =
18326 send_process_gtk_offload_getinfo_cmd_tlv,
18327 .send_enable_enhance_multicast_offload_cmd =
18328 send_enable_enhance_multicast_offload_tlv,
18329 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18330#ifdef FEATURE_WLAN_RA_FILTERING
18331 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18332#endif
18333 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018334 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18335 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018336 .send_lphb_config_tcp_pkt_filter_cmd =
18337 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018338 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18339 .send_lphb_config_udp_pkt_filter_cmd =
18340 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018341 .send_enable_disable_packet_filter_cmd =
18342 send_enable_disable_packet_filter_cmd_tlv,
18343 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018344#endif /* End of WLAN_PMO_ENABLE */
18345#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018346 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18347 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18348 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018349 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
18350 .send_process_update_edca_param_cmd =
18351 send_process_update_edca_param_cmd_tlv,
18352 .send_roam_scan_offload_mode_cmd =
18353 send_roam_scan_offload_mode_cmd_tlv,
18354 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18355 .send_roam_scan_offload_ap_profile_cmd =
18356 send_roam_scan_offload_ap_profile_cmd_tlv,
18357#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018358 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18359 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018360 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18361 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018362#ifdef WLAN_FEATURE_CIF_CFR
18363 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18364#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018365 .send_dfs_phyerr_filter_offload_en_cmd =
18366 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018367 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18368 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18369 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18370 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18371 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018372 .send_process_add_periodic_tx_ptrn_cmd =
18373 send_process_add_periodic_tx_ptrn_cmd_tlv,
18374 .send_process_del_periodic_tx_ptrn_cmd =
18375 send_process_del_periodic_tx_ptrn_cmd_tlv,
18376 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18377 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18378 .send_set_app_type2_params_in_fw_cmd =
18379 send_set_app_type2_params_in_fw_cmd_tlv,
18380 .send_set_auto_shutdown_timer_cmd =
18381 send_set_auto_shutdown_timer_cmd_tlv,
18382 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18383 .send_process_dhcpserver_offload_cmd =
18384 send_process_dhcpserver_offload_cmd_tlv,
18385 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18386 .send_process_ch_avoid_update_cmd =
18387 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018388 .send_pdev_set_regdomain_cmd =
18389 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018390 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18391 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18392 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18393 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18394 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18395 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018396#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018397 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018398#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018399 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018400 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018401 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018402 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018403 .send_set_base_macaddr_indicate_cmd =
18404 send_set_base_macaddr_indicate_cmd_tlv,
18405 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18406 .send_enable_specific_fw_logs_cmd =
18407 send_enable_specific_fw_logs_cmd_tlv,
18408 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018409 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018410 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018411 .send_pdev_set_dual_mac_config_cmd =
18412 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018413 .send_app_type1_params_in_fw_cmd =
18414 send_app_type1_params_in_fw_cmd_tlv,
18415 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18416 .send_process_roam_synch_complete_cmd =
18417 send_process_roam_synch_complete_cmd_tlv,
18418 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18419 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18420 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018421 .send_roam_scan_offload_scan_period_cmd =
18422 send_roam_scan_offload_scan_period_cmd_tlv,
18423 .send_roam_scan_offload_chan_list_cmd =
18424 send_roam_scan_offload_chan_list_cmd_tlv,
18425 .send_roam_scan_offload_rssi_change_cmd =
18426 send_roam_scan_offload_rssi_change_cmd_tlv,
18427 .send_get_buf_extscan_hotlist_cmd =
18428 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018429 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018430 .send_adapt_dwelltime_params_cmd =
18431 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018432 .send_dbs_scan_sel_params_cmd =
18433 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018434 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018435 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18436 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18437 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18438 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18439 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18440 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18441 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18442 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18443 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018444 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18445 .send_smart_ant_set_training_info_cmd =
18446 send_smart_ant_set_training_info_cmd_tlv,
18447 .send_smart_ant_set_node_config_cmd =
18448 send_smart_ant_set_node_config_cmd_tlv,
18449 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18450 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18451 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018452 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18453 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18454 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18455 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18456 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18457 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18458 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018459 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18460 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18461 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18462 .send_vdev_spectral_configure_cmd =
18463 send_vdev_spectral_configure_cmd_tlv,
18464 .send_vdev_spectral_enable_cmd =
18465 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018466 .send_thermal_mitigation_param_cmd =
18467 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018468 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18469 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018470 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018471 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018472 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18473 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18474 .extract_host_mem_req = extract_host_mem_req_tlv,
18475 .save_service_bitmap = save_service_bitmap_tlv,
18476 .is_service_enabled = is_service_enabled_tlv,
18477 .save_fw_version = save_fw_version_in_service_ready_tlv,
18478 .ready_extract_init_status = ready_extract_init_status_tlv,
18479 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
18480 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18481 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18482 .extract_tbttoffset_update_params =
18483 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018484 .extract_ext_tbttoffset_update_params =
18485 extract_ext_tbttoffset_update_params_tlv,
18486 .extract_tbttoffset_num_vdevs =
18487 extract_tbttoffset_num_vdevs_tlv,
18488 .extract_ext_tbttoffset_num_vdevs =
18489 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018490 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18491 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18492 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18493 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018494#ifdef CONVERGED_TDLS_ENABLE
18495 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18496#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018497 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018498 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018499 .extract_swba_tim_info = extract_swba_tim_info_tlv,
18500 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018501#ifdef CONVERGED_P2P_ENABLE
18502 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
18503 .extract_p2p_lo_stop_ev_param =
18504 extract_p2p_lo_stop_ev_param_tlv,
18505#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018506 .extract_offchan_data_tx_compl_param =
18507 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018508 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
18509 .extract_all_stats_count = extract_all_stats_counts_tlv,
18510 .extract_pdev_stats = extract_pdev_stats_tlv,
18511 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
18512 .extract_vdev_stats = extract_vdev_stats_tlv,
18513 .extract_peer_stats = extract_peer_stats_tlv,
18514 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
18515 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
18516 .extract_chan_stats = extract_chan_stats_tlv,
18517 .extract_profile_ctx = extract_profile_ctx_tlv,
18518 .extract_profile_data = extract_profile_data_tlv,
18519 .extract_chan_info_event = extract_chan_info_event_tlv,
18520 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053018521 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053018522 .send_encrypt_decrypt_send_cmd =
18523 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080018524 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053018525 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018526 .send_multiple_vdev_restart_req_cmd =
18527 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053018528 .extract_service_ready_ext = extract_service_ready_ext_tlv,
18529 .extract_hw_mode_cap_service_ready_ext =
18530 extract_hw_mode_cap_service_ready_ext_tlv,
18531 .extract_mac_phy_cap_service_ready_ext =
18532 extract_mac_phy_cap_service_ready_ext_tlv,
18533 .extract_reg_cap_service_ready_ext =
18534 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018535 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053018536 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018537 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
18538 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
18539 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053018540 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018541 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018542 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018543 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018544 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018545 .extract_pdev_csa_switch_count_status =
18546 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053018547 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
18548 .extract_wds_addr_event = extract_wds_addr_event_tlv,
18549 .extract_peer_sta_ps_statechange_ev =
18550 extract_peer_sta_ps_statechange_ev_tlv,
18551 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053018552 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080018553 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
18554 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018555 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018556 extract_reg_chan_list_update_event_tlv,
18557 .extract_chainmask_tables =
18558 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018559 .extract_thermal_stats = extract_thermal_stats_tlv,
18560 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018561#ifdef DFS_COMPONENT_ENABLE
18562 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
18563 .extract_dfs_radar_detection_event =
18564 extract_dfs_radar_detection_event_tlv,
18565#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018566 .convert_pdev_id_host_to_target =
18567 convert_host_pdev_id_to_target_pdev_id_legacy,
18568 .convert_pdev_id_target_to_host =
18569 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018570
18571 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
18572 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
18573 .extract_reg_11d_new_country_event =
18574 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018575 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018576};
18577
Govind Singhe7f2f342016-05-23 12:12:52 +053018578/**
18579 * populate_tlv_event_id() - populates wmi event ids
18580 *
18581 * @param event_ids: Pointer to hold event ids
18582 * Return: None
18583 */
18584static void populate_tlv_events_id(uint32_t *event_ids)
18585{
18586 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
18587 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
18588 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
18589 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18590 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
18591 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
18592 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
18593 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
18594 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
18595 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
18596 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
18597 event_ids[wmi_service_ready_ext_event_id] =
18598 WMI_SERVICE_READY_EXT_EVENTID;
18599 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
18600 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
18601 event_ids[wmi_vdev_install_key_complete_event_id] =
18602 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
18603 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
18604 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
18605
18606 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
18607 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
18608 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
18609 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
18610 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
18611 event_ids[wmi_peer_estimated_linkspeed_event_id] =
18612 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
18613 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018614 event_ids[wmi_peer_delete_response_event_id] =
18615 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018616 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
18617 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
18618 event_ids[wmi_tbttoffset_update_event_id] =
18619 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018620 event_ids[wmi_ext_tbttoffset_update_event_id] =
18621 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018622 event_ids[wmi_offload_bcn_tx_status_event_id] =
18623 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
18624 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
18625 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
18626 event_ids[wmi_mgmt_tx_completion_event_id] =
18627 WMI_MGMT_TX_COMPLETION_EVENTID;
18628
18629 event_ids[wmi_tx_delba_complete_event_id] =
18630 WMI_TX_DELBA_COMPLETE_EVENTID;
18631 event_ids[wmi_tx_addba_complete_event_id] =
18632 WMI_TX_ADDBA_COMPLETE_EVENTID;
18633 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
18634
18635 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
18636
18637 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
18638 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
18639
18640 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
18641
18642 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
18643
18644 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080018645 event_ids[wmi_p2p_lo_stop_event_id] =
18646 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018647 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
18648 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
18649 event_ids[wmi_do_wow_disable_ack_event_id] =
18650 WMI_D0_WOW_DISABLE_ACK_EVENTID;
18651 event_ids[wmi_wow_initial_wakeup_event_id] =
18652 WMI_WOW_INITIAL_WAKEUP_EVENTID;
18653
18654 event_ids[wmi_rtt_meas_report_event_id] =
18655 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
18656 event_ids[wmi_tsf_meas_report_event_id] =
18657 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
18658 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
18659 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
18660 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
18661 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
18662 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
18663 event_ids[wmi_update_fw_mem_dump_event_id] =
18664 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
18665 event_ids[wmi_diag_event_id_log_supported_event_id] =
18666 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
18667 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
18668 event_ids[wmi_nlo_scan_complete_event_id] =
18669 WMI_NLO_SCAN_COMPLETE_EVENTID;
18670 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
18671 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
18672
18673 event_ids[wmi_gtk_offload_status_event_id] =
18674 WMI_GTK_OFFLOAD_STATUS_EVENTID;
18675 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
18676 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
18677 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
18678
18679 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
18680
18681 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
18682
18683 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
18684 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
18685 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
18686 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
18687 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
18688 event_ids[wmi_wlan_profile_data_event_id] =
18689 WMI_WLAN_PROFILE_DATA_EVENTID;
18690 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
18691 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
18692 event_ids[wmi_vdev_get_keepalive_event_id] =
18693 WMI_VDEV_GET_KEEPALIVE_EVENTID;
18694 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
18695
18696 event_ids[wmi_diag_container_event_id] =
18697 WMI_DIAG_DATA_CONTAINER_EVENTID;
18698
18699 event_ids[wmi_host_auto_shutdown_event_id] =
18700 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
18701
18702 event_ids[wmi_update_whal_mib_stats_event_id] =
18703 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
18704
18705 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
18706 event_ids[wmi_update_vdev_rate_stats_event_id] =
18707 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
18708
18709 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
18710
18711 /** Set OCB Sched Response, deprecated */
18712 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
18713
18714 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
18715 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
18716 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
18717
18718 /* GPIO Event */
18719 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
18720 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
18721
18722 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
18723 event_ids[wmi_rfkill_state_change_event_id] =
18724 WMI_RFKILL_STATE_CHANGE_EVENTID;
18725
18726 /* TDLS Event */
18727 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
18728
18729 event_ids[wmi_batch_scan_enabled_event_id] =
18730 WMI_BATCH_SCAN_ENABLED_EVENTID;
18731 event_ids[wmi_batch_scan_result_event_id] =
18732 WMI_BATCH_SCAN_RESULT_EVENTID;
18733 /* OEM Event */
18734 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
18735 event_ids[wmi_oem_meas_report_event_id] =
18736 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
18737 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
18738
18739 /* NAN Event */
18740 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
18741
18742 /* LPI Event */
18743 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
18744 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
18745 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
18746
18747 /* ExtScan events */
18748 event_ids[wmi_extscan_start_stop_event_id] =
18749 WMI_EXTSCAN_START_STOP_EVENTID;
18750 event_ids[wmi_extscan_operation_event_id] =
18751 WMI_EXTSCAN_OPERATION_EVENTID;
18752 event_ids[wmi_extscan_table_usage_event_id] =
18753 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
18754 event_ids[wmi_extscan_cached_results_event_id] =
18755 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
18756 event_ids[wmi_extscan_wlan_change_results_event_id] =
18757 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
18758 event_ids[wmi_extscan_hotlist_match_event_id] =
18759 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
18760 event_ids[wmi_extscan_capabilities_event_id] =
18761 WMI_EXTSCAN_CAPABILITIES_EVENTID;
18762 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
18763 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
18764
18765 /* mDNS offload events */
18766 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
18767
18768 /* SAP Authentication offload events */
18769 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
18770 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
18771
18772 /** Out-of-context-of-bss (OCB) events */
18773 event_ids[wmi_ocb_set_config_resp_event_id] =
18774 WMI_OCB_SET_CONFIG_RESP_EVENTID;
18775 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
18776 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
18777 event_ids[wmi_dcc_get_stats_resp_event_id] =
18778 WMI_DCC_GET_STATS_RESP_EVENTID;
18779 event_ids[wmi_dcc_update_ndl_resp_event_id] =
18780 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
18781 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
18782 /* System-On-Chip events */
18783 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
18784 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
18785 event_ids[wmi_soc_hw_mode_transition_event_id] =
18786 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
18787 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
18788 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018789 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053018790 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
18791 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018792 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053018793 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
18794 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18795 event_ids[wmi_peer_sta_ps_statechg_event_id] =
18796 WMI_PEER_STA_PS_STATECHG_EVENTID;
18797 event_ids[wmi_pdev_channel_hopping_event_id] =
18798 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018799 event_ids[wmi_offchan_data_tx_completion_event] =
18800 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018801 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
18802 event_ids[wmi_dfs_radar_detection_event_id] =
18803 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018804 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070018805 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018806}
18807
Soumya Bhat488092d2017-03-22 14:41:01 +053018808#ifndef CONFIG_MCL
18809/**
18810 * populate_tlv_service() - populates wmi services
18811 *
18812 * @param wmi_service: Pointer to hold wmi_service
18813 * Return: None
18814 */
18815static void populate_tlv_service(uint32_t *wmi_service)
18816{
18817 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
18818 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
18819 wmi_service[wmi_service_roam_scan_offload] =
18820 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
18821 wmi_service[wmi_service_bcn_miss_offload] =
18822 WMI_SERVICE_BCN_MISS_OFFLOAD;
18823 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
18824 wmi_service[wmi_service_sta_advanced_pwrsave] =
18825 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
18826 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
18827 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
18828 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
18829 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
18830 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
18831 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
18832 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
18833 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
18834 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
18835 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
18836 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
18837 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
18838 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
18839 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
18840 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
18841 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
18842 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
18843 wmi_service[wmi_service_packet_power_save] =
18844 WMI_SERVICE_PACKET_POWER_SAVE;
18845 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
18846 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
18847 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
18848 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
18849 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
18850 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
18851 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
18852 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
18853 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
18854 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
18855 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
18856 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
18857 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
18858 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
18859 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
18860 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
18861 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
18862 wmi_service[wmi_service_mcc_bcn_interval_change] =
18863 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
18864 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
18865 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
18866 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
18867 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
18868 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
18869 wmi_service[wmi_service_lte_ant_share_support] =
18870 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
18871 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
18872 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
18873 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
18874 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
18875 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
18876 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
18877 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
18878 wmi_service[wmi_service_bcn_txrate_override] =
18879 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
18880 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
18881 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
18882 wmi_service[wmi_service_estimate_linkspeed] =
18883 WMI_SERVICE_ESTIMATE_LINKSPEED;
18884 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
18885 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
18886 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
18887 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
18888 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
18889 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
18890 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
18891 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
18892 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
18893 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
18894 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
18895 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
18896 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
18897 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
18898 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
18899 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
18900 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
18901 wmi_service[wmi_service_sap_auth_offload] =
18902 WMI_SERVICE_SAP_AUTH_OFFLOAD;
18903 wmi_service[wmi_service_dual_band_simultaneous_support] =
18904 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
18905 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
18906 wmi_service[wmi_service_ap_arpns_offload] =
18907 WMI_SERVICE_AP_ARPNS_OFFLOAD;
18908 wmi_service[wmi_service_per_band_chainmask_support] =
18909 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
18910 wmi_service[wmi_service_packet_filter_offload] =
18911 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
18912 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
18913 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
18914 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
18915 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
18916 wmi_service[wmi_service_multiple_vdev_restart] =
18917 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
18918
18919 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
18920 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
18921 wmi_service[wmi_service_smart_antenna_sw_support] =
18922 WMI_SERVICE_UNAVAILABLE;
18923 wmi_service[wmi_service_smart_antenna_hw_support] =
18924 WMI_SERVICE_UNAVAILABLE;
18925 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
18926 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018927 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053018928 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
18929 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
18930 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
18931 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
18932 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
18933 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
18934 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
18935 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053018936 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
18937 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
18938 wmi_service[wmi_service_periodic_chan_stat_support] =
18939 WMI_SERVICE_UNAVAILABLE;
18940 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
18941 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
18942 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
18943 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
18944 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
18945 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053018946 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
18947 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
18948 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
18949 wmi_service[wmi_service_unified_wow_capability] =
18950 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
18951 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
18952 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
18953 wmi_service[wmi_service_sync_delete_cmds] =
18954 WMI_SERVICE_SYNC_DELETE_CMDS;
18955 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
18956 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
18957 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
18958 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
18959 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
18960 wmi_service[wmi_service_deprecated_replace] =
18961 WMI_SERVICE_DEPRECATED_REPLACE;
18962 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
18963 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
18964 wmi_service[wmi_service_enhanced_mcast_filter] =
18965 WMI_SERVICE_ENHANCED_MCAST_FILTER;
18966 wmi_service[wmi_service_half_rate_quarter_rate_support] =
18967 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
18968 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
18969 wmi_service[wmi_service_p2p_listen_offload_support] =
18970 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
18971 wmi_service[wmi_service_mark_first_wakeup_packet] =
18972 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
18973 wmi_service[wmi_service_multiple_mcast_filter_set] =
18974 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
18975 wmi_service[wmi_service_host_managed_rx_reorder] =
18976 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
18977 wmi_service[wmi_service_flash_rdwr_support] =
18978 WMI_SERVICE_FLASH_RDWR_SUPPORT;
18979 wmi_service[wmi_service_wlan_stats_report] =
18980 WMI_SERVICE_WLAN_STATS_REPORT;
18981 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
18982 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
18983 wmi_service[wmi_service_dfs_phyerr_offload] =
18984 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
18985 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
18986 wmi_service[wmi_service_fw_mem_dump_support] =
18987 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
18988 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
18989 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
18990 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
18991 wmi_service[wmi_service_hw_data_filtering] =
18992 WMI_SERVICE_HW_DATA_FILTERING;
18993 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
18994 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053018995 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat488092d2017-03-22 14:41:01 +053018996}
18997
Govind Singhe7f2f342016-05-23 12:12:52 +053018998/**
18999 * populate_pdev_param_tlv() - populates pdev params
19000 *
19001 * @param pdev_param: Pointer to hold pdev params
19002 * Return: None
19003 */
19004static void populate_pdev_param_tlv(uint32_t *pdev_param)
19005{
19006 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
19007 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
19008 pdev_param[wmi_pdev_param_txpower_limit2g] =
19009 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
19010 pdev_param[wmi_pdev_param_txpower_limit5g] =
19011 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
19012 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
19013 pdev_param[wmi_pdev_param_beacon_gen_mode] =
19014 WMI_PDEV_PARAM_BEACON_GEN_MODE;
19015 pdev_param[wmi_pdev_param_beacon_tx_mode] =
19016 WMI_PDEV_PARAM_BEACON_TX_MODE;
19017 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
19018 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
19019 pdev_param[wmi_pdev_param_protection_mode] =
19020 WMI_PDEV_PARAM_PROTECTION_MODE;
19021 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
19022 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
19023 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
19024 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
19025 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
19026 pdev_param[wmi_pdev_param_sta_kickout_th] =
19027 WMI_PDEV_PARAM_STA_KICKOUT_TH;
19028 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
19029 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
19030 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
19031 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
19032 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
19033 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
19034 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
19035 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
19036 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
19037 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
19038 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
19039 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
19040 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
19041 pdev_param[wmi_pdev_param_ltr_sleep_override] =
19042 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
19043 pdev_param[wmi_pdev_param_ltr_rx_override] =
19044 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
19045 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
19046 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
19047 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
19048 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
19049 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
19050 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
19051 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
19052 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
19053 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
19054 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
19055 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
19056 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
19057 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
19058 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
19059 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
19060 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
19061 pdev_param[wmi_pdev_param_peer_stats_update_period] =
19062 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
19063 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
19064 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
19065 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
19066 pdev_param[wmi_pdev_param_arp_ac_override] =
19067 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
19068 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
19069 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
19070 pdev_param[wmi_pdev_param_ani_poll_period] =
19071 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
19072 pdev_param[wmi_pdev_param_ani_listen_period] =
19073 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
19074 pdev_param[wmi_pdev_param_ani_ofdm_level] =
19075 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
19076 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
19077 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
19078 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
19079 pdev_param[wmi_pdev_param_idle_ps_config] =
19080 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
19081 pdev_param[wmi_pdev_param_power_gating_sleep] =
19082 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
19083 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
19084 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
19085 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
19086 pdev_param[wmi_pdev_param_hw_rfkill_config] =
19087 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
19088 pdev_param[wmi_pdev_param_low_power_rf_enable] =
19089 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
19090 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
19091 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
19092 pdev_param[wmi_pdev_param_power_collapse_enable] =
19093 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
19094 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
19095 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
19096 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
19097 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
19098 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
19099 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
19100 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
19101 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
19102 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
19103 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
19104 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
19105 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
19106 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
19107 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
19108 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
19109 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
19110 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
19111 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
19112 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
19113 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
19114 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
19115 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
19116 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
19117 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
19118 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
19119 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
19120 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
19121 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
19122 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
19123 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
19124 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
19125 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
19126 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
19127 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
19128 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
19129 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
19130 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
19131 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
19132 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
19133 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
19134 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
19135 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
19136 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
19137 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
19138 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
19139 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumard99852a2017-07-08 12:32:27 +053019140 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
19141 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053019142 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
19143 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
19144 WMI_UNAVAILABLE_PARAM;
19145 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
19146 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
19147 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
19148 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
19149 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
19150 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019151 pdev_param[wmi_pdev_param_atf_strict_sch] =
19152 WMI_PDEV_PARAM_ATF_STRICT_SCH;
19153 pdev_param[wmi_pdev_param_atf_sched_duration] =
19154 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053019155 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
19156 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
19157 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
19158 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
19159 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
19160 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
19161 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
19162 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
19163 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
19164 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
19165 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
19166 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
19167 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
19168 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
19169 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
19170 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019171 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
19172 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053019173 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019174 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053019175 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019176 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
19177 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019178 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
19179 WMI_UNAVAILABLE_PARAM;
19180 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
19181 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
19182 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
19183 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
19184 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
19185 WMI_UNAVAILABLE_PARAM;
19186 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
19187 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
19188 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019189 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19190 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019191 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019192 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19193 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019194 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19195 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19196 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19197 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19198 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19199 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19200 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19201 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19202 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19203 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19204 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19205 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19206 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19207 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19208 pdev_param[wmi_pdev_param_fast_channel_reset] =
19209 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19210 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019211}
19212
19213/**
19214 * populate_vdev_param_tlv() - populates vdev params
19215 *
19216 * @param vdev_param: Pointer to hold vdev params
19217 * Return: None
19218 */
19219static void populate_vdev_param_tlv(uint32_t *vdev_param)
19220{
19221 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19222 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19223 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19224 vdev_param[wmi_vdev_param_beacon_interval] =
19225 WMI_VDEV_PARAM_BEACON_INTERVAL;
19226 vdev_param[wmi_vdev_param_listen_interval] =
19227 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19228 vdev_param[wmi_vdev_param_multicast_rate] =
19229 WMI_VDEV_PARAM_MULTICAST_RATE;
19230 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19231 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19232 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19233 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19234 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19235 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19236 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19237 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19238 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19239 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19240 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19241 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19242 vdev_param[wmi_vdev_param_bmiss_count_max] =
19243 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19244 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19245 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19246 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19247 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19248 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19249 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19250 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19251 vdev_param[wmi_vdev_param_disable_htprotection] =
19252 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19253 vdev_param[wmi_vdev_param_sta_quickkickout] =
19254 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19255 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19256 vdev_param[wmi_vdev_param_protection_mode] =
19257 WMI_VDEV_PARAM_PROTECTION_MODE;
19258 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19259 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19260 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19261 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19262 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19263 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19264 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19265 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19266 vdev_param[wmi_vdev_param_bcast_data_rate] =
19267 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19268 vdev_param[wmi_vdev_param_mcast_data_rate] =
19269 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19270 vdev_param[wmi_vdev_param_mcast_indicate] =
19271 WMI_VDEV_PARAM_MCAST_INDICATE;
19272 vdev_param[wmi_vdev_param_dhcp_indicate] =
19273 WMI_VDEV_PARAM_DHCP_INDICATE;
19274 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19275 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19276 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19277 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19278 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19279 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19280 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19281 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19282 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19283 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19284 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19285 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19286 vdev_param[wmi_vdev_param_packet_powersave] =
19287 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19288 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19289 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19290 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19291 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19292 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19293 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19294 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19295 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19296 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19297 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19298 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19299 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19300 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19301 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19302 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19303 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19304 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19305 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19306 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19307 vdev_param[wmi_vdev_param_roam_fw_offload] =
19308 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19309 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19310 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19311 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19312 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19313 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19314 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19315 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19316 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19317 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19318 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19319 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19320 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19321 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19322 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19323 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19324 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19325 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19326 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19327 vdev_param[wmi_vdev_param_inactivity_cnt] =
19328 WMI_VDEV_PARAM_INACTIVITY_CNT;
19329 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19330 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19331 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19332 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19333 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19334 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19335 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19336 vdev_param[wmi_vdev_param_rx_leak_window] =
19337 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19338 vdev_param[wmi_vdev_param_stats_avg_factor] =
19339 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19340 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19341 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19342 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19343 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19344 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19345 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019346 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19347 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019348 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019349 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19350 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19351 WMI_VDEV_PARAM_HE_RANGE_EXT;
19352 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19353 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019354 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19355 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19356 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19357 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19358 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19359 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19360 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019361 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19362 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19363 vdev_param[wmi_vdev_param_rc_num_retries] =
19364 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19365 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19366 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19367 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19368 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19369 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19370 vdev_param[wmi_vdev_param_vht80_ratemask] =
19371 WMI_VDEV_PARAM_VHT80_RATEMASK;
19372 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19373 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19374 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019375}
19376#endif
19377
Govind Singh5eb51532016-03-09 11:34:12 +053019378/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019379 * populate_target_defines_tlv() - Populate target defines and params
19380 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019381 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019382 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019383 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019384#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019385static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019386{
Govind Singhe7f2f342016-05-23 12:12:52 +053019387 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019388 populate_pdev_param_tlv(wmi_handle->pdev_param);
19389 populate_vdev_param_tlv(wmi_handle->vdev_param);
19390}
19391#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019392static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19393{ }
19394#endif
19395
19396/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019397 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19398 * host to target defines.
19399 * @param pdev_id: host pdev_id to be converted.
19400 * Return: target pdev_id after conversion.
19401 */
19402static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19403{
19404 switch (pdev_id) {
19405 case WMI_HOST_PDEV_ID_SOC:
19406 return WMI_PDEV_ID_SOC;
19407 case WMI_HOST_PDEV_ID_0:
19408 return WMI_PDEV_ID_1ST;
19409 case WMI_HOST_PDEV_ID_1:
19410 return WMI_PDEV_ID_2ND;
19411 case WMI_HOST_PDEV_ID_2:
19412 return WMI_PDEV_ID_3RD;
19413 }
19414
19415 QDF_ASSERT(0);
19416
19417 return WMI_PDEV_ID_SOC;
19418}
19419
19420/**
19421 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19422 * target to host defines.
19423 * @param pdev_id: target pdev_id to be converted.
19424 * Return: host pdev_id after conversion.
19425 */
19426static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19427{
19428 switch (pdev_id) {
19429 case WMI_PDEV_ID_SOC:
19430 return WMI_HOST_PDEV_ID_SOC;
19431 case WMI_PDEV_ID_1ST:
19432 return WMI_HOST_PDEV_ID_0;
19433 case WMI_PDEV_ID_2ND:
19434 return WMI_HOST_PDEV_ID_1;
19435 case WMI_PDEV_ID_3RD:
19436 return WMI_HOST_PDEV_ID_2;
19437 }
19438
19439 QDF_ASSERT(0);
19440
19441 return WMI_HOST_PDEV_ID_SOC;
19442}
19443
19444/**
19445 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19446 *
19447 * Return None.
19448 */
19449void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19450{
19451 wmi_handle->ops->convert_pdev_id_host_to_target =
19452 convert_host_pdev_id_to_target_pdev_id;
19453 wmi_handle->ops->convert_pdev_id_target_to_host =
19454 convert_target_pdev_id_to_host_pdev_id;
19455}
19456/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019457 * wmi_tlv_attach() - Attach TLV APIs
19458 *
19459 * Return: None
19460 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019461void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019462{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019463 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019464#ifdef WMI_INTERFACE_EVENT_LOGGING
19465 wmi_handle->log_info.buf_offset_command = 2;
19466 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019467#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019468 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019469 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019470}