blob: 621369f24d80fdd0ad60c0f0a2386573fd13439f [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));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800379 WMI_LOGA("%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
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301836 /*
1837 * Suppress authorization for all AUTH modes that need 4-way handshake
1838 * (during re-association).
1839 * Authorization will be done for these modes on key installation.
1840 */
1841 if (param->auth_flag)
1842 cmd->peer_flags |= WMI_PEER_AUTH;
1843 if (param->need_ptk_4_way)
1844 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1845 else
1846 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1847 if (param->need_gtk_2_way)
1848 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1849 /* safe mode bypass the 4-way handshake */
1850 if (param->safe_mode_enabled)
1851 cmd->peer_flags &=
1852 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1853 /* Disable AMSDU for station transmit, if user configures it */
1854 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1855 * it
1856 * if (param->amsdu_disable) Add after FW support
1857 **/
1858
1859 /* Target asserts if node is marked HT and all MCS is set to 0.
1860 * Mark the node as non-HT if all the mcs rates are disabled through
1861 * iwpriv
1862 **/
1863 if (param->peer_ht_rates.num_rates == 0)
1864 cmd->peer_flags &= ~WMI_PEER_HT;
1865}
1866#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301867
1868#ifdef CONFIG_MCL
1869static inline void copy_peer_mac_addr_tlv(
1870 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1871 struct peer_assoc_params *param)
1872{
1873 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1874 sizeof(param->peer_macaddr));
1875}
1876#else
1877static inline void copy_peer_mac_addr_tlv(
1878 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1879 struct peer_assoc_params *param)
1880{
1881 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1882}
1883#endif
1884
Govind Singh5eb51532016-03-09 11:34:12 +05301885/**
1886 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1887 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301888 * @param param : pointer to peer assoc parameter
1889 *
1890 * Return: 0 on success and -ve on failure.
1891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301892static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301893 struct peer_assoc_params *param)
1894{
Govind Singhd3156eb2016-02-26 17:50:39 +05301895 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1896 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001897 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301898 wmi_buf_t buf;
1899 int32_t len;
1900 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301901 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301902 uint32_t peer_legacy_rates_align;
1903 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001904 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301905
1906
1907 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1908 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301909
1910 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001911 (peer_legacy_rates_align * sizeof(uint8_t)) +
1912 WMI_TLV_HDR_SIZE +
1913 (peer_ht_rates_align * sizeof(uint8_t)) +
1914 sizeof(wmi_vht_rate_set) +
1915 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1916 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301917
1918 buf = wmi_buf_alloc(wmi_handle, len);
1919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301920 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301921 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301922 }
1923
1924 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1925 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1926 WMITLV_SET_HDR(&cmd->tlv_header,
1927 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1928 WMITLV_GET_STRUCT_TLVLEN
1929 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301930
Govind Singhd3156eb2016-02-26 17:50:39 +05301931 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301932
Govind Singhd3156eb2016-02-26 17:50:39 +05301933 cmd->peer_new_assoc = param->peer_new_assoc;
1934 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301935
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301936 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301937 copy_peer_mac_addr_tlv(cmd, param);
1938
Govind Singhd3156eb2016-02-26 17:50:39 +05301939 cmd->peer_rate_caps = param->peer_rate_caps;
1940 cmd->peer_caps = param->peer_caps;
1941 cmd->peer_listen_intval = param->peer_listen_intval;
1942 cmd->peer_ht_caps = param->peer_ht_caps;
1943 cmd->peer_max_mpdu = param->peer_max_mpdu;
1944 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301945 cmd->peer_vht_caps = param->peer_vht_caps;
1946 cmd->peer_phymode = param->peer_phymode;
1947
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001948 /* Update 11ax capabilities */
1949 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1950 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001951 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1952 sizeof(param->peer_he_cap_phyinfo));
1953 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1954 sizeof(param->peer_ppet));
1955
Govind Singhd3156eb2016-02-26 17:50:39 +05301956 /* Update peer legacy rate information */
1957 buf_ptr += sizeof(*cmd);
1958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301959 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301960 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301961 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301962 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301963 param->peer_legacy_rates.num_rates);
1964
1965 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001966 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301968 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301970 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301971 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301972 param->peer_ht_rates.num_rates);
1973
1974 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001975 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301976 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1977 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1978
1979 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301980
1981 /* Update bandwidth-NSS mapping */
1982 cmd->peer_bw_rxnss_override = 0;
1983 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1984
Govind Singhd3156eb2016-02-26 17:50:39 +05301985 mcs = (wmi_vht_rate_set *) buf_ptr;
1986 if (param->vht_capable) {
1987 mcs->rx_max_rate = param->rx_max_rate;
1988 mcs->rx_mcs_set = param->rx_mcs_set;
1989 mcs->tx_max_rate = param->tx_max_rate;
1990 mcs->tx_mcs_set = param->tx_mcs_set;
1991 }
1992
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001993 /* HE Rates */
1994 cmd->peer_he_mcs = param->peer_he_mcs_count;
1995 buf_ptr += sizeof(wmi_vht_rate_set);
1996 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1997 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
1998 buf_ptr += WMI_TLV_HDR_SIZE;
1999
2000 /* Loop through the HE rate set */
2001 for (i = 0; i < param->peer_he_mcs_count; i++) {
2002 he_mcs = (wmi_he_rate_set *) buf_ptr;
2003 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2004 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2005
2006 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2007 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2008 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2009 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2010 buf_ptr += sizeof(wmi_he_rate_set);
2011 }
2012
2013
Govind Singhb53420c2016-03-09 14:32:57 +05302014 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302015 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2016 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002017 "cmd->peer_vht_caps %x "
2018 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302019 "HE phy %x %x %x "
2020 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302021 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2022 cmd->peer_rate_caps, cmd->peer_caps,
2023 cmd->peer_listen_intval, cmd->peer_ht_caps,
2024 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2025 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002026 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2027 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302028 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2029 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302030
2031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2032 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302033 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302034 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302035 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302036 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 }
2038
2039 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302040}
2041
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302042/* copy_scan_notify_events() - Helper routine to copy scan notify events
2043 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302044static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302045 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302046 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302047{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302048
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302049 /* Scan events subscription */
2050 if (param->scan_ev_started)
2051 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2052 if (param->scan_ev_completed)
2053 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2054 if (param->scan_ev_bss_chan)
2055 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2056 if (param->scan_ev_foreign_chan)
2057 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2058 if (param->scan_ev_dequeued)
2059 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2060 if (param->scan_ev_preempted)
2061 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2062 if (param->scan_ev_start_failed)
2063 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2064 if (param->scan_ev_restarted)
2065 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2066 if (param->scan_ev_foreign_chn_exit)
2067 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2068 if (param->scan_ev_suspended)
2069 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2070 if (param->scan_ev_resumed)
2071 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302072
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302073 /** Set scan control flags */
2074 cmd->scan_ctrl_flags = 0;
2075 if (param->scan_f_passive)
2076 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2077 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302078 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302079 if (param->scan_f_promisc_mode)
2080 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2081 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302082 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302083 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302084 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302085 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302086 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302087 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302088 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302089 if (param->scan_f_ofdm_rates)
2090 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2091 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302092 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302093 if (param->scan_f_filter_prb_req)
2094 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2095 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302096 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302097 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302098 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302099 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302100 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302101 if (param->scan_f_force_active_dfs_chn)
2102 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2103 if (param->scan_f_add_tpc_ie_in_probe)
2104 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2105 if (param->scan_f_add_ds_ie_in_probe)
2106 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2107 if (param->scan_f_add_spoofed_mac_in_probe)
2108 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2109 if (param->scan_f_add_rand_seq_in_probe)
2110 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2111 if (param->scan_f_en_ie_whitelist_in_probe)
2112 cmd->scan_ctrl_flags |=
2113 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302114
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302115 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2116 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2117 param->adaptive_dwell_time_mode);
2118}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302119
2120/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302121static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302122 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302123{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302124 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302125}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302126
Anish Natarajdd855152017-03-20 12:49:08 +05302127/*
2128 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2129 * @param wmi_handle : Handle to WMI
2130 * @param vdev_id : vdev identifier
2131 *
2132 * Return : void *
2133 */
2134static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2135{
2136 struct wlan_objmgr_vdev *vdev = NULL;
2137 struct wlan_objmgr_pdev *pdev = NULL;
2138 uint8_t pdev_id = 0;
2139
2140 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2141 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2142 vdev_id, WLAN_SCAN_ID);
2143 if (vdev) {
2144 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2145 pdev = wlan_vdev_get_pdev(vdev);
2146 if (pdev)
2147 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2148 else {
2149 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2150 }
2151 } else {
2152 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2153 }
2154
2155 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2156}
2157
Govind Singh5eb51532016-03-09 11:34:12 +05302158/**
2159 * send_scan_start_cmd_tlv() - WMI scan start function
2160 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302161 * @param param : pointer to hold scan start cmd parameter
2162 *
2163 * Return: 0 on success and -ve on failure.
2164 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302165static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302166 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302167{
Govind Singhd3156eb2016-02-26 17:50:39 +05302168 int32_t ret = 0;
2169 int32_t i;
2170 wmi_buf_t wmi_buf;
2171 wmi_start_scan_cmd_fixed_param *cmd;
2172 uint8_t *buf_ptr;
2173 uint32_t *tmp_ptr;
2174 wmi_ssid *ssid = NULL;
2175 wmi_mac_addr *bssid;
2176 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302177 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302178
2179 /* Length TLV placeholder for array of uint32_t */
2180 len += WMI_TLV_HDR_SIZE;
2181 /* calculate the length of buffer required */
2182 if (params->num_chan)
2183 len += params->num_chan * sizeof(uint32_t);
2184
2185 /* Length TLV placeholder for array of wmi_ssid structures */
2186 len += WMI_TLV_HDR_SIZE;
2187 if (params->num_ssids)
2188 len += params->num_ssids * sizeof(wmi_ssid);
2189
2190 /* Length TLV placeholder for array of wmi_mac_addr structures */
2191 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302192 if (params->num_bssid)
2193 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302194
2195 /* Length TLV placeholder for array of bytes */
2196 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302197 if (params->extraie.len)
2198 extraie_len_with_pad =
2199 roundup(params->extraie.len, sizeof(uint32_t));
2200 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302201
2202 /* Allocate the memory */
2203 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2204 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302205 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302206 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302207 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302208 }
2209 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2210 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2211 WMITLV_SET_HDR(&cmd->tlv_header,
2212 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2213 WMITLV_GET_STRUCT_TLVLEN
2214 (wmi_start_scan_cmd_fixed_param));
2215
2216 cmd->scan_id = params->scan_id;
2217 cmd->scan_req_id = params->scan_req_id;
2218 cmd->vdev_id = params->vdev_id;
2219 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302220
2221 copy_scan_event_cntrl_flags(cmd, params);
2222
Govind Singhd3156eb2016-02-26 17:50:39 +05302223 cmd->dwell_time_active = params->dwell_time_active;
2224 cmd->dwell_time_passive = params->dwell_time_passive;
2225 cmd->min_rest_time = params->min_rest_time;
2226 cmd->max_rest_time = params->max_rest_time;
2227 cmd->repeat_probe_time = params->repeat_probe_time;
2228 cmd->probe_spacing_time = params->probe_spacing_time;
2229 cmd->idle_time = params->idle_time;
2230 cmd->max_scan_time = params->max_scan_time;
2231 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302232 cmd->burst_duration = params->burst_duration;
2233 cmd->num_chan = params->num_chan;
2234 cmd->num_bssid = params->num_bssid;
2235 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302236 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302237 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302238 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2239
2240 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2241
Govind Singhd3156eb2016-02-26 17:50:39 +05302242 buf_ptr += sizeof(*cmd);
2243 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2244 for (i = 0; i < params->num_chan; ++i)
2245 tmp_ptr[i] = params->chan_list[i];
2246
2247 WMITLV_SET_HDR(buf_ptr,
2248 WMITLV_TAG_ARRAY_UINT32,
2249 (params->num_chan * sizeof(uint32_t)));
2250 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302251 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302252 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302253 goto error;
2254 }
2255
2256 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2257 (params->num_ssids * sizeof(wmi_ssid)));
2258
2259 if (params->num_ssids) {
2260 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2261 for (i = 0; i < params->num_ssids; ++i) {
2262 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302263 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302264 params->ssid[i].length);
2265 ssid++;
2266 }
2267 }
2268 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2269
2270 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2271 (params->num_bssid * sizeof(wmi_mac_addr)));
2272 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302273
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302274 if (params->num_bssid) {
2275 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302276 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2277 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302278 bssid++;
2279 }
2280 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302281
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302282 buf_ptr += WMI_TLV_HDR_SIZE +
2283 (params->num_bssid * sizeof(wmi_mac_addr));
2284
2285 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2286 if (params->extraie.len)
2287 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2288 params);
2289
2290 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302291
Anish Natarajdd855152017-03-20 12:49:08 +05302292 ret = wmi_unified_cmd_send(
2293 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302294 len, WMI_START_SCAN_CMDID);
2295 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302296 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302297 wmi_buf_free(wmi_buf);
2298 }
2299 return ret;
2300error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302301 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302302 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302303}
2304
2305/**
2306 * send_scan_stop_cmd_tlv() - WMI scan start function
2307 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302308 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302309 *
2310 * Return: 0 on success and -ve on failure.
2311 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302312static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302313 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302314{
Govind Singhd3156eb2016-02-26 17:50:39 +05302315 wmi_stop_scan_cmd_fixed_param *cmd;
2316 int ret;
2317 int len = sizeof(*cmd);
2318 wmi_buf_t wmi_buf;
2319
2320 /* Allocate the memory */
2321 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2322 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302323 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302324 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302325 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 goto error;
2327 }
2328
2329 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2330 WMITLV_SET_HDR(&cmd->tlv_header,
2331 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2332 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2333 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302334 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302335 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302336 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2337 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302338 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302339 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2340 /* Cancelling all scans */
2341 cmd->req_type = WMI_SCAN_STOP_ALL;
2342 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2343 /* Cancelling VAP scans */
2344 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2345 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2346 /* Cancelling specific scan */
2347 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302348 } else {
2349 WMI_LOGE("%s: Invalid Command : ", __func__);
2350 wmi_buf_free(wmi_buf);
2351 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302352 }
2353
Anish Natarajdd855152017-03-20 12:49:08 +05302354 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302355 len, WMI_STOP_SCAN_CMDID);
2356 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302357 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302358 wmi_buf_free(wmi_buf);
2359 }
2360
2361error:
2362 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302363}
2364
Govind Singh87542482016-06-08 19:40:11 +05302365#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302366/**
2367 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2368 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302369 * @param param : pointer to hold scan channel list parameter
2370 *
2371 * Return: 0 on success and -ve on failure.
2372 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302373static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302374 struct scan_chan_list_params *chan_list)
2375{
2376 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302377 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302378 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302379 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302381 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2383
2384 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2385 buf = wmi_buf_alloc(wmi_handle, len);
2386 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302387 WMI_LOGE("Failed to allocate memory");
2388 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302389 goto end;
2390 }
2391
2392 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2393 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2394 WMITLV_SET_HDR(&cmd->tlv_header,
2395 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2396 WMITLV_GET_STRUCT_TLVLEN
2397 (wmi_scan_chan_list_cmd_fixed_param));
2398
Govind Singhb53420c2016-03-09 14:32:57 +05302399 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302400
2401 cmd->num_scan_chans = chan_list->num_scan_chans;
2402 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2403 WMITLV_TAG_ARRAY_STRUC,
2404 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302405 chan_info = (wmi_channel_param *)
2406 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 tchan_info = chan_list->chan_info;
2408
2409 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2410 WMITLV_SET_HDR(&chan_info->tlv_header,
2411 WMITLV_TAG_STRUC_wmi_channel,
2412 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2413 chan_info->mhz = tchan_info->mhz;
2414 chan_info->band_center_freq1 =
2415 tchan_info->band_center_freq1;
2416 chan_info->band_center_freq2 =
2417 tchan_info->band_center_freq2;
2418 chan_info->info = tchan_info->info;
2419 chan_info->reg_info_1 = tchan_info->reg_info_1;
2420 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302421 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302422
2423 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2424 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2425 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2426 tchan_info++;
2427 chan_info++;
2428 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302429 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2430 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302431
Anish Natarajdd855152017-03-20 12:49:08 +05302432 qdf_status = wmi_unified_cmd_send(wmi_handle,
2433 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302434
Govind Singh67922e82016-04-01 16:48:57 +05302435 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302436 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302437 wmi_buf_free(buf);
2438 }
Govind Singh67922e82016-04-01 16:48:57 +05302439
Govind Singhd3156eb2016-02-26 17:50:39 +05302440end:
Govind Singhb53420c2016-03-09 14:32:57 +05302441 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302442}
Govind Singh87542482016-06-08 19:40:11 +05302443#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302444static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302445 struct scan_chan_list_params *chan_list)
2446{
2447 wmi_buf_t buf;
2448 QDF_STATUS qdf_status;
2449 wmi_scan_chan_list_cmd_fixed_param *cmd;
2450 int i;
2451 uint8_t *buf_ptr;
2452 wmi_channel *chan_info;
2453 struct channel_param *tchan_info;
2454 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302455
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302456 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302457 buf = wmi_buf_alloc(wmi_handle, len);
2458 if (!buf) {
2459 WMI_LOGE("Failed to allocate memory");
2460 qdf_status = QDF_STATUS_E_NOMEM;
2461 goto end;
2462 }
2463
2464 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2465 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2466 WMITLV_SET_HDR(&cmd->tlv_header,
2467 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2468 WMITLV_GET_STRUCT_TLVLEN
2469 (wmi_scan_chan_list_cmd_fixed_param));
2470
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302471 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302472
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302473 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2474 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302475 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302476 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2477 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302478 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302479 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2480 tchan_info = &(chan_list->ch_param[0]);
2481
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302482 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302483 WMITLV_SET_HDR(&chan_info->tlv_header,
2484 WMITLV_TAG_STRUC_wmi_channel,
2485 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2486 chan_info->mhz = tchan_info->mhz;
2487 chan_info->band_center_freq1 =
2488 tchan_info->cfreq1;
2489 chan_info->band_center_freq2 =
2490 tchan_info->cfreq2;
2491
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302492 if (tchan_info->is_chan_passive)
2493 WMI_SET_CHANNEL_FLAG(chan_info,
2494 WMI_CHAN_FLAG_PASSIVE);
2495
2496 if (tchan_info->allow_vht)
2497 WMI_SET_CHANNEL_FLAG(chan_info,
2498 WMI_CHAN_FLAG_ALLOW_VHT);
2499 else if (tchan_info->allow_ht)
2500 WMI_SET_CHANNEL_FLAG(chan_info,
2501 WMI_CHAN_FLAG_ALLOW_HT);
2502 WMI_SET_CHANNEL_MODE(chan_info,
2503 tchan_info->phy_mode);
2504
2505 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2506 * after FW support
2507 */
2508
2509 /* also fill in power information */
2510 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2511 tchan_info->minpower);
2512 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2513 tchan_info->maxpower);
2514 WMI_SET_CHANNEL_REG_POWER(chan_info,
2515 tchan_info->maxregpower);
2516 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2517 tchan_info->antennamax);
2518 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2519 tchan_info->reg_class_id);
2520
Govind Singh87542482016-06-08 19:40:11 +05302521 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2522
Govind Singh87542482016-06-08 19:40:11 +05302523 tchan_info++;
2524 chan_info++;
2525 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302526 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2527 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302528
Anish Natarajdd855152017-03-20 12:49:08 +05302529 qdf_status = wmi_unified_cmd_send(
2530 wmi_handle,
2531 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302532
2533 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2534 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2535 wmi_buf_free(buf);
2536 }
2537
2538end:
2539 return qdf_status;
2540}
2541#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302542/**
2543 * send_mgmt_cmd_tlv() - WMI scan start function
2544 * @wmi_handle : handle to WMI.
2545 * @param : pointer to hold mgmt cmd parameter
2546 *
2547 * Return: 0 on success and -ve on failure.
2548 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302549static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302550 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302551{
Govind Singh427ee5a2016-02-26 18:09:36 +05302552 wmi_buf_t buf;
2553 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2554 int32_t cmd_len;
2555 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302556 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302557 uint8_t *bufp;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302558 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302559 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2560 mgmt_tx_dl_frm_len;
2561
2562 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2563 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2564
2565 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2566 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302567 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2568 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302569 }
2570
2571 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2572 bufp = (uint8_t *) cmd;
2573 WMITLV_SET_HDR(&cmd->tlv_header,
2574 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2575 WMITLV_GET_STRUCT_TLVLEN
2576 (wmi_mgmt_tx_send_cmd_fixed_param));
2577
2578 cmd->vdev_id = param->vdev_id;
2579
Govind Singh224a7312016-06-21 14:33:26 +05302580 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302581 cmd->chanfreq = param->chanfreq;
2582 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2583 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2584 sizeof(uint32_t)));
2585 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302586 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302587
2588 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2589 QDF_DMA_TO_DEVICE);
2590 if (status != QDF_STATUS_SUCCESS) {
2591 WMI_LOGE("%s: wmi buf map failed", __func__);
2592 goto err1;
2593 }
2594
Govind Singhb53420c2016-03-09 14:32:57 +05302595 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302596 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002597#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302598 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2599#endif
2600 cmd->frame_len = param->frm_len;
2601 cmd->buf_len = bufp_len;
2602
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002603 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002604 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002605
Govind Singh427ee5a2016-02-26 18:09:36 +05302606 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2607 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302608 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302609 goto err1;
2610 }
Govind Singhb53420c2016-03-09 14:32:57 +05302611 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302612
2613err1:
2614 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302615 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302616}
2617
2618/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302619 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2620 * @wmi_handle : handle to WMI.
2621 * @param : pointer to offchan data tx cmd parameter
2622 *
2623 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2624 */
2625static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2626 struct wmi_offchan_data_tx_params *param)
2627{
2628 wmi_buf_t buf;
2629 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2630 int32_t cmd_len;
2631 uint64_t dma_addr;
2632 void *qdf_ctx = param->qdf_ctx;
2633 uint8_t *bufp;
2634 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2635 param->frm_len : mgmt_tx_dl_frm_len;
2636
2637 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
2638 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2639
2640 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2641 if (!buf) {
2642 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2643 return QDF_STATUS_E_NOMEM;
2644 }
2645
2646 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2647 bufp = (uint8_t *) cmd;
2648 WMITLV_SET_HDR(&cmd->tlv_header,
2649 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2650 WMITLV_GET_STRUCT_TLVLEN
2651 (wmi_offchan_data_tx_send_cmd_fixed_param));
2652
2653 cmd->vdev_id = param->vdev_id;
2654
2655 cmd->desc_id = param->desc_id;
2656 cmd->chanfreq = param->chanfreq;
2657 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2658 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2659 sizeof(uint32_t)));
2660 bufp += WMI_TLV_HDR_SIZE;
2661 qdf_mem_copy(bufp, param->pdata, bufp_len);
2662 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2663 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2664 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2665#if defined(HTT_PADDR64)
2666 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2667#endif
2668 cmd->frame_len = param->frm_len;
2669 cmd->buf_len = bufp_len;
2670
2671 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2672 bufp, cmd->vdev_id, cmd->chanfreq);
2673
2674 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2675 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2676 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
2677 wmi_buf_free(buf);
2678 return QDF_STATUS_E_FAILURE;
2679 }
2680
2681 return QDF_STATUS_SUCCESS;
2682}
2683
2684/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302685 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2686 * @wmi_handle: wmi handle
2687 * @param_value: parameter value
2688 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302689 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302690 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302691static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302692 uint32_t param_value)
2693{
Govind Singh67922e82016-04-01 16:48:57 +05302694 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302695 wmi_modem_power_state_cmd_param *cmd;
2696 wmi_buf_t buf;
2697 uint16_t len = sizeof(*cmd);
2698
2699 buf = wmi_buf_alloc(wmi_handle, len);
2700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302701 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302702 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302703 }
2704 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2705 WMITLV_SET_HDR(&cmd->tlv_header,
2706 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2707 WMITLV_GET_STRUCT_TLVLEN
2708 (wmi_modem_power_state_cmd_param));
2709 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302710 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302711 param_value);
2712 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2713 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302714 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302715 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302716 wmi_buf_free(buf);
2717 }
Govind Singh67922e82016-04-01 16:48:57 +05302718
Govind Singh427ee5a2016-02-26 18:09:36 +05302719 return ret;
2720}
2721
2722/**
2723 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2724 * @wmi_handle: wmi handle
2725 * @vdev_id: vdev id
2726 * @val: value
2727 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302728 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302729 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302730static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302731 uint32_t vdev_id, uint8_t val)
2732{
2733 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2734 wmi_buf_t buf;
2735 int32_t len = sizeof(*cmd);
2736
Govind Singhb53420c2016-03-09 14:32:57 +05302737 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302738
2739 buf = wmi_buf_alloc(wmi_handle, len);
2740 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302741 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302742 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302743 }
2744 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2745 WMITLV_SET_HDR(&cmd->tlv_header,
2746 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2747 WMITLV_GET_STRUCT_TLVLEN
2748 (wmi_sta_powersave_mode_cmd_fixed_param));
2749 cmd->vdev_id = vdev_id;
2750 if (val)
2751 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2752 else
2753 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2754
2755 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2756 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302757 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302758 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302759 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302760 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761 }
Govind Singh5eb51532016-03-09 11:34:12 +05302762 return 0;
2763}
2764
Govind Singh427ee5a2016-02-26 18:09:36 +05302765/**
2766 * send_set_mimops_cmd_tlv() - set MIMO powersave
2767 * @wmi_handle: wmi handle
2768 * @vdev_id: vdev id
2769 * @value: value
2770 *
Govind Singhb53420c2016-03-09 14:32:57 +05302771 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302772 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302773static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302774 uint8_t vdev_id, int value)
2775{
Govind Singh67922e82016-04-01 16:48:57 +05302776 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302777 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2778 wmi_buf_t buf;
2779 uint16_t len = sizeof(*cmd);
2780
2781 buf = wmi_buf_alloc(wmi_handle, len);
2782 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302783 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302784 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302785 }
2786 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2787 WMITLV_SET_HDR(&cmd->tlv_header,
2788 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2789 WMITLV_GET_STRUCT_TLVLEN
2790 (wmi_sta_smps_force_mode_cmd_fixed_param));
2791
2792 cmd->vdev_id = vdev_id;
2793
Houston Hoffmanb5168052016-04-14 02:18:01 -07002794 /* WMI_SMPS_FORCED_MODE values do not directly map
2795 * to SM power save values defined in the specification.
2796 * Make sure to send the right mapping.
2797 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302798 switch (value) {
2799 case 0:
2800 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2801 break;
2802 case 1:
2803 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2804 break;
2805 case 2:
2806 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2807 break;
2808 case 3:
2809 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2810 break;
2811 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302812 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2813 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302814 }
2815
Govind Singhb53420c2016-03-09 14:32:57 +05302816 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302817
2818 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2819 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302820 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302821 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302822 wmi_buf_free(buf);
2823 }
2824
2825 return ret;
2826}
2827
2828/**
2829 * send_set_smps_params_cmd_tlv() - set smps params
2830 * @wmi_handle: wmi handle
2831 * @vdev_id: vdev id
2832 * @value: value
2833 *
Govind Singhb53420c2016-03-09 14:32:57 +05302834 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302835 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302836static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302837 int value)
2838{
Govind Singh67922e82016-04-01 16:48:57 +05302839 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302840 wmi_sta_smps_param_cmd_fixed_param *cmd;
2841 wmi_buf_t buf;
2842 uint16_t len = sizeof(*cmd);
2843
2844 buf = wmi_buf_alloc(wmi_handle, len);
2845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302847 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302848 }
2849 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2850 WMITLV_SET_HDR(&cmd->tlv_header,
2851 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2852 WMITLV_GET_STRUCT_TLVLEN
2853 (wmi_sta_smps_param_cmd_fixed_param));
2854
2855 cmd->vdev_id = vdev_id;
2856 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2857 cmd->param =
2858 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2859
Govind Singhb53420c2016-03-09 14:32:57 +05302860 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302861 cmd->param);
2862
2863 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2864 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302865 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302866 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302867 wmi_buf_free(buf);
2868 }
2869
2870 return ret;
2871}
2872
2873/**
2874 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2875 * @wmi_handle: wmi handle
2876 * @noa: p2p power save parameters
2877 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302878 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302879 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302880static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302881 struct p2p_ps_params *noa)
2882{
2883 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2884 wmi_p2p_noa_descriptor *noa_discriptor;
2885 wmi_buf_t buf;
2886 uint8_t *buf_ptr;
2887 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302888 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302889 uint32_t duration;
2890
Govind Singhb53420c2016-03-09 14:32:57 +05302891 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302892 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2893 buf = wmi_buf_alloc(wmi_handle, len);
2894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302895 WMI_LOGE("Failed to allocate memory");
2896 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302897 goto end;
2898 }
2899
2900 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2901 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2902 WMITLV_SET_HDR(&cmd->tlv_header,
2903 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2904 WMITLV_GET_STRUCT_TLVLEN
2905 (wmi_p2p_set_noa_cmd_fixed_param));
2906 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2907 cmd->vdev_id = noa->session_id;
2908 cmd->enable = (duration) ? true : false;
2909 cmd->num_noa = 1;
2910
2911 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2912 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2913 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2914 sizeof
2915 (wmi_p2p_set_noa_cmd_fixed_param)
2916 + WMI_TLV_HDR_SIZE);
2917 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2918 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2919 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2920 noa_discriptor->type_count = noa->count;
2921 noa_discriptor->duration = duration;
2922 noa_discriptor->interval = noa->interval;
2923 noa_discriptor->start_time = 0;
2924
Govind Singhb53420c2016-03-09 14:32:57 +05302925 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302926 cmd->vdev_id, noa->count, noa_discriptor->duration,
2927 noa->interval);
2928 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2929 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302930 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302931 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302932 wmi_buf_free(buf);
2933 }
2934
2935end:
Govind Singhb53420c2016-03-09 14:32:57 +05302936 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302937 return status;
2938}
2939
2940
2941/**
2942 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2943 * @wmi_handle: wmi handle
2944 * @noa: p2p opp power save parameters
2945 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302946 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302947 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302948static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302949 struct p2p_ps_params *oppps)
2950{
2951 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2952 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302953 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302954
Govind Singhb53420c2016-03-09 14:32:57 +05302955 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302956 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302958 WMI_LOGE("Failed to allocate memory");
2959 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302960 goto end;
2961 }
2962
2963 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2964 WMITLV_SET_HDR(&cmd->tlv_header,
2965 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2966 WMITLV_GET_STRUCT_TLVLEN
2967 (wmi_p2p_set_oppps_cmd_fixed_param));
2968 cmd->vdev_id = oppps->session_id;
2969 if (oppps->ctwindow)
2970 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2971
2972 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302973 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302974 cmd->vdev_id, oppps->ctwindow);
2975 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2976 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302977 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302978 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302979 wmi_buf_free(buf);
2980 }
2981
2982end:
Govind Singhb53420c2016-03-09 14:32:57 +05302983 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302984 return status;
2985}
2986
Wu Gaocd3a8512017-03-13 20:17:34 +08002987#ifdef CONVERGED_P2P_ENABLE
2988/**
2989 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2990 * @wmi_handle: wmi handle
2991 * @param: p2p listen offload start parameters
2992 *
2993 * Return: QDF status
2994 */
2995static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2996 struct p2p_lo_start *param)
2997{
2998 wmi_buf_t buf;
2999 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3000 int32_t len = sizeof(*cmd);
3001 uint8_t *buf_ptr;
3002 QDF_STATUS status;
3003 int device_types_len_aligned;
3004 int probe_resp_len_aligned;
3005
3006 if (!param) {
3007 WMI_LOGE("lo start param is null");
3008 return QDF_STATUS_E_INVAL;
3009 }
3010
3011 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3012
3013 device_types_len_aligned =
3014 qdf_roundup(param->dev_types_len,
3015 sizeof(A_UINT32));
3016 probe_resp_len_aligned =
3017 qdf_roundup(param->probe_resp_len,
3018 sizeof(A_UINT32));
3019
3020 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3021 probe_resp_len_aligned;
3022
3023 buf = wmi_buf_alloc(wmi_handle, len);
3024 if (!buf) {
3025 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3026 __func__);
3027 return QDF_STATUS_E_NOMEM;
3028 }
3029
3030 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3031 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3032
3033 WMITLV_SET_HDR(&cmd->tlv_header,
3034 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3035 WMITLV_GET_STRUCT_TLVLEN(
3036 wmi_p2p_lo_start_cmd_fixed_param));
3037
3038 cmd->vdev_id = param->vdev_id;
3039 cmd->ctl_flags = param->ctl_flags;
3040 cmd->channel = param->freq;
3041 cmd->period = param->period;
3042 cmd->interval = param->interval;
3043 cmd->count = param->count;
3044 cmd->device_types_len = param->dev_types_len;
3045 cmd->prob_resp_len = param->probe_resp_len;
3046
3047 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3049 device_types_len_aligned);
3050 buf_ptr += WMI_TLV_HDR_SIZE;
3051 qdf_mem_copy(buf_ptr, param->device_types,
3052 param->dev_types_len);
3053
3054 buf_ptr += device_types_len_aligned;
3055 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3056 probe_resp_len_aligned);
3057 buf_ptr += WMI_TLV_HDR_SIZE;
3058 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3059 param->probe_resp_len);
3060
3061 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3062 cmd->channel, cmd->period, cmd->interval, cmd->count);
3063
3064 status = wmi_unified_cmd_send(wmi_handle,
3065 buf, len,
3066 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3067 if (status != QDF_STATUS_SUCCESS) {
3068 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3069 __func__, status);
3070 wmi_buf_free(buf);
3071 return status;
3072 }
3073
3074 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3075
3076 return QDF_STATUS_SUCCESS;
3077}
3078
3079/**
3080 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3081 * @wmi_handle: wmi handle
3082 * @param: p2p listen offload stop parameters
3083 *
3084 * Return: QDF status
3085 */
3086static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3087 uint8_t vdev_id)
3088{
3089 wmi_buf_t buf;
3090 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3091 int32_t len;
3092 QDF_STATUS status;
3093
3094 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3095
3096 len = sizeof(*cmd);
3097 buf = wmi_buf_alloc(wmi_handle, len);
3098 if (!buf) {
3099 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3100 __func__);
3101 return QDF_STATUS_E_NOMEM;
3102 }
3103 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3104
3105 WMITLV_SET_HDR(&cmd->tlv_header,
3106 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3107 WMITLV_GET_STRUCT_TLVLEN(
3108 wmi_p2p_lo_stop_cmd_fixed_param));
3109
3110 cmd->vdev_id = vdev_id;
3111
3112 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3113
3114 status = wmi_unified_cmd_send(wmi_handle,
3115 buf, len,
3116 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3117 if (status != QDF_STATUS_SUCCESS) {
3118 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3119 __func__, status);
3120 wmi_buf_free(buf);
3121 return status;
3122 }
3123
3124 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3125
3126 return QDF_STATUS_SUCCESS;
3127}
3128#endif /* End of CONVERGED_P2P_ENABLE */
3129
Govind Singh427ee5a2016-02-26 18:09:36 +05303130/**
3131 * send_get_temperature_cmd_tlv() - get pdev temperature req
3132 * @wmi_handle: wmi handle
3133 *
Govind Singhb53420c2016-03-09 14:32:57 +05303134 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303135 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303136static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303137{
3138 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3139 wmi_buf_t wmi_buf;
3140 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3141 uint8_t *buf_ptr;
3142
3143 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303144 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3145 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303146 }
3147
3148 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3149 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303150 WMI_LOGE(FL("wmi_buf_alloc failed"));
3151 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303152 }
3153
3154 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3155
3156 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3157 WMITLV_SET_HDR(&cmd->tlv_header,
3158 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3159 WMITLV_GET_STRUCT_TLVLEN
3160 (wmi_pdev_get_temperature_cmd_fixed_param));
3161
3162 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3163 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303164 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303165 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303166 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303168
Govind Singhb53420c2016-03-09 14:32:57 +05303169 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303170}
3171
3172/**
3173 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3174 * @wmi_handle: wmi handle
3175 * @vdevid: vdev id
3176 * @peer_addr: peer mac address
3177 * @auto_triggerparam: auto trigger parameters
3178 * @num_ac: number of access category
3179 *
3180 * This function sets the trigger
3181 * uapsd params such as service interval, delay interval
3182 * and suspend interval which will be used by the firmware
3183 * to send trigger frames periodically when there is no
3184 * traffic on the transmit side.
3185 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303186 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303187 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303188static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 struct sta_uapsd_trig_params *param)
3190{
3191 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303192 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303193 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3194 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3195 uint32_t i;
3196 wmi_buf_t buf;
3197 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003198 struct sta_uapsd_params *uapsd_param;
3199 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303200
3201 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3202 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303203 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303204 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303205 }
3206
3207 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3208 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3209 WMITLV_SET_HDR(&cmd->tlv_header,
3210 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3211 WMITLV_GET_STRUCT_TLVLEN
3212 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3213 cmd->vdev_id = param->vdevid;
3214 cmd->num_ac = param->num_ac;
3215 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3216
3217 /* TLV indicating array of structures to follow */
3218 buf_ptr += sizeof(*cmd);
3219 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3220
3221 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303222
3223 /*
3224 * Update tag and length for uapsd auto trigger params (this will take
3225 * care of updating tag and length if it is not pre-filled by caller).
3226 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003227 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3228 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303229 for (i = 0; i < param->num_ac; i++) {
3230 WMITLV_SET_HDR((buf_ptr +
3231 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3232 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3233 WMITLV_GET_STRUCT_TLVLEN
3234 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003235 trig_param->wmm_ac = uapsd_param->wmm_ac;
3236 trig_param->user_priority = uapsd_param->user_priority;
3237 trig_param->service_interval = uapsd_param->service_interval;
3238 trig_param->suspend_interval = uapsd_param->suspend_interval;
3239 trig_param->delay_interval = uapsd_param->delay_interval;
3240 trig_param++;
3241 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303242 }
3243
3244 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3245 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303246 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303248 wmi_buf_free(buf);
3249 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303250
Govind Singh427ee5a2016-02-26 18:09:36 +05303251 return ret;
3252}
3253
Govind Singh2edc80f2016-03-01 15:30:53 +05303254/**
3255 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3256 * @wmi_handle: pointer to the wmi handle
3257 * @utc: pointer to the UTC time struct
3258 *
3259 * Return: 0 on succes
3260 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303261static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303262 struct ocb_utc_param *utc)
3263{
Govind Singh67922e82016-04-01 16:48:57 +05303264 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303265 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3266 uint8_t *buf_ptr;
3267 uint32_t len, i;
3268 wmi_buf_t buf;
3269
3270 len = sizeof(*cmd);
3271 buf = wmi_buf_alloc(wmi_handle, len);
3272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303273 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303274 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303275 }
3276
3277 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3278 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3279 WMITLV_SET_HDR(&cmd->tlv_header,
3280 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3281 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3282 cmd->vdev_id = utc->vdev_id;
3283
3284 for (i = 0; i < SIZE_UTC_TIME; i++)
3285 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3286
3287 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3288 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3289
3290 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3291 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303292 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303293 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303294 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303295 }
3296
Govind Singh67922e82016-04-01 16:48:57 +05303297 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303298}
3299
3300/**
3301 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3302 * frames on a channel
3303 * @wmi_handle: pointer to the wmi handle
3304 * @timing_advert: pointer to the timing advertisement struct
3305 *
3306 * Return: 0 on succes
3307 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303308static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303309 struct ocb_timing_advert_param *timing_advert)
3310{
Govind Singh67922e82016-04-01 16:48:57 +05303311 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303312 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3313 uint8_t *buf_ptr;
3314 uint32_t len, len_template;
3315 wmi_buf_t buf;
3316
3317 len = sizeof(*cmd) +
3318 WMI_TLV_HDR_SIZE;
3319
3320 len_template = timing_advert->template_length;
3321 /* Add padding to the template if needed */
3322 if (len_template % 4 != 0)
3323 len_template += 4 - (len_template % 4);
3324 len += len_template;
3325
3326 buf = wmi_buf_alloc(wmi_handle, len);
3327 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303328 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303329 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303330 }
3331
3332 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3333 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3334 WMITLV_SET_HDR(&cmd->tlv_header,
3335 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3336 WMITLV_GET_STRUCT_TLVLEN(
3337 wmi_ocb_start_timing_advert_cmd_fixed_param));
3338 cmd->vdev_id = timing_advert->vdev_id;
3339 cmd->repeat_rate = timing_advert->repeat_rate;
3340 cmd->channel_freq = timing_advert->chan_freq;
3341 cmd->timestamp_offset = timing_advert->timestamp_offset;
3342 cmd->time_value_offset = timing_advert->time_value_offset;
3343 cmd->timing_advert_template_length = timing_advert->template_length;
3344 buf_ptr += sizeof(*cmd);
3345
3346 /* Add the timing advert template */
3347 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3348 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303349 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303350 (uint8_t *)timing_advert->template_value,
3351 timing_advert->template_length);
3352
3353 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3354 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303355 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303356 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303357 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303358 }
3359
Govind Singh67922e82016-04-01 16:48:57 +05303360 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303361}
3362
3363/**
3364 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3365 * on a channel
3366 * @wmi_handle: pointer to the wmi handle
3367 * @timing_advert: pointer to the timing advertisement struct
3368 *
3369 * Return: 0 on succes
3370 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303371static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303372 struct ocb_timing_advert_param *timing_advert)
3373{
Govind Singh67922e82016-04-01 16:48:57 +05303374 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303375 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3376 uint8_t *buf_ptr;
3377 uint32_t len;
3378 wmi_buf_t buf;
3379
3380 len = sizeof(*cmd);
3381 buf = wmi_buf_alloc(wmi_handle, len);
3382 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303383 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303384 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303385 }
3386
3387 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3388 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3389 WMITLV_SET_HDR(&cmd->tlv_header,
3390 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3391 WMITLV_GET_STRUCT_TLVLEN(
3392 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3393 cmd->vdev_id = timing_advert->vdev_id;
3394 cmd->channel_freq = timing_advert->chan_freq;
3395
3396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3397 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303398 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303399 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303400 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303401 }
3402
Govind Singh67922e82016-04-01 16:48:57 +05303403 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303404}
3405
3406/**
3407 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3408 * @wmi_handle: pointer to the wmi handle
3409 * @request: pointer to the request
3410 *
3411 * Return: 0 on succes
3412 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303413static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303414 uint8_t vdev_id)
3415{
Govind Singhb53420c2016-03-09 14:32:57 +05303416 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303417 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3418 uint8_t *buf_ptr;
3419 wmi_buf_t buf;
3420 int32_t len;
3421
3422 len = sizeof(*cmd);
3423 buf = wmi_buf_alloc(wmi_handle, len);
3424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303425 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303426 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303427 }
3428 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3429
3430 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303431 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303432 WMITLV_SET_HDR(&cmd->tlv_header,
3433 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3434 WMITLV_GET_STRUCT_TLVLEN(
3435 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3436 cmd->vdev_id = vdev_id;
3437
3438 /* Send the WMI command */
3439 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3440 WMI_OCB_GET_TSF_TIMER_CMDID);
3441 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303442 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303443 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303444 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303445 }
3446
Govind Singh67922e82016-04-01 16:48:57 +05303447 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303448}
3449
3450/**
3451 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3452 * @wmi_handle: pointer to the wmi handle
3453 * @get_stats_param: pointer to the dcc stats
3454 *
3455 * Return: 0 on succes
3456 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303457static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303458 struct dcc_get_stats_param *get_stats_param)
3459{
Govind Singh67922e82016-04-01 16:48:57 +05303460 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303461 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3462 wmi_dcc_channel_stats_request *channel_stats_array;
3463 wmi_buf_t buf;
3464 uint8_t *buf_ptr;
3465 uint32_t len;
3466 uint32_t i;
3467
3468 /* Validate the input */
3469 if (get_stats_param->request_array_len !=
3470 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303471 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303472 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303473 }
3474
3475 /* Allocate memory for the WMI command */
3476 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3477 get_stats_param->request_array_len;
3478
3479 buf = wmi_buf_alloc(wmi_handle, len);
3480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303481 WMI_LOGE(FL("wmi_buf_alloc failed"));
3482 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303483 }
3484
3485 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303486 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303487
3488 /* Populate the WMI command */
3489 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3490 buf_ptr += sizeof(*cmd);
3491
3492 WMITLV_SET_HDR(&cmd->tlv_header,
3493 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3494 WMITLV_GET_STRUCT_TLVLEN(
3495 wmi_dcc_get_stats_cmd_fixed_param));
3496 cmd->vdev_id = get_stats_param->vdev_id;
3497 cmd->num_channels = get_stats_param->channel_count;
3498
3499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3500 get_stats_param->request_array_len);
3501 buf_ptr += WMI_TLV_HDR_SIZE;
3502
3503 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303504 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303505 get_stats_param->request_array_len);
3506 for (i = 0; i < cmd->num_channels; i++)
3507 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3508 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3509 WMITLV_GET_STRUCT_TLVLEN(
3510 wmi_dcc_channel_stats_request));
3511
3512 /* Send the WMI command */
3513 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3514 WMI_DCC_GET_STATS_CMDID);
3515
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_clear_stats_cmd_tlv() - command to clear the DCC stats
3526 * @wmi_handle: pointer to the wmi handle
3527 * @vdev_id: vdev id
3528 * @dcc_stats_bitmap: dcc status bitmap
3529 *
3530 * Return: 0 on succes
3531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303532static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303533 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3534{
Govind Singh67922e82016-04-01 16:48:57 +05303535 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303536 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3537 wmi_buf_t buf;
3538 uint8_t *buf_ptr;
3539 uint32_t len;
3540
3541 /* Allocate memory for the WMI command */
3542 len = sizeof(*cmd);
3543
3544 buf = wmi_buf_alloc(wmi_handle, len);
3545 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303546 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303547 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303548 }
3549
3550 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303551 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303552
3553 /* Populate the WMI command */
3554 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3555
3556 WMITLV_SET_HDR(&cmd->tlv_header,
3557 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3558 WMITLV_GET_STRUCT_TLVLEN(
3559 wmi_dcc_clear_stats_cmd_fixed_param));
3560 cmd->vdev_id = vdev_id;
3561 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3562
3563 /* Send the WMI command */
3564 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3565 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303566 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303567 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303568 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303569 }
3570
Govind Singh67922e82016-04-01 16:48:57 +05303571 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303572}
3573
3574/**
3575 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3576 * @wmi_handle: pointer to the wmi handle
3577 * @update_ndl_param: pointer to the request parameters
3578 *
3579 * Return: 0 on success
3580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303581static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303582 struct dcc_update_ndl_param *update_ndl_param)
3583{
Govind Singhb53420c2016-03-09 14:32:57 +05303584 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303585 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3586 wmi_dcc_ndl_chan *ndl_chan_array;
3587 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3588 uint32_t active_state_count;
3589 wmi_buf_t buf;
3590 uint8_t *buf_ptr;
3591 uint32_t len;
3592 uint32_t i;
3593
3594 /* validate the input */
3595 if (update_ndl_param->dcc_ndl_chan_list_len !=
3596 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303597 WMI_LOGE(FL("Invalid parameter"));
3598 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303599 }
3600 active_state_count = 0;
3601 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3602 for (i = 0; i < update_ndl_param->channel_count; i++)
3603 active_state_count +=
3604 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3605 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3606 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303607 WMI_LOGE(FL("Invalid parameter"));
3608 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303609 }
3610
3611 /* Allocate memory for the WMI command */
3612 len = sizeof(*cmd) +
3613 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3614 WMI_TLV_HDR_SIZE +
3615 update_ndl_param->dcc_ndl_active_state_list_len;
3616
3617 buf = wmi_buf_alloc(wmi_handle, len);
3618 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303619 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303620 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303621 }
3622
3623 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303624 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303625
3626 /* Populate the WMI command */
3627 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3628 buf_ptr += sizeof(*cmd);
3629
3630 WMITLV_SET_HDR(&cmd->tlv_header,
3631 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3632 WMITLV_GET_STRUCT_TLVLEN(
3633 wmi_dcc_update_ndl_cmd_fixed_param));
3634 cmd->vdev_id = update_ndl_param->vdev_id;
3635 cmd->num_channel = update_ndl_param->channel_count;
3636
3637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3638 update_ndl_param->dcc_ndl_chan_list_len);
3639 buf_ptr += WMI_TLV_HDR_SIZE;
3640
3641 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303642 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303643 update_ndl_param->dcc_ndl_chan_list_len);
3644 for (i = 0; i < cmd->num_channel; i++)
3645 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3646 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3647 WMITLV_GET_STRUCT_TLVLEN(
3648 wmi_dcc_ndl_chan));
3649 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3650
3651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3652 update_ndl_param->dcc_ndl_active_state_list_len);
3653 buf_ptr += WMI_TLV_HDR_SIZE;
3654
3655 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303656 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303657 update_ndl_param->dcc_ndl_active_state_list,
3658 update_ndl_param->dcc_ndl_active_state_list_len);
3659 for (i = 0; i < active_state_count; i++) {
3660 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3661 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3662 WMITLV_GET_STRUCT_TLVLEN(
3663 wmi_dcc_ndl_active_state_config));
3664 }
3665 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3666
3667 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303668 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303669 WMI_DCC_UPDATE_NDL_CMDID);
3670 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303671 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303672 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303673 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303674 }
3675
Govind Singh67922e82016-04-01 16:48:57 +05303676 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303677}
3678
3679/**
3680 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3681 * @wmi_handle: pointer to the wmi handle
3682 * @config: the OCB configuration
3683 *
3684 * Return: 0 on success
3685 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303686static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303687 struct ocb_config_param *config, uint32_t *ch_mhz)
3688{
Govind Singh67922e82016-04-01 16:48:57 +05303689 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303690 wmi_ocb_set_config_cmd_fixed_param *cmd;
3691 wmi_channel *chan;
3692 wmi_ocb_channel *ocb_chan;
3693 wmi_qos_parameter *qos_param;
3694 wmi_dcc_ndl_chan *ndl_chan;
3695 wmi_dcc_ndl_active_state_config *ndl_active_config;
3696 wmi_ocb_schedule_element *sched_elem;
3697 uint8_t *buf_ptr;
3698 wmi_buf_t buf;
3699 int32_t len;
3700 int32_t i, j, active_state_count;
3701
3702 /*
3703 * Validate the dcc_ndl_chan_list_len and count the number of active
3704 * states. Validate dcc_ndl_active_state_list_len.
3705 */
3706 active_state_count = 0;
3707 if (config->dcc_ndl_chan_list_len) {
3708 if (!config->dcc_ndl_chan_list ||
3709 config->dcc_ndl_chan_list_len !=
3710 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303711 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303712 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303713 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303714 }
3715
3716 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3717 i < config->channel_count; ++i, ++ndl_chan)
3718 active_state_count +=
3719 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3720
3721 if (active_state_count) {
3722 if (!config->dcc_ndl_active_state_list ||
3723 config->dcc_ndl_active_state_list_len !=
3724 active_state_count *
3725 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303726 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303727 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303728 }
3729 }
3730 }
3731
3732 len = sizeof(*cmd) +
3733 WMI_TLV_HDR_SIZE + config->channel_count *
3734 sizeof(wmi_channel) +
3735 WMI_TLV_HDR_SIZE + config->channel_count *
3736 sizeof(wmi_ocb_channel) +
3737 WMI_TLV_HDR_SIZE + config->channel_count *
3738 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3739 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3740 WMI_TLV_HDR_SIZE + active_state_count *
3741 sizeof(wmi_dcc_ndl_active_state_config) +
3742 WMI_TLV_HDR_SIZE + config->schedule_size *
3743 sizeof(wmi_ocb_schedule_element);
3744 buf = wmi_buf_alloc(wmi_handle, len);
3745 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303747 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303748 }
3749
3750 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3751 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3752 WMITLV_SET_HDR(&cmd->tlv_header,
3753 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3754 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3755 cmd->vdev_id = config->session_id;
3756 cmd->channel_count = config->channel_count;
3757 cmd->schedule_size = config->schedule_size;
3758 cmd->flags = config->flags;
3759 buf_ptr += sizeof(*cmd);
3760
3761 /* Add the wmi_channel info */
3762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3763 config->channel_count*sizeof(wmi_channel));
3764 buf_ptr += WMI_TLV_HDR_SIZE;
3765 for (i = 0; i < config->channel_count; i++) {
3766 chan = (wmi_channel *)buf_ptr;
3767 WMITLV_SET_HDR(&chan->tlv_header,
3768 WMITLV_TAG_STRUC_wmi_channel,
3769 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3770 chan->mhz = config->channels[i].chan_freq;
3771 chan->band_center_freq1 = config->channels[i].chan_freq;
3772 chan->band_center_freq2 = 0;
3773 chan->info = 0;
3774
3775 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3776 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3777 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3778 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3779 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3780 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3781 config->channels[i].antenna_max);
3782
3783 if (config->channels[i].bandwidth < 10)
3784 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3785 else if (config->channels[i].bandwidth < 20)
3786 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3787 buf_ptr += sizeof(*chan);
3788 }
3789
3790 /* Add the wmi_ocb_channel info */
3791 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3792 config->channel_count*sizeof(wmi_ocb_channel));
3793 buf_ptr += WMI_TLV_HDR_SIZE;
3794 for (i = 0; i < config->channel_count; i++) {
3795 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3796 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3797 WMITLV_TAG_STRUC_wmi_ocb_channel,
3798 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3799 ocb_chan->bandwidth = config->channels[i].bandwidth;
3800 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3801 config->channels[i].mac_address.bytes,
3802 &ocb_chan->mac_address);
3803 buf_ptr += sizeof(*ocb_chan);
3804 }
3805
3806 /* Add the wmi_qos_parameter info */
3807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3808 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3809 buf_ptr += WMI_TLV_HDR_SIZE;
3810 /* WMI_MAX_NUM_AC parameters for each channel */
3811 for (i = 0; i < config->channel_count; i++) {
3812 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3813 qos_param = (wmi_qos_parameter *)buf_ptr;
3814 WMITLV_SET_HDR(&qos_param->tlv_header,
3815 WMITLV_TAG_STRUC_wmi_qos_parameter,
3816 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3817 qos_param->aifsn =
3818 config->channels[i].qos_params[j].aifsn;
3819 qos_param->cwmin =
3820 config->channels[i].qos_params[j].cwmin;
3821 qos_param->cwmax =
3822 config->channels[i].qos_params[j].cwmax;
3823 buf_ptr += sizeof(*qos_param);
3824 }
3825 }
3826
3827 /* Add the wmi_dcc_ndl_chan (per channel) */
3828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3829 config->dcc_ndl_chan_list_len);
3830 buf_ptr += WMI_TLV_HDR_SIZE;
3831 if (config->dcc_ndl_chan_list_len) {
3832 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303833 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303834 config->dcc_ndl_chan_list_len);
3835 for (i = 0; i < config->channel_count; i++)
3836 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3837 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3838 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3839 buf_ptr += config->dcc_ndl_chan_list_len;
3840 }
3841
3842 /* Add the wmi_dcc_ndl_active_state_config */
3843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3844 sizeof(wmi_dcc_ndl_active_state_config));
3845 buf_ptr += WMI_TLV_HDR_SIZE;
3846 if (active_state_count) {
3847 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303848 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303849 config->dcc_ndl_active_state_list,
3850 active_state_count * sizeof(*ndl_active_config));
3851 for (i = 0; i < active_state_count; ++i)
3852 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3853 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3854 WMITLV_GET_STRUCT_TLVLEN(
3855 wmi_dcc_ndl_active_state_config));
3856 buf_ptr += active_state_count *
3857 sizeof(*ndl_active_config);
3858 }
3859
3860 /* Add the wmi_ocb_schedule_element info */
3861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3862 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3863 buf_ptr += WMI_TLV_HDR_SIZE;
3864 for (i = 0; i < config->schedule_size; i++) {
3865 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3866 WMITLV_SET_HDR(&sched_elem->tlv_header,
3867 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3868 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3869 sched_elem->channel_freq = config->schedule[i].chan_freq;
3870 sched_elem->total_duration = config->schedule[i].total_duration;
3871 sched_elem->guard_interval = config->schedule[i].guard_interval;
3872 buf_ptr += sizeof(*sched_elem);
3873 }
3874
3875
3876 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3877 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303878 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303879 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303880 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303881 }
3882
Govind Singh67922e82016-04-01 16:48:57 +05303883 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303884}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303885
3886/**
3887 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3888 * @wmi_handle: wmi handle
3889 * @mcc_adaptive_scheduler: enable/disable
3890 *
3891 * This function enable/disable mcc adaptive scheduler in fw.
3892 *
Govind Singhb53420c2016-03-09 14:32:57 +05303893 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303894 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303895static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003896 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3897 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303898{
Govind Singh67922e82016-04-01 16:48:57 +05303899 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303900 wmi_buf_t buf = 0;
3901 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3902 uint16_t len =
3903 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3904
3905 buf = wmi_buf_alloc(wmi_handle, len);
3906 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303907 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3908 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303909 }
3910 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3911 wmi_buf_data(buf);
3912
3913 WMITLV_SET_HDR(&cmd->tlv_header,
3914 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3915 WMITLV_GET_STRUCT_TLVLEN
3916 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3917 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303918 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303919
3920 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3921 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303922 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303923 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303924 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303925 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303926 }
Govind Singh67922e82016-04-01 16:48:57 +05303927
3928 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303929}
3930
3931/**
3932 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3933 * @wmi: wmi handle
3934 * @mcc_channel: mcc channel
3935 * @mcc_channel_time_latency: MCC channel time latency.
3936 *
3937 * Currently used to set time latency for an MCC vdev/adapter using operating
3938 * channel of it and channel number. The info is provided run time using
3939 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3940 *
3941 * Return: CDF status
3942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303943static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303944 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3945{
Govind Singh67922e82016-04-01 16:48:57 +05303946 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303947 wmi_buf_t buf = 0;
3948 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3949 uint16_t len = 0;
3950 uint8_t *buf_ptr = NULL;
3951 wmi_resmgr_chan_latency chan_latency;
3952 /* Note: we only support MCC time latency for a single channel */
3953 uint32_t num_channels = 1;
3954 uint32_t chan1_freq = mcc_channel_freq;
3955 uint32_t latency_chan1 = mcc_channel_time_latency;
3956
3957
3958 /* If 0ms latency is provided, then FW will set to a default.
3959 * Otherwise, latency must be at least 30ms.
3960 */
3961 if ((latency_chan1 > 0) &&
3962 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303963 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303964 "Minimum is 30ms (or 0 to use default value by "
3965 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303966 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303967 }
3968
3969 /* Set WMI CMD for channel time latency here */
3970 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3971 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3972 num_channels * sizeof(wmi_resmgr_chan_latency);
3973 buf = wmi_buf_alloc(wmi_handle, len);
3974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303975 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3976 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303977 }
3978 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3979 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3980 wmi_buf_data(buf);
3981 WMITLV_SET_HDR(&cmdTL->tlv_header,
3982 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3983 WMITLV_GET_STRUCT_TLVLEN
3984 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3985 cmdTL->num_chans = num_channels;
3986 /* Update channel time latency information for home channel(s) */
3987 buf_ptr += sizeof(*cmdTL);
3988 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3989 num_channels * sizeof(wmi_resmgr_chan_latency));
3990 buf_ptr += WMI_TLV_HDR_SIZE;
3991 chan_latency.chan_mhz = chan1_freq;
3992 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303993 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303994 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3995 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303996 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303997 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303998 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303999 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304000 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304001 }
Govind Singh67922e82016-04-01 16:48:57 +05304002
4003 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304004}
4005
4006/**
4007 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4008 * @wmi: wmi handle
4009 * @adapter_1_chan_number: adapter 1 channel number
4010 * @adapter_1_quota: adapter 1 quota
4011 * @adapter_2_chan_number: adapter 2 channel number
4012 *
4013 * Return: CDF status
4014 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304015static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304016 uint32_t adapter_1_chan_freq,
4017 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4018{
Govind Singh67922e82016-04-01 16:48:57 +05304019 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304020 wmi_buf_t buf = 0;
4021 uint16_t len = 0;
4022 uint8_t *buf_ptr = NULL;
4023 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4024 wmi_resmgr_chan_time_quota chan_quota;
4025 uint32_t quota_chan1 = adapter_1_quota;
4026 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4027 uint32_t quota_chan2 = 100 - quota_chan1;
4028 /* Note: setting time quota for MCC requires info for 2 channels */
4029 uint32_t num_channels = 2;
4030 uint32_t chan1_freq = adapter_1_chan_freq;
4031 uint32_t chan2_freq = adapter_2_chan_freq;
4032
Govind Singhb53420c2016-03-09 14:32:57 +05304033 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304034 "freq2:%dMHz, Quota2:%dms", __func__,
4035 chan1_freq, quota_chan1, chan2_freq,
4036 quota_chan2);
4037
4038 /*
4039 * Perform sanity check on time quota values provided.
4040 */
4041 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4042 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304043 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304044 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304045 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304046 }
4047 /* Set WMI CMD for channel time quota here */
4048 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4049 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4050 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4051 buf = wmi_buf_alloc(wmi_handle, len);
4052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304053 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4054 QDF_ASSERT(0);
4055 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304056 }
4057 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4058 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4059 wmi_buf_data(buf);
4060 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4061 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4062 WMITLV_GET_STRUCT_TLVLEN
4063 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4064 cmdTQ->num_chans = num_channels;
4065
4066 /* Update channel time quota information for home channel(s) */
4067 buf_ptr += sizeof(*cmdTQ);
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4069 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4070 buf_ptr += WMI_TLV_HDR_SIZE;
4071 chan_quota.chan_mhz = chan1_freq;
4072 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304073 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304074 /* Construct channel and quota record for the 2nd MCC mode. */
4075 buf_ptr += sizeof(chan_quota);
4076 chan_quota.chan_mhz = chan2_freq;
4077 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304078 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304079
4080 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4081 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304082 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304083 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304084 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304085 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304086 }
Govind Singh67922e82016-04-01 16:48:57 +05304087
4088 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304089}
4090
4091/**
4092 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4093 * @wmi_handle: Pointer to wmi handle
4094 * @thermal_info: Thermal command information
4095 *
4096 * This function sends the thermal management command
4097 * to the firmware
4098 *
Govind Singhb53420c2016-03-09 14:32:57 +05304099 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304101static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304102 struct thermal_cmd_params *thermal_info)
4103{
4104 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4105 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304106 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304107 uint32_t len = 0;
4108
4109 len = sizeof(*cmd);
4110
4111 buf = wmi_buf_alloc(wmi_handle, len);
4112 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304113 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4114 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304115 }
4116
4117 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4118
4119 WMITLV_SET_HDR(&cmd->tlv_header,
4120 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4121 WMITLV_GET_STRUCT_TLVLEN
4122 (wmi_thermal_mgmt_cmd_fixed_param));
4123
4124 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4125 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4126 cmd->enable = thermal_info->thermal_enable;
4127
Govind Singhb53420c2016-03-09 14:32:57 +05304128 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304129 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4130
4131 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4132 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304133 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304134 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304135 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304136 }
4137
Govind Singh67922e82016-04-01 16:48:57 +05304138 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304139}
4140
4141
4142/**
4143 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304144 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304145 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4146 *
4147 * This function sends down the LRO configuration parameters to
4148 * the firmware to enable LRO, sets the TCP flags and sets the
4149 * seed values for the toeplitz hash generation
4150 *
Govind Singhb53420c2016-03-09 14:32:57 +05304151 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304153static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304154 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4155{
4156 wmi_lro_info_cmd_fixed_param *cmd;
4157 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304158 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304159
4160
4161 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304163 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4164 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304165 }
4166
4167 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4168
4169 WMITLV_SET_HDR(&cmd->tlv_header,
4170 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4171 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4172
4173 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4174 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4175 wmi_lro_cmd->tcp_flag);
4176 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4177 wmi_lro_cmd->tcp_flag_mask);
4178 cmd->toeplitz_hash_ipv4_0_3 =
4179 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4180 cmd->toeplitz_hash_ipv4_4_7 =
4181 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4182 cmd->toeplitz_hash_ipv4_8_11 =
4183 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4184 cmd->toeplitz_hash_ipv4_12_15 =
4185 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4186 cmd->toeplitz_hash_ipv4_16 =
4187 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4188
4189 cmd->toeplitz_hash_ipv6_0_3 =
4190 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4191 cmd->toeplitz_hash_ipv6_4_7 =
4192 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4193 cmd->toeplitz_hash_ipv6_8_11 =
4194 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4195 cmd->toeplitz_hash_ipv6_12_15 =
4196 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4197 cmd->toeplitz_hash_ipv6_16_19 =
4198 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4199 cmd->toeplitz_hash_ipv6_20_23 =
4200 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4201 cmd->toeplitz_hash_ipv6_24_27 =
4202 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4203 cmd->toeplitz_hash_ipv6_28_31 =
4204 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4205 cmd->toeplitz_hash_ipv6_32_35 =
4206 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4207 cmd->toeplitz_hash_ipv6_36_39 =
4208 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4209 cmd->toeplitz_hash_ipv6_40 =
4210 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4211
Govind Singhb53420c2016-03-09 14:32:57 +05304212 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304213 cmd->lro_enable, cmd->tcp_flag_u32);
4214
4215 status = wmi_unified_cmd_send(wmi_handle, buf,
4216 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304217 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304218 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304219 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304220 }
4221
Govind Singh67922e82016-04-01 16:48:57 +05304222 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304223}
4224
Govind Singh4eacd2b2016-03-07 14:24:22 +05304225/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304226 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4227 * @wmi_handle: Pointer to wmi handle
4228 * @rate_report_params: Pointer to peer rate report parameters
4229 *
4230 *
4231 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304233static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304234 struct wmi_peer_rate_report_params *rate_report_params)
4235{
4236 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4237 wmi_buf_t buf = NULL;
4238 QDF_STATUS status = 0;
4239 uint32_t len = 0;
4240 uint32_t i, j;
4241
4242 len = sizeof(*cmd);
4243
4244 buf = wmi_buf_alloc(wmi_handle, len);
4245 if (!buf) {
4246 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4247 return QDF_STATUS_E_FAILURE;
4248 }
4249
4250 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4251 wmi_buf_data(buf);
4252
4253 WMITLV_SET_HDR(
4254 &cmd->tlv_header,
4255 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4256 WMITLV_GET_STRUCT_TLVLEN(
4257 wmi_peer_set_rate_report_condition_fixed_param));
4258
4259 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4260 cmd->report_backoff_time = rate_report_params->backoff_time;
4261 cmd->report_timer_period = rate_report_params->timer_period;
4262 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4263 cmd->cond_per_phy[i].val_cond_flags =
4264 rate_report_params->report_per_phy[i].cond_flags;
4265 cmd->cond_per_phy[i].rate_delta.min_delta =
4266 rate_report_params->report_per_phy[i].delta.delta_min;
4267 cmd->cond_per_phy[i].rate_delta.percentage =
4268 rate_report_params->report_per_phy[i].delta.percent;
4269 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4270 cmd->cond_per_phy[i].rate_threshold[j] =
4271 rate_report_params->report_per_phy[i].
4272 report_rate_threshold[j];
4273 }
4274 }
4275
4276 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4277 cmd->enable_rate_report,
4278 cmd->report_backoff_time, cmd->report_timer_period);
4279
4280 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4281 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4282 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304283 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304284 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4285 __func__);
4286 }
4287 return status;
4288}
4289
4290/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304291 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4292 * @wmi_handle: wmi handle
4293 * @param: bcn ll cmd parameter
4294 *
Govind Singhb53420c2016-03-09 14:32:57 +05304295 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304296 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304297static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304298 wmi_bcn_send_from_host_cmd_fixed_param *param)
4299{
4300 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4301 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304302 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304303
4304 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4305 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304306 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4307 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304308 }
4309
4310 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4311 WMITLV_SET_HDR(&cmd->tlv_header,
4312 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4313 WMITLV_GET_STRUCT_TLVLEN
4314 (wmi_bcn_send_from_host_cmd_fixed_param));
4315 cmd->vdev_id = param->vdev_id;
4316 cmd->data_len = param->data_len;
4317 cmd->frame_ctrl = param->frame_ctrl;
4318 cmd->frag_ptr = param->frag_ptr;
4319 cmd->dtim_flag = param->dtim_flag;
4320
4321 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4322 WMI_PDEV_SEND_BCN_CMDID);
4323
Govind Singh67922e82016-04-01 16:48:57 +05304324 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304325 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304326 wmi_buf_free(wmi_buf);
4327 }
4328
4329 return ret;
4330}
4331
4332/**
4333 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4334 * @wmi_handle: wmi handle
4335 * @vdev_id: vdev id
4336 * @max_retries: max retries
4337 * @retry_interval: retry interval
4338 * This function sets sta query related parameters in fw.
4339 *
Govind Singhb53420c2016-03-09 14:32:57 +05304340 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304341 */
4342
Sathish Kumarfd347372017-02-13 12:29:09 +05304343static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304344 uint8_t vdev_id, uint32_t max_retries,
4345 uint32_t retry_interval)
4346{
4347 wmi_buf_t buf;
4348 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4349 int len;
4350
4351 len = sizeof(*cmd);
4352 buf = wmi_buf_alloc(wmi_handle, len);
4353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGE(FL("wmi_buf_alloc failed"));
4355 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304356 }
4357
4358 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4359 WMITLV_SET_HDR(&cmd->tlv_header,
4360 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4361 WMITLV_GET_STRUCT_TLVLEN
4362 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4363
4364
4365 cmd->vdev_id = vdev_id;
4366 cmd->sa_query_max_retry_count = max_retries;
4367 cmd->sa_query_retry_interval = retry_interval;
4368
Govind Singhb53420c2016-03-09 14:32:57 +05304369 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304370 vdev_id, retry_interval, max_retries);
4371
4372 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4373 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304374 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304376 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304377 }
4378
Govind Singhb53420c2016-03-09 14:32:57 +05304379 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304380 return 0;
4381}
4382
4383/**
4384 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4385 * @wmi_handle: wmi handle
4386 * @params: sta keep alive parameter
4387 *
4388 * This function sets keep alive related parameters in fw.
4389 *
4390 * Return: CDF status
4391 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304392static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304393 struct sta_params *params)
4394{
4395 wmi_buf_t buf;
4396 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4397 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4398 uint8_t *buf_ptr;
4399 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304400 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304401
Govind Singhb53420c2016-03-09 14:32:57 +05304402 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304403
Govind Singh4eacd2b2016-03-07 14:24:22 +05304404 len = sizeof(*cmd) + sizeof(*arp_rsp);
4405 buf = wmi_buf_alloc(wmi_handle, len);
4406 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304407 WMI_LOGE("wmi_buf_alloc failed");
4408 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304409 }
4410
4411 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4412 buf_ptr = (uint8_t *) cmd;
4413 WMITLV_SET_HDR(&cmd->tlv_header,
4414 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4415 WMITLV_GET_STRUCT_TLVLEN
4416 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4417 cmd->interval = params->timeperiod;
4418 cmd->enable = (params->timeperiod) ? 1 : 0;
4419 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304420 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304421 params->timeperiod, params->method);
4422 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4423 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4424 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4425 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4426
4427 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4428 if ((NULL == params->hostv4addr) ||
4429 (NULL == params->destv4addr) ||
4430 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304431 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304432 "destv4addr:%p destmac:%p ", __func__,
4433 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304434 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304435 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304436 }
4437 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304438 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304439 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304440 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304441 WMI_IPV4_ADDR_LEN);
4442 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4443 } else {
4444 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4445 }
4446
Govind Singh67922e82016-04-01 16:48:57 +05304447 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4448 WMI_STA_KEEPALIVE_CMDID);
4449 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304450 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304451 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304452 }
4453
Govind Singhb53420c2016-03-09 14:32:57 +05304454 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304455 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304456}
4457
4458/**
4459 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4460 * @wmi_handle: wmi handle
4461 * @if_id: vdev id
4462 * @gtx_info: GTX config params
4463 *
4464 * This function set GTX related params in firmware.
4465 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304466 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304467 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304468static 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 +05304469 struct wmi_gtx_config *gtx_info)
4470{
4471 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4472 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304473 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304474 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304475
Govind Singh4eacd2b2016-03-07 14:24:22 +05304476 buf = wmi_buf_alloc(wmi_handle, len);
4477 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304478 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304479 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304480 }
4481 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4482 WMITLV_SET_HDR(&cmd->tlv_header,
4483 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4484 WMITLV_GET_STRUCT_TLVLEN
4485 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4486 cmd->vdev_id = if_id;
4487
4488 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4489 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4490 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4491 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4492 cmd->gtxPERMargin = gtx_info->gtx_margin;
4493 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4494 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4495 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4496
Govind Singhb53420c2016-03-09 14:32:57 +05304497 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304498 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4499 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4500 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4501 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4502
Abhishek Singh716c46c2016-05-04 16:24:07 +05304503 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304504 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304505 if (QDF_IS_STATUS_ERROR(ret)) {
4506 WMI_LOGE("Failed to set GTX PARAMS");
4507 wmi_buf_free(buf);
4508 }
4509 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304510}
4511
4512/**
4513 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4514 * @wmi_handle: wmi handle
4515 * @edca_params: edca parameters
4516 *
4517 * This function updates EDCA parameters to the target
4518 *
4519 * Return: CDF Status
4520 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304521static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304522 uint8_t vdev_id,
4523 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4524{
4525 uint8_t *buf_ptr;
4526 wmi_buf_t buf;
4527 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4528 wmi_wmm_vparams *wmm_param, *twmm_param;
4529 int len = sizeof(*cmd);
4530 int ac;
4531
4532 buf = wmi_buf_alloc(wmi_handle, len);
4533
4534 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4536 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 }
4538
4539 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4540 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4541 WMITLV_SET_HDR(&cmd->tlv_header,
4542 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4543 WMITLV_GET_STRUCT_TLVLEN
4544 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4545 cmd->vdev_id = vdev_id;
4546
4547 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4548 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4549 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4550 WMITLV_SET_HDR(&wmm_param->tlv_header,
4551 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4552 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4553 wmm_param->cwmin = twmm_param->cwmin;
4554 wmm_param->cwmax = twmm_param->cwmax;
4555 wmm_param->aifs = twmm_param->aifs;
4556 wmm_param->txoplimit = twmm_param->txoplimit;
4557 wmm_param->acm = twmm_param->acm;
4558 wmm_param->no_ack = twmm_param->no_ack;
4559 }
4560
4561 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4562 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4563 goto fail;
4564
Govind Singhb53420c2016-03-09 14:32:57 +05304565 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304566
4567fail:
4568 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304569 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4570 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304571}
4572
4573/**
4574 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4575 * @wmi_handle: wmi handle
4576 * @vdev_id: vdev id
4577 * @probe_rsp_info: probe response info
4578 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304579 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304581static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304582 uint8_t vdev_id,
4583 struct wmi_probe_resp_params *probe_rsp_info,
4584 uint8_t *frm)
4585{
4586 wmi_prb_tmpl_cmd_fixed_param *cmd;
4587 wmi_bcn_prb_info *bcn_prb_info;
4588 wmi_buf_t wmi_buf;
4589 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4590 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304591 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304592
Govind Singhb53420c2016-03-09 14:32:57 +05304593 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304594
4595 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4596 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4597
4598 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4599 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4600 tmpl_len_aligned;
4601
4602 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304603 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304604 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304605 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304606 }
4607
4608 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4609 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304610 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304611 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304612 }
4613
4614 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4615
4616 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4617 WMITLV_SET_HDR(&cmd->tlv_header,
4618 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4619 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4620 cmd->vdev_id = vdev_id;
4621 cmd->buf_len = tmpl_len;
4622 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4623
4624 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4625 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4626 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4627 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4628 bcn_prb_info->caps = 0;
4629 bcn_prb_info->erp = 0;
4630 buf_ptr += sizeof(wmi_bcn_prb_info);
4631
4632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4633 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304634 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304635
4636 ret = wmi_unified_cmd_send(wmi_handle,
4637 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304638 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304639 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304640 wmi_buf_free(wmi_buf);
4641 }
4642
4643 return ret;
4644}
4645
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304646#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304647#define WPI_IV_LEN 16
4648
4649/**
4650 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4651 *
4652 * @dest_tx: destination address of tsc key counter
4653 * @src_tx: source address of tsc key counter
4654 * @dest_rx: destination address of rsc key counter
4655 * @src_rx: source address of rsc key counter
4656 *
4657 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4658 *
4659 * Return: None
4660 *
4661 */
4662static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4663 uint8_t *dest_rx, uint8_t *src_rx)
4664{
4665 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4666 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4667}
4668#else
4669static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4670 uint8_t *dest_rx, uint8_t *src_rx)
4671{
4672 return;
4673}
4674#endif
4675
4676/**
4677 * send_setup_install_key_cmd_tlv() - set key parameters
4678 * @wmi_handle: wmi handle
4679 * @key_params: key parameters
4680 *
4681 * This function fills structure from information
4682 * passed in key_params.
4683 *
4684 * Return: QDF_STATUS_SUCCESS - success
4685 * QDF_STATUS_E_FAILURE - failure
4686 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4687 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304688static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304689 struct set_key_params *key_params)
4690{
4691 wmi_vdev_install_key_cmd_fixed_param *cmd;
4692 wmi_buf_t buf;
4693 uint8_t *buf_ptr;
4694 uint32_t len;
4695 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304696 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304697
4698 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4699 WMI_TLV_HDR_SIZE;
4700
4701 buf = wmi_buf_alloc(wmi_handle, len);
4702 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304703 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304704 return QDF_STATUS_E_NOMEM;
4705 }
4706
4707 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4708 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4709 WMITLV_SET_HDR(&cmd->tlv_header,
4710 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4711 WMITLV_GET_STRUCT_TLVLEN
4712 (wmi_vdev_install_key_cmd_fixed_param));
4713 cmd->vdev_id = key_params->vdev_id;
4714 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304715
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304716
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304717 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4718 cmd->key_flags |= key_params->key_flags;
4719 cmd->key_cipher = key_params->key_cipher;
4720 if ((key_params->key_txmic_len) &&
4721 (key_params->key_rxmic_len)) {
4722 cmd->key_txmic_len = key_params->key_txmic_len;
4723 cmd->key_rxmic_len = key_params->key_rxmic_len;
4724 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304725#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304726 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4727 key_params->tx_iv,
4728 cmd->wpi_key_rsc_counter,
4729 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304730#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304731 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4732 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4733 roundup(key_params->key_len, sizeof(uint32_t)));
4734 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4735 qdf_mem_copy((void *)key_data,
4736 (const void *)key_params->key_data, key_params->key_len);
4737 cmd->key_len = key_params->key_len;
4738
4739 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4740 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304741 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304742 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304743
Govind Singh67922e82016-04-01 16:48:57 +05304744 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304745}
4746
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304747/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004748 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4749 * @wmi_handle: wmi handle
4750 * @params: sar limit params
4751 *
4752 * Return: QDF_STATUS_SUCCESS for success or error code
4753 */
4754static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4755 struct sar_limit_cmd_params *sar_limit_params)
4756{
4757 wmi_buf_t buf;
4758 QDF_STATUS qdf_status;
4759 wmi_sar_limits_cmd_fixed_param *cmd;
4760 int i;
4761 uint8_t *buf_ptr;
4762 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4763 struct sar_limit_cmd_row *sar_rows_list;
4764 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4765
4766 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4767 buf = wmi_buf_alloc(wmi_handle, len);
4768 if (!buf) {
4769 WMI_LOGE("Failed to allocate memory");
4770 qdf_status = QDF_STATUS_E_NOMEM;
4771 goto end;
4772 }
4773
4774 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4775 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4776 WMITLV_SET_HDR(&cmd->tlv_header,
4777 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4778 WMITLV_GET_STRUCT_TLVLEN
4779 (wmi_sar_limits_cmd_fixed_param));
4780 cmd->sar_enable = sar_limit_params->sar_enable;
4781 cmd->commit_limits = sar_limit_params->commit_limits;
4782 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4783
4784 WMI_LOGD("no of sar rows = %d, len = %d",
4785 sar_limit_params->num_limit_rows, len);
4786 buf_ptr += sizeof(*cmd);
4787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4788 sizeof(wmi_sar_limit_cmd_row) *
4789 sar_limit_params->num_limit_rows);
4790 if (cmd->num_limit_rows == 0)
4791 goto send_sar_limits;
4792
4793 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4794 (buf_ptr + WMI_TLV_HDR_SIZE);
4795 sar_rows_list = sar_limit_params->sar_limit_row_list;
4796
4797 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4798 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4799 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4800 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4801 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4802 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4803 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4804 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4805 wmi_sar_rows_list->validity_bitmap =
4806 sar_rows_list->validity_bitmap;
4807 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4808 i, wmi_sar_rows_list->band_id,
4809 wmi_sar_rows_list->chain_id,
4810 wmi_sar_rows_list->mod_id,
4811 wmi_sar_rows_list->limit_value,
4812 wmi_sar_rows_list->validity_bitmap);
4813 sar_rows_list++;
4814 wmi_sar_rows_list++;
4815 }
4816send_sar_limits:
4817 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4818 WMI_SAR_LIMITS_CMDID);
4819
4820 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4821 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4822 wmi_buf_free(buf);
4823 }
4824
4825end:
4826 return qdf_status;
4827}
4828
4829/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304830 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4831 * @wmi_handle: wmi handle
4832 * @params: encrypt/decrypt params
4833 *
4834 * Return: QDF_STATUS_SUCCESS for success or error code
4835 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004836static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304837QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4838 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4839{
4840 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4841 wmi_buf_t wmi_buf;
4842 uint8_t *buf_ptr;
4843 QDF_STATUS ret;
4844 uint32_t len;
4845
4846 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4847
4848 len = sizeof(*cmd) +
4849 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4850 WMI_TLV_HDR_SIZE;
4851 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4852 if (!wmi_buf) {
4853 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4854 __func__);
4855 return QDF_STATUS_E_NOMEM;
4856 }
4857
4858 buf_ptr = wmi_buf_data(wmi_buf);
4859 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4860
4861 WMITLV_SET_HDR(&cmd->tlv_header,
4862 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4863 WMITLV_GET_STRUCT_TLVLEN(
4864 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4865
4866 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4867 cmd->key_flag = encrypt_decrypt_params->key_flag;
4868 cmd->key_idx = encrypt_decrypt_params->key_idx;
4869 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4870 cmd->key_len = encrypt_decrypt_params->key_len;
4871 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4872 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4873
4874 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4875 encrypt_decrypt_params->key_len);
4876
4877 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4878 MAX_MAC_HEADER_LEN);
4879
4880 cmd->data_len = encrypt_decrypt_params->data_len;
4881
4882 if (cmd->data_len) {
4883 buf_ptr += sizeof(*cmd);
4884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4885 roundup(encrypt_decrypt_params->data_len,
4886 sizeof(A_UINT32)));
4887 buf_ptr += WMI_TLV_HDR_SIZE;
4888 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4889 encrypt_decrypt_params->data_len);
4890 }
4891
4892 /* This conversion is to facilitate data to FW in little endian */
4893 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4894 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4895 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4896 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4897 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4898 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4899
4900 ret = wmi_unified_cmd_send(wmi_handle,
4901 wmi_buf, len,
4902 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4903 if (QDF_IS_STATUS_ERROR(ret)) {
4904 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4905 wmi_buf_free(wmi_buf);
4906 }
4907
4908 return ret;
4909}
4910
4911
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304912
Govind Singh4eacd2b2016-03-07 14:24:22 +05304913/**
4914 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4915 * @wmi_handle: wmi handle
4916 * @vdev_id: vdev id
4917 * @p2p_ie: p2p IE
4918 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304919 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304920 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304921static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304922 A_UINT32 vdev_id, uint8_t *p2p_ie)
4923{
Govind Singh67922e82016-04-01 16:48:57 +05304924 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304925 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4926 wmi_buf_t wmi_buf;
4927 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4928 uint8_t *buf_ptr;
4929
4930 ie_len = (uint32_t) (p2p_ie[1] + 2);
4931
4932 /* More than one P2P IE may be included in a single frame.
4933 If multiple P2P IEs are present, the complete P2P attribute
4934 data consists of the concatenation of the P2P Attribute
4935 fields of the P2P IEs. The P2P Attributes field of each
4936 P2P IE may be any length up to the maximum (251 octets).
4937 In this case host sends one P2P IE to firmware so the length
4938 should not exceed more than 251 bytes
4939 */
4940 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304941 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304942 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304943 }
4944
4945 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4946
4947 wmi_buf_len =
4948 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4949 WMI_TLV_HDR_SIZE;
4950
4951 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4952 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304953 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304954 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304955 }
4956
4957 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4958
4959 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4960 WMITLV_SET_HDR(&cmd->tlv_header,
4961 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4962 WMITLV_GET_STRUCT_TLVLEN
4963 (wmi_p2p_go_set_beacon_ie_fixed_param));
4964 cmd->vdev_id = vdev_id;
4965 cmd->ie_buf_len = ie_len;
4966
4967 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4968 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4969 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304970 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304971
Govind Singhb53420c2016-03-09 14:32:57 +05304972 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304973
4974 ret = wmi_unified_cmd_send(wmi_handle,
4975 wmi_buf, wmi_buf_len,
4976 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304977 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304978 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304979 wmi_buf_free(wmi_buf);
4980 }
4981
Govind Singhb53420c2016-03-09 14:32:57 +05304982 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304983 return ret;
4984}
4985
4986/**
4987 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4988 * @wmi_handle: wmi handle
4989 * @req: gateway parameter update request structure
4990 *
4991 * This function reads the incoming @req and fill in the destination
4992 * WMI structure and sends down the gateway configs down to the firmware
4993 *
Govind Singhb53420c2016-03-09 14:32:57 +05304994 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304995 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304996static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304997 struct gateway_update_req_param *req)
4998{
4999 wmi_roam_subnet_change_config_fixed_param *cmd;
5000 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305001 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305002 int len = sizeof(*cmd);
5003
5004 buf = wmi_buf_alloc(wmi_handle, len);
5005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305006 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5007 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305008 }
5009
5010 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5011 WMITLV_SET_HDR(&cmd->tlv_header,
5012 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5013 WMITLV_GET_STRUCT_TLVLEN(
5014 wmi_roam_subnet_change_config_fixed_param));
5015
5016 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305017 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5018 QDF_IPV4_ADDR_SIZE);
5019 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5020 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5022 &cmd->inet_gw_mac_addr);
5023 cmd->max_retries = req->max_retries;
5024 cmd->timeout = req->timeout;
5025 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5026 cmd->flag = 0;
5027 if (req->ipv4_addr_type)
5028 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5029
5030 if (req->ipv6_addr_type)
5031 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5032
5033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5034 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305035 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305036 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305037 ret);
5038 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305039 }
5040
Govind Singh67922e82016-04-01 16:48:57 +05305041 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305042}
5043
5044/**
5045 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5046 * @wmi_handle: wmi handle
5047 * @req: rssi monitoring request structure
5048 *
5049 * This function reads the incoming @req and fill in the destination
5050 * WMI structure and send down the rssi monitoring configs down to the firmware
5051 *
5052 * Return: 0 on success; error number otherwise
5053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305054static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305055 struct rssi_monitor_param *req)
5056{
5057 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5058 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305059 QDF_STATUS ret;
5060 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305061
5062 buf = wmi_buf_alloc(wmi_handle, len);
5063 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305064 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5065 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305066 }
5067
5068 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5069 WMITLV_SET_HDR(&cmd->tlv_header,
5070 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5071 WMITLV_GET_STRUCT_TLVLEN(
5072 wmi_rssi_breach_monitor_config_fixed_param));
5073
5074 cmd->vdev_id = req->session_id;
5075 cmd->request_id = req->request_id;
5076 cmd->lo_rssi_reenable_hysteresis = 0;
5077 cmd->hi_rssi_reenable_histeresis = 0;
5078 cmd->min_report_interval = 0;
5079 cmd->max_num_report = 1;
5080 if (req->control) {
5081 /* enable one threshold for each min/max */
5082 cmd->enabled_bitmap = 0x09;
5083 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5084 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5085 } else {
5086 cmd->enabled_bitmap = 0;
5087 cmd->low_rssi_breach_threshold[0] = 0;
5088 cmd->hi_rssi_breach_threshold[0] = 0;
5089 }
5090
5091 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5092 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305093 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305094 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 }
5097
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005098 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5099
Govind Singh67922e82016-04-01 16:48:57 +05305100 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305101}
5102
5103/**
5104 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5105 * @wmi_handle: wmi handle
5106 * @psetoui: OUI parameters
5107 *
5108 * set scan probe OUI parameters in firmware
5109 *
5110 * Return: CDF status
5111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305112static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113 struct scan_mac_oui *psetoui)
5114{
5115 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5116 wmi_buf_t wmi_buf;
5117 uint32_t len;
5118 uint8_t *buf_ptr;
5119 uint32_t *oui_buf;
5120
5121 len = sizeof(*cmd);
5122 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5123 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305124 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5125 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305126 }
5127 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5128 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5129 WMITLV_SET_HDR(&cmd->tlv_header,
5130 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5131 WMITLV_GET_STRUCT_TLVLEN
5132 (wmi_scan_prob_req_oui_cmd_fixed_param));
5133
5134 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305135 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305136 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5137 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305138 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305139 cmd->prob_req_oui);
5140
5141 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5142 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305143 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305144 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305145 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305146 }
Govind Singhb53420c2016-03-09 14:32:57 +05305147 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305148}
5149
5150/**
5151 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5152 * @wmi_handle: wmi handle
5153 * @req: passpoint network request structure
5154 *
5155 * This function sends down WMI command with network id set to wildcard id.
5156 * firmware shall clear all the config entries
5157 *
Govind Singhb53420c2016-03-09 14:32:57 +05305158 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305159 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305160static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305161 struct wifi_passpoint_req_param *req)
5162{
5163 wmi_passpoint_config_cmd_fixed_param *cmd;
5164 wmi_buf_t buf;
5165 uint32_t len;
5166 int ret;
5167
5168 len = sizeof(*cmd);
5169 buf = wmi_buf_alloc(wmi_handle, len);
5170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305171 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5172 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305173 }
5174
5175 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5176
5177 WMITLV_SET_HDR(&cmd->tlv_header,
5178 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5179 WMITLV_GET_STRUCT_TLVLEN(
5180 wmi_passpoint_config_cmd_fixed_param));
5181 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5182
5183 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5184 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5185 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305186 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305187 __func__);
5188 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305189 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305190 }
5191
Govind Singhb53420c2016-03-09 14:32:57 +05305192 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305193}
5194
5195/**
5196 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5197 * @wmi_handle: wmi handle
5198 * @req: passpoint network request structure
5199 *
5200 * This function reads the incoming @req and fill in the destination
5201 * WMI structure and send down the passpoint configs down to the firmware
5202 *
Govind Singhb53420c2016-03-09 14:32:57 +05305203 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305205static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305206 struct wifi_passpoint_req_param *req)
5207{
5208 wmi_passpoint_config_cmd_fixed_param *cmd;
5209 u_int8_t i, j, *bytes;
5210 wmi_buf_t buf;
5211 uint32_t len;
5212 int ret;
5213
5214 len = sizeof(*cmd);
5215 for (i = 0; i < req->num_networks; i++) {
5216 buf = wmi_buf_alloc(wmi_handle, len);
5217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305218 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5219 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 }
5221
5222 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5223 wmi_buf_data(buf);
5224
5225 WMITLV_SET_HDR(&cmd->tlv_header,
5226 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5227 WMITLV_GET_STRUCT_TLVLEN(
5228 wmi_passpoint_config_cmd_fixed_param));
5229 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305230 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5231 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305233 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5235 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305236 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237 j, bytes[0], bytes[1], bytes[2], bytes[3],
5238 bytes[4], bytes[5], bytes[6], bytes[7]);
5239
Govind Singhb53420c2016-03-09 14:32:57 +05305240 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305241 &req->networks[i].roaming_consortium_ids[j],
5242 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5243 }
Govind Singhb53420c2016-03-09 14:32:57 +05305244 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305245 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305246 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5248
5249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5250 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5251 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305252 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 __func__);
5254 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305255 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256 }
5257 }
5258
Govind Singhb53420c2016-03-09 14:32:57 +05305259 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305260}
5261
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305262/**
5263 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5264 * @wmi_handle: wmi handle
5265 * @scan_cmd_fp: start scan command ptr
5266 * @roam_req: roam request param
5267 *
5268 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5269 * of WMI_ROAM_SCAN_MODE.
5270 *
5271 * Return: QDF status
5272 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305273static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305274 wmi_start_scan_cmd_fixed_param *
5275 scan_cmd_fp,
5276 struct roam_offload_scan_params *roam_req)
5277{
5278 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305279 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305280 int len;
5281 uint8_t *buf_ptr;
5282 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305283
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305284#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5285 int auth_mode = roam_req->auth_mode;
5286 wmi_roam_offload_tlv_param *roam_offload_params;
5287 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5288 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5289 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305290 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305291#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5292 /* Need to create a buf with roam_scan command at
5293 * front and piggyback with scan command */
5294 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5295#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5296 (2 * WMI_TLV_HDR_SIZE) +
5297#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5298 sizeof(wmi_start_scan_cmd_fixed_param);
5299#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5300 if (roam_req->is_roam_req_valid &&
5301 roam_req->roam_offload_enabled) {
5302 len += sizeof(wmi_roam_offload_tlv_param);
5303 len += WMI_TLV_HDR_SIZE;
5304 if ((auth_mode != WMI_AUTH_NONE) &&
5305 ((auth_mode != WMI_AUTH_OPEN) ||
5306 (auth_mode == WMI_AUTH_OPEN &&
5307 roam_req->mdid.mdie_present) ||
5308 roam_req->is_ese_assoc)) {
5309 len += WMI_TLV_HDR_SIZE;
5310 if (roam_req->is_ese_assoc)
5311 len +=
5312 sizeof(wmi_roam_ese_offload_tlv_param);
5313 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5314 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5315 (auth_mode == WMI_AUTH_OPEN &&
5316 roam_req->mdid.mdie_present))
5317 len +=
5318 sizeof(wmi_roam_11r_offload_tlv_param);
5319 else
5320 len +=
5321 sizeof(wmi_roam_11i_offload_tlv_param);
5322 } else {
5323 len += WMI_TLV_HDR_SIZE;
5324 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305325
5326 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5327 + roundup(roam_req->assoc_ie_length,
5328 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305329 } else {
5330 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305331 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305332 __func__, roam_req->roam_offload_enabled);
5333 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305334 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305335 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305336 }
5337 if (roam_req->is_roam_req_valid &&
5338 roam_req->roam_offload_enabled) {
5339 roam_req->mode = roam_req->mode |
5340 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5341 }
5342#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5343
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305344 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5345 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5346 len = sizeof(wmi_roam_scan_mode_fixed_param);
5347
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305348 buf = wmi_buf_alloc(wmi_handle, len);
5349 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305350 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305351 return QDF_STATUS_E_NOMEM;
5352 }
5353
5354 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305355
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305356 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5357 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5358 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5359 WMITLV_GET_STRUCT_TLVLEN
5360 (wmi_roam_scan_mode_fixed_param));
5361
5362 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5363 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305364 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5365 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5366 roam_scan_mode_fp->flags |=
5367 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305368 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305369 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305370
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305371 /* Fill in scan parameters suitable for roaming scan */
5372 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305373
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305374 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5375 sizeof(wmi_start_scan_cmd_fixed_param));
5376 /* Ensure there is no additional IEs */
5377 scan_cmd_fp->ie_len = 0;
5378 WMITLV_SET_HDR(buf_ptr,
5379 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5380 WMITLV_GET_STRUCT_TLVLEN
5381 (wmi_start_scan_cmd_fixed_param));
5382#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5383 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5384 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5385 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5386 sizeof(wmi_roam_offload_tlv_param));
5387 buf_ptr += WMI_TLV_HDR_SIZE;
5388 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5389 WMITLV_SET_HDR(buf_ptr,
5390 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5391 WMITLV_GET_STRUCT_TLVLEN
5392 (wmi_roam_offload_tlv_param));
5393 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5394 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5395 roam_offload_params->select_5g_margin =
5396 roam_req->select_5ghz_margin;
5397 roam_offload_params->reassoc_failure_timeout =
5398 roam_req->reassoc_failure_timeout;
5399
5400 /* Fill the capabilities */
5401 roam_offload_params->capability =
5402 roam_req->roam_offload_params.capability;
5403 roam_offload_params->ht_caps_info =
5404 roam_req->roam_offload_params.ht_caps_info;
5405 roam_offload_params->ampdu_param =
5406 roam_req->roam_offload_params.ampdu_param;
5407 roam_offload_params->ht_ext_cap =
5408 roam_req->roam_offload_params.ht_ext_cap;
5409 roam_offload_params->ht_txbf =
5410 roam_req->roam_offload_params.ht_txbf;
5411 roam_offload_params->asel_cap =
5412 roam_req->roam_offload_params.asel_cap;
5413 roam_offload_params->qos_caps =
5414 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005415 roam_offload_params->qos_enabled =
5416 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305417 roam_offload_params->wmm_caps =
5418 roam_req->roam_offload_params.wmm_caps;
5419 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5420 (uint8_t *)roam_req->roam_offload_params.mcsset,
5421 ROAM_OFFLOAD_NUM_MCS_SET);
5422
5423 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5424 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5425 * they are filled in the same order.Depending on the
5426 * authentication type, the other mode TLV's are nullified
5427 * and only headers are filled.*/
5428 if ((auth_mode != WMI_AUTH_NONE) &&
5429 ((auth_mode != WMI_AUTH_OPEN) ||
5430 (auth_mode == WMI_AUTH_OPEN
5431 && roam_req->mdid.mdie_present) ||
5432 roam_req->is_ese_assoc)) {
5433 if (roam_req->is_ese_assoc) {
5434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5435 WMITLV_GET_STRUCT_TLVLEN(0));
5436 buf_ptr += WMI_TLV_HDR_SIZE;
5437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5438 WMITLV_GET_STRUCT_TLVLEN(0));
5439 buf_ptr += WMI_TLV_HDR_SIZE;
5440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5441 sizeof(wmi_roam_ese_offload_tlv_param));
5442 buf_ptr += WMI_TLV_HDR_SIZE;
5443 roam_offload_ese =
5444 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5445 qdf_mem_copy(roam_offload_ese->krk,
5446 roam_req->krk,
5447 sizeof(roam_req->krk));
5448 qdf_mem_copy(roam_offload_ese->btk,
5449 roam_req->btk,
5450 sizeof(roam_req->btk));
5451 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5452 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5453 WMITLV_GET_STRUCT_TLVLEN
5454 (wmi_roam_ese_offload_tlv_param));
5455 buf_ptr +=
5456 sizeof(wmi_roam_ese_offload_tlv_param);
5457 } else if (auth_mode == WMI_AUTH_FT_RSNA
5458 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5459 || (auth_mode == WMI_AUTH_OPEN
5460 && roam_req->mdid.mdie_present)) {
5461 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5462 0);
5463 buf_ptr += WMI_TLV_HDR_SIZE;
5464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5465 sizeof(wmi_roam_11r_offload_tlv_param));
5466 buf_ptr += WMI_TLV_HDR_SIZE;
5467 roam_offload_11r =
5468 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5469 roam_offload_11r->r0kh_id_len =
5470 roam_req->rokh_id_length;
5471 qdf_mem_copy(roam_offload_11r->r0kh_id,
5472 roam_req->rokh_id,
5473 roam_offload_11r->r0kh_id_len);
5474 qdf_mem_copy(roam_offload_11r->psk_msk,
5475 roam_req->psk_pmk,
5476 sizeof(roam_req->psk_pmk));
5477 roam_offload_11r->psk_msk_len =
5478 roam_req->pmk_len;
5479 roam_offload_11r->mdie_present =
5480 roam_req->mdid.mdie_present;
5481 roam_offload_11r->mdid =
5482 roam_req->mdid.mobility_domain;
5483 if (auth_mode == WMI_AUTH_OPEN) {
5484 /* If FT-Open ensure pmk length
5485 and r0khid len are zero */
5486 roam_offload_11r->r0kh_id_len = 0;
5487 roam_offload_11r->psk_msk_len = 0;
5488 }
5489 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5490 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5491 WMITLV_GET_STRUCT_TLVLEN
5492 (wmi_roam_11r_offload_tlv_param));
5493 buf_ptr +=
5494 sizeof(wmi_roam_11r_offload_tlv_param);
5495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5496 WMITLV_GET_STRUCT_TLVLEN(0));
5497 buf_ptr += WMI_TLV_HDR_SIZE;
5498 } else {
5499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5500 sizeof(wmi_roam_11i_offload_tlv_param));
5501 buf_ptr += WMI_TLV_HDR_SIZE;
5502 roam_offload_11i =
5503 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005504
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005505 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005506 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305507 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5508 (roam_offload_11i->flags);
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005509 WMI_LOGE("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305510 } else {
5511 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5512 (roam_offload_11i->flags);
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005513 WMI_LOGE("LFR3:OKC disabled");
5514 }
5515 if (roam_req->roam_key_mgmt_offload_enabled &&
5516 roam_req->fw_pmksa_cache) {
5517 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5518 (roam_offload_11i->flags);
5519 WMI_LOGE("LFR3:PMKSA caching enabled");
5520 } else {
5521 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5522 (roam_offload_11i->flags);
5523 WMI_LOGE("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305524 }
5525
5526 qdf_mem_copy(roam_offload_11i->pmk,
5527 roam_req->psk_pmk,
5528 sizeof(roam_req->psk_pmk));
5529 roam_offload_11i->pmk_len = roam_req->pmk_len;
5530 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5531 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5532 WMITLV_GET_STRUCT_TLVLEN
5533 (wmi_roam_11i_offload_tlv_param));
5534 buf_ptr +=
5535 sizeof(wmi_roam_11i_offload_tlv_param);
5536 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5537 0);
5538 buf_ptr += WMI_TLV_HDR_SIZE;
5539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5540 0);
5541 buf_ptr += WMI_TLV_HDR_SIZE;
5542 }
5543 } else {
5544 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5545 WMITLV_GET_STRUCT_TLVLEN(0));
5546 buf_ptr += WMI_TLV_HDR_SIZE;
5547 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5548 WMITLV_GET_STRUCT_TLVLEN(0));
5549 buf_ptr += WMI_TLV_HDR_SIZE;
5550 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5551 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305552 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305553 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305554
5555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5556 sizeof(*assoc_ies));
5557 buf_ptr += WMI_TLV_HDR_SIZE;
5558
5559 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5560 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5561 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5562 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5563 assoc_ies->buf_len = roam_req->assoc_ie_length;
5564
5565 buf_ptr += sizeof(*assoc_ies);
5566
5567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5568 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5569 buf_ptr += WMI_TLV_HDR_SIZE;
5570
5571 if (assoc_ies->buf_len != 0) {
5572 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5573 assoc_ies->buf_len);
5574 }
5575
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305576 } else {
5577 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5578 WMITLV_GET_STRUCT_TLVLEN(0));
5579 buf_ptr += WMI_TLV_HDR_SIZE;
5580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5581 WMITLV_GET_STRUCT_TLVLEN(0));
5582 buf_ptr += WMI_TLV_HDR_SIZE;
5583 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5584 WMITLV_GET_STRUCT_TLVLEN(0));
5585 buf_ptr += WMI_TLV_HDR_SIZE;
5586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5587 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305588 buf_ptr += WMI_TLV_HDR_SIZE;
5589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5590 WMITLV_GET_STRUCT_TLVLEN(0));
5591 buf_ptr += WMI_TLV_HDR_SIZE;
5592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5593 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305594 }
5595#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305596
5597send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305598 status = wmi_unified_cmd_send(wmi_handle, buf,
5599 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305600 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305601 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305602 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5603 status);
5604 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305605 }
5606
Govind Singh67922e82016-04-01 16:48:57 +05305607 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305608}
5609
5610
5611/**
5612 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5613 * rssi threashold
5614 * @wmi_handle: wmi handle
5615 * @roam_req: Roaming request buffer
5616 *
5617 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5618 *
5619 * Return: QDF status
5620 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305621static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305622 struct roam_offload_scan_rssi_params *roam_req)
5623{
5624 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305625 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305626 int len;
5627 uint8_t *buf_ptr;
5628 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5629 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5630 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305631 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305632
5633 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5634 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5635 len += sizeof(wmi_roam_scan_extended_threshold_param);
5636 len += WMI_TLV_HDR_SIZE;
5637 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305638 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5639 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305640 buf = wmi_buf_alloc(wmi_handle, len);
5641 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305643 return QDF_STATUS_E_NOMEM;
5644 }
5645
5646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5647 rssi_threshold_fp =
5648 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5649 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5650 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5651 WMITLV_GET_STRUCT_TLVLEN
5652 (wmi_roam_scan_rssi_threshold_fixed_param));
5653 /* fill in threshold values */
5654 rssi_threshold_fp->vdev_id = roam_req->session_id;
5655 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5656 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5657 rssi_threshold_fp->hirssi_scan_max_count =
5658 roam_req->hi_rssi_scan_max_count;
5659 rssi_threshold_fp->hirssi_scan_delta =
5660 roam_req->hi_rssi_scan_rssi_delta;
5661 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5662
5663 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5664 WMITLV_SET_HDR(buf_ptr,
5665 WMITLV_TAG_ARRAY_STRUC,
5666 sizeof(wmi_roam_scan_extended_threshold_param));
5667 buf_ptr += WMI_TLV_HDR_SIZE;
5668 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5669
5670 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5671 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5672 ext_thresholds->boost_threshold_5g =
5673 roam_req->boost_threshold_5g;
5674
5675 ext_thresholds->boost_algorithm_5g =
5676 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5677 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5678 ext_thresholds->penalty_algorithm_5g =
5679 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5680 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5681 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5682 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5683 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5684
5685 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5686 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5687 WMITLV_GET_STRUCT_TLVLEN
5688 (wmi_roam_scan_extended_threshold_param));
5689 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5690 WMITLV_SET_HDR(buf_ptr,
5691 WMITLV_TAG_ARRAY_STRUC,
5692 sizeof(wmi_roam_earlystop_rssi_thres_param));
5693 buf_ptr += WMI_TLV_HDR_SIZE;
5694 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5695 early_stop_thresholds->roam_earlystop_thres_min =
5696 roam_req->roam_earlystop_thres_min;
5697 early_stop_thresholds->roam_earlystop_thres_max =
5698 roam_req->roam_earlystop_thres_max;
5699 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5700 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5701 WMITLV_GET_STRUCT_TLVLEN
5702 (wmi_roam_earlystop_rssi_thres_param));
5703
Gupta, Kapil7e652922016-04-12 15:02:00 +05305704 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5705 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5706 sizeof(wmi_roam_dense_thres_param));
5707 buf_ptr += WMI_TLV_HDR_SIZE;
5708 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5709 dense_thresholds->roam_dense_rssi_thres_offset =
5710 roam_req->dense_rssi_thresh_offset;
5711 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5712 dense_thresholds->roam_dense_traffic_thres =
5713 roam_req->traffic_threshold;
5714 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5715 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5716 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5717 WMITLV_GET_STRUCT_TLVLEN
5718 (wmi_roam_dense_thres_param));
5719
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305720 status = wmi_unified_cmd_send(wmi_handle, buf,
5721 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305722 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305723 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305724 status);
5725 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305726 }
5727
Govind Singh67922e82016-04-01 16:48:57 +05305728 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305729}
5730
5731/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305732 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5733 * configuration params
5734 * @wma_handle: wma handler
5735 * @dwelltime_params: pointer to dwelltime_params
5736 *
5737 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5738 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005739static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305740QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5741 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5742{
5743 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5744 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5745 wmi_buf_t buf;
5746 uint8_t *buf_ptr;
5747 int32_t err;
5748 int len;
5749
5750 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5751 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5752 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5753 buf = wmi_buf_alloc(wmi_handle, len);
5754 if (!buf) {
5755 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5756 __func__);
5757 return QDF_STATUS_E_NOMEM;
5758 }
5759 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5760 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5761 WMITLV_SET_HDR(&dwell_param->tlv_header,
5762 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5763 WMITLV_GET_STRUCT_TLVLEN
5764 (wmi_scan_adaptive_dwell_config_fixed_param));
5765
5766 dwell_param->enable = dwelltime_params->is_enabled;
5767 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5768 WMITLV_SET_HDR(buf_ptr,
5769 WMITLV_TAG_ARRAY_STRUC,
5770 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5771 buf_ptr += WMI_TLV_HDR_SIZE;
5772
5773 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5774 WMITLV_SET_HDR(&cmd->tlv_header,
5775 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5776 WMITLV_GET_STRUCT_TLVLEN(
5777 wmi_scan_adaptive_dwell_parameters_tlv));
5778
5779 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5780 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5781 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5782 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5783 err = wmi_unified_cmd_send(wmi_handle, buf,
5784 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5785 if (err) {
5786 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5787 wmi_buf_free(buf);
5788 return QDF_STATUS_E_FAILURE;
5789 }
5790
5791 return QDF_STATUS_SUCCESS;
5792}
5793
Nitesh Shah52323d02017-05-22 15:49:00 +05305794/**
5795 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
5796 * configuration params
5797 * @wmi_handle: wmi handler
5798 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
5799 *
5800 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5801 */
5802static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
5803 struct wmi_dbs_scan_sel_params *dbs_scan_params)
5804{
5805 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
5806 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
5807 wmi_buf_t buf;
5808 uint8_t *buf_ptr;
5809 QDF_STATUS err;
5810 uint32_t i;
5811 int len;
5812
5813 len = sizeof(*dbs_scan_param);
5814 len += WMI_TLV_HDR_SIZE;
5815 len += dbs_scan_params->num_clients * sizeof(*cmd);
5816
5817 buf = wmi_buf_alloc(wmi_handle, len);
5818 if (!buf) {
5819 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
5820 return QDF_STATUS_E_NOMEM;
5821 }
5822
5823 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5824 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
5825 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
5826 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
5827 WMITLV_GET_STRUCT_TLVLEN
5828 (wmi_scan_dbs_duty_cycle_fixed_param));
5829
5830 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
5831 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
5832 buf_ptr += sizeof(*dbs_scan_param);
5833 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5834 (sizeof(*cmd) * dbs_scan_params->num_clients));
5835 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
5836
5837 for (i = 0; i < dbs_scan_params->num_clients; i++) {
5838 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
5839 WMITLV_SET_HDR(&cmd->tlv_header,
5840 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
5841 WMITLV_GET_STRUCT_TLVLEN(
5842 wmi_scan_dbs_duty_cycle_tlv_param));
5843 cmd->module_id = dbs_scan_params->module_id[i];
5844 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
5845 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
5846 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
5847 }
5848
5849 err = wmi_unified_cmd_send(wmi_handle, buf,
5850 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
5851 if (QDF_IS_STATUS_ERROR(err)) {
5852 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
5853 wmi_buf_free(buf);
5854 return QDF_STATUS_E_FAILURE;
5855 }
5856
5857 return QDF_STATUS_SUCCESS;
5858}
Gupta, Kapil2e685982016-04-25 19:14:19 +05305859
5860/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305861 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5862 * @wmi_handle: wmi handle
5863 * @roam_req: Request which contains the filters
5864 *
5865 * There are filters such as whitelist, blacklist and preferred
5866 * list that need to be applied to the scan results to form the
5867 * probable candidates for roaming.
5868 *
5869 * Return: Return success upon succesfully passing the
5870 * parameters to the firmware, otherwise failure.
5871 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305872static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305873 struct roam_scan_filter_params *roam_req)
5874{
5875 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305876 QDF_STATUS status;
5877 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305878 uint32_t len;
5879 uint8_t *buf_ptr;
5880 wmi_roam_filter_fixed_param *roam_filter;
5881 uint8_t *bssid_src_ptr = NULL;
5882 wmi_mac_addr *bssid_dst_ptr = NULL;
5883 wmi_ssid *ssid_ptr = NULL;
5884 uint32_t *bssid_preferred_factor_ptr = NULL;
5885
5886 len = sizeof(wmi_roam_filter_fixed_param);
5887 len += WMI_TLV_HDR_SIZE;
5888 len += roam_req->len;
5889
5890 buf = wmi_buf_alloc(wmi_handle, len);
5891 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305892 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305893 return QDF_STATUS_E_NOMEM;
5894 }
5895
5896 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5897 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5898 WMITLV_SET_HDR(&roam_filter->tlv_header,
5899 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5900 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5901 /* fill in fixed values */
5902 roam_filter->vdev_id = roam_req->session_id;
5903 roam_filter->flags = 0;
5904 roam_filter->op_bitmap = roam_req->op_bitmap;
5905 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5906 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5907 roam_filter->num_bssid_preferred_list =
5908 roam_req->num_bssid_preferred_list;
5909 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5910
5911 WMITLV_SET_HDR((buf_ptr),
5912 WMITLV_TAG_ARRAY_FIXED_STRUC,
5913 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5914 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5915 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5916 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5917 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5918 bssid_src_ptr += ATH_MAC_LEN;
5919 bssid_dst_ptr++;
5920 }
5921 buf_ptr += WMI_TLV_HDR_SIZE +
5922 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5923 WMITLV_SET_HDR((buf_ptr),
5924 WMITLV_TAG_ARRAY_FIXED_STRUC,
5925 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5926 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5927 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5928 qdf_mem_copy(&ssid_ptr->ssid,
5929 &roam_req->ssid_allowed_list[i].mac_ssid,
5930 roam_req->ssid_allowed_list[i].length);
5931 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5932 ssid_ptr++;
5933 }
5934 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5935 sizeof(wmi_ssid));
5936 WMITLV_SET_HDR((buf_ptr),
5937 WMITLV_TAG_ARRAY_FIXED_STRUC,
5938 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5939 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5940 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5941 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5942 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5943 (wmi_mac_addr *)bssid_dst_ptr);
5944 bssid_src_ptr += ATH_MAC_LEN;
5945 bssid_dst_ptr++;
5946 }
5947 buf_ptr += WMI_TLV_HDR_SIZE +
5948 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5949 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5950 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5951 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5952 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5953 *bssid_preferred_factor_ptr =
5954 roam_req->bssid_favored_factor[i];
5955 bssid_preferred_factor_ptr++;
5956 }
5957 buf_ptr += WMI_TLV_HDR_SIZE +
5958 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5959
5960 status = wmi_unified_cmd_send(wmi_handle, buf,
5961 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305962 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305963 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305964 status);
5965 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305966 }
Govind Singh67922e82016-04-01 16:48:57 +05305967
5968 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305969}
5970
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971/** send_set_epno_network_list_cmd_tlv() - set epno network list
5972 * @wmi_handle: wmi handle
5973 * @req: epno config params request structure
5974 *
5975 * This function reads the incoming epno config request structure
5976 * and constructs the WMI message to the firmware.
5977 *
5978 * Returns: 0 on success, error number otherwise
5979 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305980static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305981 struct wifi_enhanched_pno_params *req)
5982{
5983 wmi_nlo_config_cmd_fixed_param *cmd;
5984 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305985 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305986 u_int8_t i, *buf_ptr;
5987 wmi_buf_t buf;
5988 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305989 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305990
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305991 /* Fixed Params */
5992 len = sizeof(*cmd);
5993 if (req->num_networks) {
5994 /* TLV place holder for array of structures
5995 * then each nlo_configured_parameters(nlo_list) TLV.
5996 */
5997 len += WMI_TLV_HDR_SIZE;
5998 len += (sizeof(nlo_configured_parameters)
5999 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6000 /* TLV for array of uint32 channel_list */
6001 len += WMI_TLV_HDR_SIZE;
6002 /* TLV for nlo_channel_prediction_cfg */
6003 len += WMI_TLV_HDR_SIZE;
6004 /* TLV for candidate score params */
6005 len += sizeof(enlo_candidate_score_params);
6006 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306007
6008 buf = wmi_buf_alloc(wmi_handle, len);
6009 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306010 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6011 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306012 }
6013
6014 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6015
6016 buf_ptr = (u_int8_t *) cmd;
6017 WMITLV_SET_HDR(&cmd->tlv_header,
6018 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6019 WMITLV_GET_STRUCT_TLVLEN(
6020 wmi_nlo_config_cmd_fixed_param));
6021 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306022
6023 /* set flag to reset if num of networks are 0 */
6024 cmd->flags = (req->num_networks == 0 ?
6025 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306026
6027 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6028
Govind Singhb53420c2016-03-09 14:32:57 +05306029 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306030 WMI_LOGD("SSID count: %d flags: %d",
6031 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306032
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306033 /* Fill nlo_config only when num_networks are non zero */
6034 if (cmd->no_of_ssids) {
6035 /* Fill networks */
6036 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6037 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6038 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306039
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306040 nlo_list = (nlo_configured_parameters *) buf_ptr;
6041 for (i = 0; i < cmd->no_of_ssids; i++) {
6042 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6043 WMITLV_TAG_ARRAY_BYTE,
6044 WMITLV_GET_STRUCT_TLVLEN(
6045 nlo_configured_parameters));
6046 /* Copy ssid and it's length */
6047 nlo_list[i].ssid.valid = true;
6048 nlo_list[i].ssid.ssid.ssid_len =
6049 req->networks[i].ssid.length;
6050 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6051 req->networks[i].ssid.mac_ssid,
6052 nlo_list[i].ssid.ssid.ssid_len);
6053 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6054 nlo_list[i].ssid.ssid.ssid_len,
6055 (char *) nlo_list[i].ssid.ssid.ssid,
6056 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306057
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306058 /* Copy pno flags */
6059 nlo_list[i].bcast_nw_type.valid = true;
6060 nlo_list[i].bcast_nw_type.bcast_nw_type =
6061 req->networks[i].flags;
6062 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306063 nlo_list[i].bcast_nw_type.bcast_nw_type);
6064
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306065 /* Copy auth bit field */
6066 nlo_list[i].auth_type.valid = true;
6067 nlo_list[i].auth_type.auth_type =
6068 req->networks[i].auth_bit_field;
6069 WMI_LOGD("Auth bit field (%u)",
6070 nlo_list[i].auth_type.auth_type);
6071 }
6072
6073 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6074 /* Fill the channel list */
6075 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6076 buf_ptr += WMI_TLV_HDR_SIZE;
6077
6078 /* Fill prediction_param */
6079 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6080 buf_ptr += WMI_TLV_HDR_SIZE;
6081
6082 /* Fill epno candidate score params */
6083 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6084 WMITLV_SET_HDR(buf_ptr,
6085 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6086 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6087 cand_score_params->min5GHz_rssi =
6088 req->min_5ghz_rssi;
6089 cand_score_params->min24GHz_rssi =
6090 req->min_24ghz_rssi;
6091 cand_score_params->initial_score_max =
6092 req->initial_score_max;
6093 cand_score_params->current_connection_bonus =
6094 req->current_connection_bonus;
6095 cand_score_params->same_network_bonus =
6096 req->same_network_bonus;
6097 cand_score_params->secure_bonus =
6098 req->secure_bonus;
6099 cand_score_params->band5GHz_bonus =
6100 req->band_5ghz_bonus;
6101 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306102 }
6103
Govind Singh4eacd2b2016-03-07 14:24:22 +05306104 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306105 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306106 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306107 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306108 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306109 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306110 }
6111
Govind Singhb53420c2016-03-09 14:32:57 +05306112 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306113 req->session_id);
6114
Govind Singh67922e82016-04-01 16:48:57 +05306115 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306116}
6117
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306118
Govind Singh4eacd2b2016-03-07 14:24:22 +05306119/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6120 * @wmi_handle: wmi handle
6121 * @ipa_offload: ipa offload control parameter
6122 *
6123 * Returns: 0 on success, error number otherwise
6124 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306125static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306126 struct ipa_offload_control_params *ipa_offload)
6127{
6128 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6129 wmi_buf_t wmi_buf;
6130 uint32_t len;
6131 u_int8_t *buf_ptr;
6132
6133 len = sizeof(*cmd);
6134 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6135 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306136 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6137 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306138 }
6139
Govind Singhb53420c2016-03-09 14:32:57 +05306140 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306141 ipa_offload->offload_type, ipa_offload->enable);
6142
6143 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6144
6145 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6146 WMITLV_SET_HDR(&cmd->tlv_header,
6147 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6148 WMITLV_GET_STRUCT_TLVLEN(
6149 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6150
6151 cmd->offload_type = ipa_offload->offload_type;
6152 cmd->vdev_id = ipa_offload->vdev_id;
6153 cmd->enable = ipa_offload->enable;
6154
6155 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6156 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306157 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306159 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306160 }
6161
Govind Singhb53420c2016-03-09 14:32:57 +05306162 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306163}
6164
6165/**
6166 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6167 * @wmi_handle: wmi handle
6168 * @pgetcapab: get capabilities params
6169 *
6170 * This function send request to fw to get extscan capabilities.
6171 *
6172 * Return: CDF status
6173 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306174static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306175 struct extscan_capabilities_params *pgetcapab)
6176{
6177 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6178 wmi_buf_t wmi_buf;
6179 uint32_t len;
6180 uint8_t *buf_ptr;
6181
6182 len = sizeof(*cmd);
6183 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6184 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306185 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6186 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306187 }
6188 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6189
6190 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6191 WMITLV_SET_HDR(&cmd->tlv_header,
6192 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6193 WMITLV_GET_STRUCT_TLVLEN
6194 (wmi_extscan_get_capabilities_cmd_fixed_param));
6195
6196 cmd->request_id = pgetcapab->request_id;
6197
6198 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6199 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306200 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306201 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306202 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306203 }
Govind Singhb53420c2016-03-09 14:32:57 +05306204 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306205}
6206
6207/**
6208 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6209 * @wmi_handle: wmi handle
6210 * @pcached_results: cached results parameters
6211 *
6212 * This function send request to fw to get cached results.
6213 *
6214 * Return: CDF status
6215 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306216static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306217 struct extscan_cached_result_params *pcached_results)
6218{
6219 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6220 wmi_buf_t wmi_buf;
6221 uint32_t len;
6222 uint8_t *buf_ptr;
6223
6224 len = sizeof(*cmd);
6225 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6226 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306227 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6228 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306229 }
6230 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6231
6232 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6233 WMITLV_SET_HDR(&cmd->tlv_header,
6234 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6235 WMITLV_GET_STRUCT_TLVLEN
6236 (wmi_extscan_get_cached_results_cmd_fixed_param));
6237
6238 cmd->request_id = pcached_results->request_id;
6239 cmd->vdev_id = pcached_results->session_id;
6240 cmd->control_flags = pcached_results->flush;
6241
6242 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6243 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306244 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306245 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306246 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306247 }
Govind Singhb53420c2016-03-09 14:32:57 +05306248 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306249}
6250
6251/**
6252 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6253 * @wmi_handle: wmi handle
6254 * @reset_req: Reset change request params
6255 *
6256 * This function sends stop change monitor request to fw.
6257 *
6258 * Return: CDF status
6259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306260static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306261 struct extscan_capabilities_reset_params *reset_req)
6262{
6263 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6264 wmi_buf_t wmi_buf;
6265 uint32_t len;
6266 uint8_t *buf_ptr;
6267 int change_list = 0;
6268
6269 len = sizeof(*cmd);
6270
6271 /* reset significant change tlv is set to 0 */
6272 len += WMI_TLV_HDR_SIZE;
6273 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6274 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6275 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306276 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6277 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306278 }
6279 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6280
6281 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6282 buf_ptr;
6283 WMITLV_SET_HDR(&cmd->tlv_header,
6284 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6285 WMITLV_GET_STRUCT_TLVLEN
6286 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6287
6288 cmd->request_id = reset_req->request_id;
6289 cmd->vdev_id = reset_req->session_id;
6290 cmd->mode = 0;
6291
6292 buf_ptr += sizeof(*cmd);
6293 WMITLV_SET_HDR(buf_ptr,
6294 WMITLV_TAG_ARRAY_STRUC,
6295 change_list *
6296 sizeof(wmi_extscan_wlan_change_bssid_param));
6297 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6298 sizeof
6299 (wmi_extscan_wlan_change_bssid_param));
6300
6301 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6302 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306303 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306304 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306305 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306306 }
Govind Singhb53420c2016-03-09 14:32:57 +05306307 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306308}
6309
6310/**
6311 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6312 * @wmi_handle: wmi handle
6313 * @psigchange: change monitor request params
6314 * @buf: wmi buffer
6315 * @buf_len: buffer length
6316 *
6317 * This function fills elements of change monitor request buffer.
6318 *
6319 * Return: CDF status
6320 */
Govind Singhb53420c2016-03-09 14:32:57 +05306321static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306322 struct extscan_set_sig_changereq_params
6323 *psigchange, wmi_buf_t *buf, int *buf_len)
6324{
6325 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6326 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6327 uint8_t *buf_ptr;
6328 int j;
6329 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006330 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306331 struct ap_threshold_params *src_ap = psigchange->ap;
6332
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006333 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306334 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6335 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306336 }
6337 len += WMI_TLV_HDR_SIZE;
6338 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6339
6340 *buf = wmi_buf_alloc(wmi_handle, len);
6341 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306342 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306343 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306344 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306345 }
6346 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6347 cmd =
6348 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6349 buf_ptr;
6350 WMITLV_SET_HDR(&cmd->tlv_header,
6351 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6352 WMITLV_GET_STRUCT_TLVLEN
6353 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6354
6355 cmd->request_id = psigchange->request_id;
6356 cmd->vdev_id = psigchange->session_id;
6357 cmd->total_entries = numap;
6358 cmd->mode = 1;
6359 cmd->num_entries_in_page = numap;
6360 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6361 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6362 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6363 cmd->max_out_of_range_count = psigchange->min_breaching;
6364
6365 buf_ptr += sizeof(*cmd);
6366 WMITLV_SET_HDR(buf_ptr,
6367 WMITLV_TAG_ARRAY_STRUC,
6368 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6369 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6370 (buf_ptr + WMI_TLV_HDR_SIZE);
6371
6372 for (j = 0; j < numap; j++) {
6373 WMITLV_SET_HDR(dest_chglist,
6374 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6375 WMITLV_GET_STRUCT_TLVLEN
6376 (wmi_extscan_wlan_change_bssid_param));
6377
6378 dest_chglist->lower_rssi_limit = src_ap->low;
6379 dest_chglist->upper_rssi_limit = src_ap->high;
6380 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6381 &dest_chglist->bssid);
6382
Govind Singhb53420c2016-03-09 14:32:57 +05306383 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306384 dest_chglist->lower_rssi_limit);
6385 dest_chglist++;
6386 src_ap++;
6387 }
6388 buf_ptr += WMI_TLV_HDR_SIZE +
6389 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6390 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306391 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306392}
6393
6394/**
6395 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6396 * @wmi_handle: wmi handle
6397 * @psigchange: change monitor request params
6398 *
6399 * This function sends start change monitor request to fw.
6400 *
6401 * Return: CDF status
6402 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306403static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306404 struct extscan_set_sig_changereq_params *
6405 psigchange)
6406{
Govind Singhb53420c2016-03-09 14:32:57 +05306407 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306408 wmi_buf_t buf;
6409 int len;
6410
6411
Govind Singhb53420c2016-03-09 14:32:57 +05306412 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 psigchange, &buf,
6414 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306415 if (qdf_status != QDF_STATUS_SUCCESS) {
6416 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306417 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306418 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306419 }
6420 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306421 WMI_LOGE("%s: Failed to get buffer", __func__);
6422 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306423 }
6424 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6425 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306426 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306427 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306428 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306429 }
Govind Singhb53420c2016-03-09 14:32:57 +05306430 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306431}
6432
6433/**
6434 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6435 * @wmi_handle: wmi handle
6436 * @photlist_reset: hotlist reset params
6437 *
6438 * This function configures hotlist monitor to stop in fw.
6439 *
6440 * Return: CDF status
6441 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306442static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306443 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6444{
6445 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6446 wmi_buf_t wmi_buf;
6447 uint32_t len;
6448 uint8_t *buf_ptr;
6449 int hotlist_entries = 0;
6450
6451 len = sizeof(*cmd);
6452
6453 /* reset bssid hotlist with tlv set to 0 */
6454 len += WMI_TLV_HDR_SIZE;
6455 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6456
6457 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6458 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306459 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6460 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306461 }
6462
6463 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6464 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6465 buf_ptr;
6466 WMITLV_SET_HDR(&cmd->tlv_header,
6467 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6468 WMITLV_GET_STRUCT_TLVLEN
6469 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6470
6471 cmd->request_id = photlist_reset->request_id;
6472 cmd->vdev_id = photlist_reset->session_id;
6473 cmd->mode = 0;
6474
6475 buf_ptr += sizeof(*cmd);
6476 WMITLV_SET_HDR(buf_ptr,
6477 WMITLV_TAG_ARRAY_STRUC,
6478 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6479 buf_ptr += WMI_TLV_HDR_SIZE +
6480 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6481
6482 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6483 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306484 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306485 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306486 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306487 }
Govind Singhb53420c2016-03-09 14:32:57 +05306488 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306489}
6490
6491/**
6492 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6493 * @wmi_handle: wmi handle
6494 * @pstopcmd: stop scan command request params
6495 *
6496 * This function sends stop extscan request to fw.
6497 *
6498 * Return: CDF Status.
6499 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306500static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306501 struct extscan_stop_req_params *pstopcmd)
6502{
6503 wmi_extscan_stop_cmd_fixed_param *cmd;
6504 wmi_buf_t wmi_buf;
6505 uint32_t len;
6506 uint8_t *buf_ptr;
6507
6508 len = sizeof(*cmd);
6509 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6510 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306511 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6512 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306513 }
6514 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6515 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6516 WMITLV_SET_HDR(&cmd->tlv_header,
6517 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6518 WMITLV_GET_STRUCT_TLVLEN
6519 (wmi_extscan_stop_cmd_fixed_param));
6520
6521 cmd->request_id = pstopcmd->request_id;
6522 cmd->vdev_id = pstopcmd->session_id;
6523
6524 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6525 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306526 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306527 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306528 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306529 }
6530
Govind Singhb53420c2016-03-09 14:32:57 +05306531 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306532}
6533
6534/**
6535 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6536 * @wmi_handle: wmi handle
6537 * @pstart: scan command request params
6538 * @buf: event buffer
6539 * @buf_len: length of buffer
6540 *
6541 * This function fills individual elements of extscan request and
6542 * TLV for buckets, channel list.
6543 *
6544 * Return: CDF Status.
6545 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006546static
Govind Singhb53420c2016-03-09 14:32:57 +05306547QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306548 struct wifi_scan_cmd_req_params *pstart,
6549 wmi_buf_t *buf, int *buf_len)
6550{
6551 wmi_extscan_start_cmd_fixed_param *cmd;
6552 wmi_extscan_bucket *dest_blist;
6553 wmi_extscan_bucket_channel *dest_clist;
6554 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6555 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6556 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6557
6558 uint8_t *buf_ptr;
6559 int i, k, count = 0;
6560 int len = sizeof(*cmd);
6561 int nbuckets = pstart->numBuckets;
6562 int nchannels = 0;
6563
6564 /* These TLV's are are NULL by default */
6565 uint32_t ie_len_with_pad = 0;
6566 int num_ssid = 0;
6567 int num_bssid = 0;
6568 int ie_len = 0;
6569
6570 uint32_t base_period = pstart->basePeriod;
6571
6572 /* TLV placeholder for ssid_list (NULL) */
6573 len += WMI_TLV_HDR_SIZE;
6574 len += num_ssid * sizeof(wmi_ssid);
6575
6576 /* TLV placeholder for bssid_list (NULL) */
6577 len += WMI_TLV_HDR_SIZE;
6578 len += num_bssid * sizeof(wmi_mac_addr);
6579
6580 /* TLV placeholder for ie_data (NULL) */
6581 len += WMI_TLV_HDR_SIZE;
6582 len += ie_len * sizeof(uint32_t);
6583
6584 /* TLV placeholder for bucket */
6585 len += WMI_TLV_HDR_SIZE;
6586 len += nbuckets * sizeof(wmi_extscan_bucket);
6587
6588 /* TLV channel placeholder */
6589 len += WMI_TLV_HDR_SIZE;
6590 for (i = 0; i < nbuckets; i++) {
6591 nchannels += src_bucket->numChannels;
6592 src_bucket++;
6593 }
6594
Govind Singhb53420c2016-03-09 14:32:57 +05306595 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306596 __func__, nbuckets, nchannels);
6597 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6598 /* Allocate the memory */
6599 *buf = wmi_buf_alloc(wmi_handle, len);
6600 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306601 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306602 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306603 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306604 }
6605 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6606 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6607 WMITLV_SET_HDR(&cmd->tlv_header,
6608 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6609 WMITLV_GET_STRUCT_TLVLEN
6610 (wmi_extscan_start_cmd_fixed_param));
6611
6612 cmd->request_id = pstart->requestId;
6613 cmd->vdev_id = pstart->sessionId;
6614 cmd->base_period = pstart->basePeriod;
6615 cmd->num_buckets = nbuckets;
6616 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306617 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306618 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306619 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306620 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306621#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306622 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6623 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306624 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6625 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6626#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306627 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6628
6629 /* The max dwell time is retrieved from the first channel
6630 * of the first bucket and kept common for all channels.
6631 */
6632 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6633 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6634 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6635 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6636 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6637 cmd->max_table_usage = pstart->report_threshold_percent;
6638 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6639
6640 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306641 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306642 cmd->probe_delay = 0;
6643 cmd->probe_spacing_time = 0;
6644 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306645 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6646 WMI_SCAN_ADD_CCK_RATES |
6647 WMI_SCAN_ADD_OFDM_RATES |
6648 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6649 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306650 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6651 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306652 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306653 cmd->num_ssids = 0;
6654 cmd->num_bssid = 0;
6655 cmd->ie_len = 0;
6656 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6657 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6658
6659 buf_ptr += sizeof(*cmd);
6660 WMITLV_SET_HDR(buf_ptr,
6661 WMITLV_TAG_ARRAY_FIXED_STRUC,
6662 num_ssid * sizeof(wmi_ssid));
6663 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6664
6665 WMITLV_SET_HDR(buf_ptr,
6666 WMITLV_TAG_ARRAY_FIXED_STRUC,
6667 num_bssid * sizeof(wmi_mac_addr));
6668 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6669
6670 ie_len_with_pad = 0;
6671 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6672 ie_len_with_pad);
6673 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6674
6675 WMITLV_SET_HDR(buf_ptr,
6676 WMITLV_TAG_ARRAY_STRUC,
6677 nbuckets * sizeof(wmi_extscan_bucket));
6678 dest_blist = (wmi_extscan_bucket *)
6679 (buf_ptr + WMI_TLV_HDR_SIZE);
6680 src_bucket = pstart->buckets;
6681
6682 /* Retrieve scanning information from each bucket and
6683 * channels and send it to the target
6684 */
6685 for (i = 0; i < nbuckets; i++) {
6686 WMITLV_SET_HDR(dest_blist,
6687 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6688 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6689
6690 dest_blist->bucket_id = src_bucket->bucket;
6691 dest_blist->base_period_multiplier =
6692 src_bucket->period / base_period;
6693 dest_blist->min_period = src_bucket->period;
6694 dest_blist->max_period = src_bucket->max_period;
6695 dest_blist->exp_backoff = src_bucket->exponent;
6696 dest_blist->exp_max_step_count = src_bucket->step_count;
6697 dest_blist->channel_band = src_bucket->band;
6698 dest_blist->num_channels = src_bucket->numChannels;
6699 dest_blist->notify_extscan_events = 0;
6700
6701 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6702 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006703 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6704 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306705
6706 if (src_bucket->reportEvents &
6707 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6708 dest_blist->forwarding_flags =
6709 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6710 dest_blist->notify_extscan_events |=
6711 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6712 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6713 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6714 } else {
6715 dest_blist->forwarding_flags =
6716 WMI_EXTSCAN_NO_FORWARDING;
6717 }
6718
6719 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6720 dest_blist->configuration_flags = 0;
6721 else
6722 dest_blist->configuration_flags =
6723 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6724
Govind Singhb53420c2016-03-09 14:32:57 +05306725 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726 __func__, dest_blist->notify_extscan_events,
6727 dest_blist->configuration_flags,
6728 dest_blist->forwarding_flags);
6729
6730 dest_blist->min_dwell_time_active =
6731 src_bucket->min_dwell_time_active;
6732 dest_blist->max_dwell_time_active =
6733 src_bucket->max_dwell_time_active;
6734 dest_blist->min_dwell_time_passive =
6735 src_bucket->min_dwell_time_passive;
6736 dest_blist->max_dwell_time_passive =
6737 src_bucket->max_dwell_time_passive;
6738 src_channel = src_bucket->channels;
6739
6740 /* save the channel info to later populate
6741 * the channel TLV
6742 */
6743 for (k = 0; k < src_bucket->numChannels; k++) {
6744 save_channel[count++].channel = src_channel->channel;
6745 src_channel++;
6746 }
6747 dest_blist++;
6748 src_bucket++;
6749 }
6750 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6751 WMITLV_SET_HDR(buf_ptr,
6752 WMITLV_TAG_ARRAY_STRUC,
6753 nchannels * sizeof(wmi_extscan_bucket_channel));
6754 dest_clist = (wmi_extscan_bucket_channel *)
6755 (buf_ptr + WMI_TLV_HDR_SIZE);
6756
6757 /* Active or passive scan is based on the bucket dwell time
6758 * and channel specific active,passive scans are not
6759 * supported yet
6760 */
6761 for (i = 0; i < nchannels; i++) {
6762 WMITLV_SET_HDR(dest_clist,
6763 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6764 WMITLV_GET_STRUCT_TLVLEN
6765 (wmi_extscan_bucket_channel));
6766 dest_clist->channel = save_channel[i].channel;
6767 dest_clist++;
6768 }
6769 buf_ptr += WMI_TLV_HDR_SIZE +
6770 (nchannels * sizeof(wmi_extscan_bucket_channel));
6771 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306772 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306773}
6774
6775/**
6776 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6777 * @wmi_handle: wmi handle
6778 * @pstart: scan command request params
6779 *
6780 * This function sends start extscan request to fw.
6781 *
6782 * Return: CDF Status.
6783 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306784static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306785 struct wifi_scan_cmd_req_params *pstart)
6786{
Govind Singhb53420c2016-03-09 14:32:57 +05306787 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306788 wmi_buf_t buf;
6789 int len;
6790
6791 /* Fill individual elements of extscan request and
6792 * TLV for buckets, channel list.
6793 */
Govind Singhb53420c2016-03-09 14:32:57 +05306794 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306795 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306796 if (qdf_status != QDF_STATUS_SUCCESS) {
6797 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6798 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306799 }
6800 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306801 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306802 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306803 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306804 }
6805 if (wmi_unified_cmd_send(wmi_handle, buf,
6806 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306807 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306808 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306809 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306810 }
6811
Govind Singhb53420c2016-03-09 14:32:57 +05306812 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306813}
6814
6815/**
6816 * send_plm_stop_cmd_tlv() - plm stop request
6817 * @wmi_handle: wmi handle
6818 * @plm: plm request parameters
6819 *
6820 * This function request FW to stop PLM.
6821 *
6822 * Return: CDF status
6823 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306824static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306825 const struct plm_req_params *plm)
6826{
6827 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6828 int32_t len;
6829 wmi_buf_t buf;
6830 uint8_t *buf_ptr;
6831 int ret;
6832
6833 len = sizeof(*cmd);
6834 buf = wmi_buf_alloc(wmi_handle, len);
6835 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306836 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6837 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306838 }
6839
6840 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6841
6842 buf_ptr = (uint8_t *) cmd;
6843
6844 WMITLV_SET_HDR(&cmd->tlv_header,
6845 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6846 WMITLV_GET_STRUCT_TLVLEN
6847 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6848
6849 cmd->vdev_id = plm->session_id;
6850
6851 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306852 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306853
6854 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6855 WMI_VDEV_PLMREQ_STOP_CMDID);
6856 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306857 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306858 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306859 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306860 }
6861
Govind Singhb53420c2016-03-09 14:32:57 +05306862 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863}
6864
6865/**
6866 * send_plm_start_cmd_tlv() - plm start request
6867 * @wmi_handle: wmi handle
6868 * @plm: plm request parameters
6869 *
6870 * This function request FW to start PLM.
6871 *
6872 * Return: CDF status
6873 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306874static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306875 const struct plm_req_params *plm,
6876 uint32_t *gchannel_list)
6877{
6878 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6879 uint32_t *channel_list;
6880 int32_t len;
6881 wmi_buf_t buf;
6882 uint8_t *buf_ptr;
6883 uint8_t count;
6884 int ret;
6885
6886 /* TLV place holder for channel_list */
6887 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6888 len += sizeof(uint32_t) * plm->plm_num_ch;
6889
6890 buf = wmi_buf_alloc(wmi_handle, len);
6891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306892 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6893 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306894 }
6895 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6896
6897 buf_ptr = (uint8_t *) cmd;
6898
6899 WMITLV_SET_HDR(&cmd->tlv_header,
6900 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6901 WMITLV_GET_STRUCT_TLVLEN
6902 (wmi_vdev_plmreq_start_cmd_fixed_param));
6903
6904 cmd->vdev_id = plm->session_id;
6905
6906 cmd->meas_token = plm->meas_token;
6907 cmd->dialog_token = plm->diag_token;
6908 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306909 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306910 cmd->off_duration = plm->meas_duration;
6911 cmd->burst_cycle = plm->burst_len;
6912 cmd->tx_power = plm->desired_tx_pwr;
6913 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6914 cmd->num_chans = plm->plm_num_ch;
6915
6916 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6917
Govind Singhb53420c2016-03-09 14:32:57 +05306918 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6919 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6920 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6921 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6922 WMI_LOGD("off_duration: %d", cmd->off_duration);
6923 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6924 WMI_LOGD("tx_power: %d", cmd->tx_power);
6925 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306926
6927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6928 (cmd->num_chans * sizeof(uint32_t)));
6929
6930 buf_ptr += WMI_TLV_HDR_SIZE;
6931 if (cmd->num_chans) {
6932 channel_list = (uint32_t *) buf_ptr;
6933 for (count = 0; count < cmd->num_chans; count++) {
6934 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306935 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306936 channel_list[count] =
6937 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306938 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306939 }
6940 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6941 }
6942
6943 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6944 WMI_VDEV_PLMREQ_START_CMDID);
6945 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306946 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306947 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306948 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306949 }
6950
Govind Singhb53420c2016-03-09 14:32:57 +05306951 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306952}
6953
6954/**
6955 * send_pno_stop_cmd_tlv() - PNO stop request
6956 * @wmi_handle: wmi handle
6957 * @vdev_id: vdev id
6958 *
6959 * This function request FW to stop ongoing PNO operation.
6960 *
6961 * Return: CDF status
6962 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306963static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306964{
6965 wmi_nlo_config_cmd_fixed_param *cmd;
6966 int32_t len = sizeof(*cmd);
6967 wmi_buf_t buf;
6968 uint8_t *buf_ptr;
6969 int ret;
6970
6971 /*
6972 * TLV place holder for array of structures nlo_configured_parameters
6973 * TLV place holder for array of uint32_t channel_list
6974 * TLV place holder for chnl prediction cfg
6975 */
6976 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6977 buf = wmi_buf_alloc(wmi_handle, len);
6978 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306979 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6980 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306981 }
6982
6983 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6984 buf_ptr = (uint8_t *) cmd;
6985
6986 WMITLV_SET_HDR(&cmd->tlv_header,
6987 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6988 WMITLV_GET_STRUCT_TLVLEN
6989 (wmi_nlo_config_cmd_fixed_param));
6990
6991 cmd->vdev_id = vdev_id;
6992 cmd->flags = WMI_NLO_CONFIG_STOP;
6993 buf_ptr += sizeof(*cmd);
6994
6995 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6996 buf_ptr += WMI_TLV_HDR_SIZE;
6997
6998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6999 buf_ptr += WMI_TLV_HDR_SIZE;
7000
7001 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7002 buf_ptr += WMI_TLV_HDR_SIZE;
7003
7004
7005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7006 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7007 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307008 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307009 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307010 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307011 }
7012
Govind Singhb53420c2016-03-09 14:32:57 +05307013 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307014}
7015
7016/**
Govind Singhccb0c272016-04-01 16:30:08 +05307017 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7018 * @buf_ptr: Buffer passed by upper layers
7019 * @pno: Buffer to be sent to the firmware
7020 *
7021 * Copy the PNO Channel prediction configuration parameters
7022 * passed by the upper layers to a WMI format TLV and send it
7023 * down to the firmware.
7024 *
7025 * Return: None
7026 */
7027static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7028 struct pno_scan_req_params *pno)
7029{
7030 nlo_channel_prediction_cfg *channel_prediction_cfg =
7031 (nlo_channel_prediction_cfg *) buf_ptr;
7032 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7033 WMITLV_TAG_ARRAY_BYTE,
7034 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307035#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307036 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7037 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7038 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7039 channel_prediction_cfg->full_scan_period_ms =
7040 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307041#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307042 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7043 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7044 channel_prediction_cfg->enable,
7045 channel_prediction_cfg->top_k_num,
7046 channel_prediction_cfg->stationary_threshold,
7047 channel_prediction_cfg->full_scan_period_ms);
7048}
7049
7050/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307051 * send_pno_start_cmd_tlv() - PNO start request
7052 * @wmi_handle: wmi handle
7053 * @pno: PNO request
7054 *
7055 * This function request FW to start PNO request.
7056 * Request: CDF status
7057 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307058static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307059 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307060{
7061 wmi_nlo_config_cmd_fixed_param *cmd;
7062 nlo_configured_parameters *nlo_list;
7063 uint32_t *channel_list;
7064 int32_t len;
7065 wmi_buf_t buf;
7066 uint8_t *buf_ptr;
7067 uint8_t i;
7068 int ret;
7069
7070 /*
7071 * TLV place holder for array nlo_configured_parameters(nlo_list)
7072 * TLV place holder for array of uint32_t channel_list
7073 * TLV place holder for chnnl prediction cfg
7074 */
7075 len = sizeof(*cmd) +
7076 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7077
Abhishek Singh5987b632017-03-03 22:09:07 +05307078 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079 WMI_NLO_MAX_CHAN);
7080 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307081 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307082 len += sizeof(nlo_channel_prediction_cfg);
7083
7084 buf = wmi_buf_alloc(wmi_handle, len);
7085 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307086 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7087 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307088 }
7089
7090 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7091
7092 buf_ptr = (uint8_t *) cmd;
7093 WMITLV_SET_HDR(&cmd->tlv_header,
7094 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7095 WMITLV_GET_STRUCT_TLVLEN
7096 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307097 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307098 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7099
Govind Singh87542482016-06-08 19:40:11 +05307100#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307101 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307102 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307103#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307104 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307105 cmd->active_dwell_time = pno->active_dwell_time;
7106 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307107
7108 /* Copy scan interval */
7109 cmd->fast_scan_period = pno->fast_scan_period;
7110 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007111 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307112 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007113 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307114 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307115 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307116 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307117
7118 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7119
Abhishek Singh5987b632017-03-03 22:09:07 +05307120 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307121 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7123 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7124 buf_ptr += WMI_TLV_HDR_SIZE;
7125
7126 nlo_list = (nlo_configured_parameters *) buf_ptr;
7127 for (i = 0; i < cmd->no_of_ssids; i++) {
7128 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7129 WMITLV_TAG_ARRAY_BYTE,
7130 WMITLV_GET_STRUCT_TLVLEN
7131 (nlo_configured_parameters));
7132 /* Copy ssid and it's length */
7133 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307134 nlo_list[i].ssid.ssid.ssid_len =
7135 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307136 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307137 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307138 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307139 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307140 nlo_list[i].ssid.ssid.ssid_len,
7141 (char *)nlo_list[i].ssid.ssid.ssid,
7142 nlo_list[i].ssid.ssid.ssid_len);
7143
7144 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307145 if (pno->networks_list[i].rssi_thresh &&
7146 pno->networks_list[i].rssi_thresh >
7147 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307148 nlo_list[i].rssi_cond.valid = true;
7149 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307150 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307151 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307152 nlo_list[i].rssi_cond.rssi);
7153 }
7154 nlo_list[i].bcast_nw_type.valid = true;
7155 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307156 pno->networks_list[i].bc_new_type;
Govind Singhb53420c2016-03-09 14:32:57 +05307157 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307158 nlo_list[i].bcast_nw_type.bcast_nw_type);
7159 }
7160 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7161
7162 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307163 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307164 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307165 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7167 (cmd->num_of_channels * sizeof(uint32_t)));
7168 buf_ptr += WMI_TLV_HDR_SIZE;
7169
7170 channel_list = (uint32_t *) buf_ptr;
7171 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307172 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307173
7174 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307175 channel_list[i] =
7176 wlan_chan_to_freq(pno->
7177 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307178
Govind Singhb53420c2016-03-09 14:32:57 +05307179 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307180 }
7181 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7183 sizeof(nlo_channel_prediction_cfg));
7184 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307185 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307186 buf_ptr += WMI_TLV_HDR_SIZE;
7187 /** TODO: Discrete firmware doesn't have command/option to configure
7188 * App IE which comes from wpa_supplicant as of part PNO start request.
7189 */
7190 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7191 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7192 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307193 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307194 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307195 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307196 }
7197
Govind Singhb53420c2016-03-09 14:32:57 +05307198 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307199}
7200
7201/* send_set_ric_req_cmd_tlv() - set ric request element
7202 * @wmi_handle: wmi handle
7203 * @msg: message
7204 * @is_add_ts: is addts required
7205 *
7206 * This function sets ric request element for 11r roaming.
7207 *
7208 * Return: CDF status
7209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307210static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307211 void *msg, uint8_t is_add_ts)
7212{
7213 wmi_ric_request_fixed_param *cmd;
7214 wmi_ric_tspec *tspec_param;
7215 wmi_buf_t buf;
7216 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307217 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307218 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7219 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7220
7221 buf = wmi_buf_alloc(wmi_handle, len);
7222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307223 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7224 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307225 }
7226
7227 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7228
7229 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7230 WMITLV_SET_HDR(&cmd->tlv_header,
7231 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7232 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7233 if (is_add_ts)
7234 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7235 else
7236 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7237 cmd->num_ric_request = 1;
7238 cmd->is_add_ric = is_add_ts;
7239
7240 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7242
7243 buf_ptr += WMI_TLV_HDR_SIZE;
7244 tspec_param = (wmi_ric_tspec *) buf_ptr;
7245 WMITLV_SET_HDR(&tspec_param->tlv_header,
7246 WMITLV_TAG_STRUC_wmi_ric_tspec,
7247 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7248
7249 if (is_add_ts)
7250 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307251#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307252 else
7253 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307254#endif
7255 if (ptspecIE) {
7256 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307257#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307258 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7259 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307260#else
Govind Singh87542482016-06-08 19:40:11 +05307261 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7262 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263#endif /* ANI_LITTLE_BIT_ENDIAN */
7264
Govind Singh87542482016-06-08 19:40:11 +05307265 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7266 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7267 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7268 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7269 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7270 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7271 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7272 tspec_param->min_data_rate = ptspecIE->minDataRate;
7273 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7274 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7275 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7276 tspec_param->delay_bound = ptspecIE->delayBound;
7277 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7278 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7279 tspec_param->medium_time = 0;
7280 }
Govind Singhb53420c2016-03-09 14:32:57 +05307281 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307282
7283 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7284 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307285 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307286 __func__);
7287 if (is_add_ts)
7288 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307289 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307290 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307291 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307292 }
7293
Govind Singhb53420c2016-03-09 14:32:57 +05307294 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307295}
7296
7297/**
7298 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7299 * @wmi_handle: wmi handle
7300 * @clear_req: ll stats clear request command params
7301 *
Govind Singhb53420c2016-03-09 14:32:57 +05307302 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307304static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307305 const struct ll_stats_clear_params *clear_req,
7306 uint8_t addr[IEEE80211_ADDR_LEN])
7307{
7308 wmi_clear_link_stats_cmd_fixed_param *cmd;
7309 int32_t len;
7310 wmi_buf_t buf;
7311 uint8_t *buf_ptr;
7312 int ret;
7313
7314 len = sizeof(*cmd);
7315 buf = wmi_buf_alloc(wmi_handle, len);
7316
7317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307318 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7319 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307320 }
7321
7322 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307323 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307324 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7325
7326 WMITLV_SET_HDR(&cmd->tlv_header,
7327 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7328 WMITLV_GET_STRUCT_TLVLEN
7329 (wmi_clear_link_stats_cmd_fixed_param));
7330
7331 cmd->stop_stats_collection_req = clear_req->stop_req;
7332 cmd->vdev_id = clear_req->sta_id;
7333 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7334
7335 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7336 &cmd->peer_macaddr);
7337
Govind Singhb53420c2016-03-09 14:32:57 +05307338 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7339 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7340 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7341 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7342 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307343 cmd->peer_macaddr); */
7344
7345 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7346 WMI_CLEAR_LINK_STATS_CMDID);
7347 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307348 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307349 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307350 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307351 }
7352
Govind Singhb53420c2016-03-09 14:32:57 +05307353 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7354 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307355}
7356
7357/**
7358 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7359 * @wmi_handle: wmi handle
7360 * @setReq: ll stats set request command params
7361 *
Govind Singhb53420c2016-03-09 14:32:57 +05307362 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307363 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307364static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307365 const struct ll_stats_set_params *set_req)
7366{
7367 wmi_start_link_stats_cmd_fixed_param *cmd;
7368 int32_t len;
7369 wmi_buf_t buf;
7370 uint8_t *buf_ptr;
7371 int ret;
7372
7373 len = sizeof(*cmd);
7374 buf = wmi_buf_alloc(wmi_handle, len);
7375
7376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307377 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7378 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307379 }
7380
7381 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307382 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307383 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7384
7385 WMITLV_SET_HDR(&cmd->tlv_header,
7386 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7387 WMITLV_GET_STRUCT_TLVLEN
7388 (wmi_start_link_stats_cmd_fixed_param));
7389
7390 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7391 cmd->aggressive_statistics_gathering =
7392 set_req->aggressive_statistics_gathering;
7393
Govind Singhb53420c2016-03-09 14:32:57 +05307394 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7395 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7396 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307397
7398 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7399 WMI_START_LINK_STATS_CMDID);
7400 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307401 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307402 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307403 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307404 }
7405
Govind Singhb53420c2016-03-09 14:32:57 +05307406 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307407}
7408
7409/**
7410 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7411 * @wmi_handle:wmi handle
7412 * @get_req:ll stats get request command params
7413 * @addr: mac address
7414 *
Govind Singhb53420c2016-03-09 14:32:57 +05307415 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307416 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307417static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307418 const struct ll_stats_get_params *get_req,
7419 uint8_t addr[IEEE80211_ADDR_LEN])
7420{
7421 wmi_request_link_stats_cmd_fixed_param *cmd;
7422 int32_t len;
7423 wmi_buf_t buf;
7424 uint8_t *buf_ptr;
7425 int ret;
7426
7427 len = sizeof(*cmd);
7428 buf = wmi_buf_alloc(wmi_handle, len);
7429
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307430 if (!buf) {
7431 WMI_LOGE("%s: buf allocation failed", __func__);
7432 return QDF_STATUS_E_NOMEM;
7433 }
7434
Govind Singh4eacd2b2016-03-07 14:24:22 +05307435 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307436 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307437 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7438
7439 WMITLV_SET_HDR(&cmd->tlv_header,
7440 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7441 WMITLV_GET_STRUCT_TLVLEN
7442 (wmi_request_link_stats_cmd_fixed_param));
7443
7444 cmd->request_id = get_req->req_id;
7445 cmd->stats_type = get_req->param_id_mask;
7446 cmd->vdev_id = get_req->sta_id;
7447
7448 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7449 &cmd->peer_macaddr);
7450
Govind Singhb53420c2016-03-09 14:32:57 +05307451 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007452 WMI_LOGD("Request ID : %u", cmd->request_id);
7453 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307454 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7455 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456
7457 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7458 WMI_REQUEST_LINK_STATS_CMDID);
7459 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307460 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307461 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307462 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307463 }
7464
Govind Singhb53420c2016-03-09 14:32:57 +05307465 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307466}
7467
7468/**
7469 * send_get_stats_cmd_tlv() - get stats request
7470 * @wmi_handle: wmi handle
7471 * @get_stats_param: stats params
7472 * @addr: mac address
7473 *
7474 * Return: CDF status
7475 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307476static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307477 struct pe_stats_req *get_stats_param,
7478 uint8_t addr[IEEE80211_ADDR_LEN])
7479{
7480 wmi_buf_t buf;
7481 wmi_request_stats_cmd_fixed_param *cmd;
7482 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7483
7484 buf = wmi_buf_alloc(wmi_handle, len);
7485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307486 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7487 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307488 }
7489
7490
7491 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7492 WMITLV_SET_HDR(&cmd->tlv_header,
7493 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7494 WMITLV_GET_STRUCT_TLVLEN
7495 (wmi_request_stats_cmd_fixed_param));
7496 cmd->stats_id =
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05307497 WMI_REQUEST_PDEV_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307498 cmd->vdev_id = get_stats_param->session_id;
7499 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307500 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307501 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7502 WMI_REQUEST_STATS_CMDID)) {
7503
Govind Singhb53420c2016-03-09 14:32:57 +05307504 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307505 __func__);
7506 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307507 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307508 }
7509
Govind Singhb53420c2016-03-09 14:32:57 +05307510 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307511
7512}
7513
Govind Singh20c5dac2016-03-07 15:33:31 +05307514/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307515 * send_congestion_cmd_tlv() - send request to fw to get CCA
7516 * @wmi_handle: wmi handle
7517 * @vdev_id: vdev id
7518 *
7519 * Return: CDF status
7520 */
7521static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7522 A_UINT8 vdev_id)
7523{
7524 wmi_buf_t buf;
7525 wmi_request_stats_cmd_fixed_param *cmd;
7526 uint8_t len;
7527 uint8_t *buf_ptr;
7528
7529 len = sizeof(*cmd);
7530 buf = wmi_buf_alloc(wmi_handle, len);
7531 if (!buf) {
7532 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7533 return QDF_STATUS_E_FAILURE;
7534 }
7535
7536 buf_ptr = wmi_buf_data(buf);
7537 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7538 WMITLV_SET_HDR(&cmd->tlv_header,
7539 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7540 WMITLV_GET_STRUCT_TLVLEN
7541 (wmi_request_stats_cmd_fixed_param));
7542
7543 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7544 cmd->vdev_id = vdev_id;
7545 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7546 cmd->vdev_id, cmd->stats_id);
7547
7548 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7549 WMI_REQUEST_STATS_CMDID)) {
7550 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7551 __func__);
7552 wmi_buf_free(buf);
7553 return QDF_STATUS_E_FAILURE;
7554 }
7555
7556 return QDF_STATUS_SUCCESS;
7557}
7558
7559/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307560 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7561 * @wmi_handle: wmi handle
7562 * @rssi_req: get RSSI request
7563 *
7564 * Return: CDF status
7565 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307566static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307567{
7568 wmi_buf_t buf;
7569 wmi_request_stats_cmd_fixed_param *cmd;
7570 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7571
7572 buf = wmi_buf_alloc(wmi_handle, len);
7573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307574 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7575 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307576 }
7577
7578 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7579 WMITLV_SET_HDR(&cmd->tlv_header,
7580 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7581 WMITLV_GET_STRUCT_TLVLEN
7582 (wmi_request_stats_cmd_fixed_param));
7583 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7584 if (wmi_unified_cmd_send
7585 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307586 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307588 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307589 }
7590
Govind Singhb53420c2016-03-09 14:32:57 +05307591 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307592}
7593
7594/**
7595 * send_snr_cmd_tlv() - get RSSI from fw
7596 * @wmi_handle: wmi handle
7597 * @vdev_id: vdev id
7598 *
7599 * Return: CDF status
7600 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307601static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307602{
7603 wmi_buf_t buf;
7604 wmi_request_stats_cmd_fixed_param *cmd;
7605 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7606
7607 buf = wmi_buf_alloc(wmi_handle, len);
7608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307609 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7610 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307611 }
7612
7613 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7614 cmd->vdev_id = vdev_id;
7615
7616 WMITLV_SET_HDR(&cmd->tlv_header,
7617 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7618 WMITLV_GET_STRUCT_TLVLEN
7619 (wmi_request_stats_cmd_fixed_param));
7620 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7621 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7622 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307623 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307624 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307625 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307626 }
7627
Govind Singhb53420c2016-03-09 14:32:57 +05307628 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307629}
7630
7631/**
7632 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7633 * @wmi_handle: wmi handle
7634 * @link_status: get link params
7635 *
7636 * Return: CDF status
7637 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307638static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307639 struct link_status_params *link_status)
7640{
7641 wmi_buf_t buf;
7642 wmi_request_stats_cmd_fixed_param *cmd;
7643 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7644
7645 buf = wmi_buf_alloc(wmi_handle, len);
7646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7648 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307649 }
7650
7651 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7652 WMITLV_SET_HDR(&cmd->tlv_header,
7653 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7654 WMITLV_GET_STRUCT_TLVLEN
7655 (wmi_request_stats_cmd_fixed_param));
7656 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7657 cmd->vdev_id = link_status->session_id;
7658 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7659 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307660 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307661 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307662 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307663 }
7664
Govind Singhb53420c2016-03-09 14:32:57 +05307665 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307666}
7667
Govind Singh20c5dac2016-03-07 15:33:31 +05307668/**
7669 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7670 * @wmi_handle: wmi handle
7671 * @ta_dhcp_ind: DHCP indication parameter
7672 *
7673 * Return: CDF Status
7674 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307675static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307676 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7677{
Govind Singh67922e82016-04-01 16:48:57 +05307678 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307679 wmi_buf_t buf = NULL;
7680 uint8_t *buf_ptr;
7681 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7682 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7683
7684
7685 buf = wmi_buf_alloc(wmi_handle, len);
7686 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307687 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7688 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307689 }
7690
7691 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7692 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7693 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7694 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7695 WMITLV_GET_STRUCT_TLVLEN
7696 (wmi_peer_set_param_cmd_fixed_param));
7697
7698 /* fill in values */
7699 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7700 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7701 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307702 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307703 &ta_dhcp_ind->peer_macaddr,
7704 sizeof(ta_dhcp_ind->peer_macaddr));
7705
7706 status = wmi_unified_cmd_send(wmi_handle, buf,
7707 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307708 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307709 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307710 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307711 wmi_buf_free(buf);
7712 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307713
Govind Singh67922e82016-04-01 16:48:57 +05307714 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307715}
7716
7717/**
7718 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7719 * @wmi_handle: wmi handle
7720 * @pLinkSpeed: link speed info
7721 *
7722 * Return: CDF status
7723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307724static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307725 wmi_mac_addr peer_macaddr)
7726{
7727 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7728 wmi_buf_t wmi_buf;
7729 uint32_t len;
7730 uint8_t *buf_ptr;
7731
7732 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7733 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7734 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307735 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7736 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307737 }
7738 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7739
7740 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7741 WMITLV_SET_HDR(&cmd->tlv_header,
7742 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7743 WMITLV_GET_STRUCT_TLVLEN
7744 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7745
7746 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307747 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307748 &peer_macaddr,
7749 sizeof(peer_macaddr));
7750
7751
7752 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7753 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307754 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307755 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307756 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307757 }
Govind Singhb53420c2016-03-09 14:32:57 +05307758 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307759}
7760
7761/**
7762 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7763 * @wmi_handle: wmi handler
7764 * @egap_params: pointer to egap_params
7765 *
7766 * Return: 0 for success, otherwise appropriate error code
7767 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307768static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307769 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7770{
7771 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7772 wmi_buf_t buf;
7773 int32_t err;
7774
7775 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307777 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7778 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307779 }
7780 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7781 WMITLV_SET_HDR(&cmd->tlv_header,
7782 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7783 WMITLV_GET_STRUCT_TLVLEN(
7784 wmi_ap_ps_egap_param_cmd_fixed_param));
7785
7786 cmd->enable = egap_params->enable;
7787 cmd->inactivity_time = egap_params->inactivity_time;
7788 cmd->wait_time = egap_params->wait_time;
7789 cmd->flags = egap_params->flags;
7790 err = wmi_unified_cmd_send(wmi_handle, buf,
7791 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7792 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307793 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307794 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307795 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307796 }
7797
Govind Singhb53420c2016-03-09 14:32:57 +05307798 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307799}
7800
7801/**
7802 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7803 * @wmi_handl: wmi handle
7804 * @cmd: Profiling command index
7805 * @value1: parameter1 value
7806 * @value2: parameter2 value
7807 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307808 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307809 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307810static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307811 uint32_t cmd, uint32_t value1, uint32_t value2)
7812{
7813 wmi_buf_t buf;
7814 int32_t len = 0;
7815 int ret;
7816 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7817 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7818 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7819 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7820
7821 switch (cmd) {
7822 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7823 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7824 buf = wmi_buf_alloc(wmi_handle, len);
7825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307828 }
7829 prof_trig_cmd =
7830 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7831 wmi_buf_data(buf);
7832 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7833 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7834 WMITLV_GET_STRUCT_TLVLEN
7835 (wmi_wlan_profile_trigger_cmd_fixed_param));
7836 prof_trig_cmd->enable = value1;
7837 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7838 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7839 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307840 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307841 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307842 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307843 return ret;
7844 }
7845 break;
7846
7847 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7848 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7849 buf = wmi_buf_alloc(wmi_handle, len);
7850 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307851 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307852 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307853 }
7854 profile_getdata_cmd =
7855 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7856 wmi_buf_data(buf);
7857 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7858 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7859 WMITLV_GET_STRUCT_TLVLEN
7860 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7861 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7862 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7863 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307864 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307865 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307866 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307867 return ret;
7868 }
7869 break;
7870
7871 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7872 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7873 buf = wmi_buf_alloc(wmi_handle, len);
7874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307875 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307876 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307877 }
7878 hist_intvl_cmd =
7879 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7880 wmi_buf_data(buf);
7881 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7882 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7883 WMITLV_GET_STRUCT_TLVLEN
7884 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7885 hist_intvl_cmd->profile_id = value1;
7886 hist_intvl_cmd->value = value2;
7887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7888 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7889 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307890 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307891 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307892 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307893 return ret;
7894 }
7895 break;
7896
7897 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7898 len =
7899 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7900 buf = wmi_buf_alloc(wmi_handle, len);
7901 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307902 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307903 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307904 }
7905 profile_enable_cmd =
7906 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7907 wmi_buf_data(buf);
7908 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7909 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7910 WMITLV_GET_STRUCT_TLVLEN
7911 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7912 profile_enable_cmd->profile_id = value1;
7913 profile_enable_cmd->enable = value2;
7914 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7915 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7916 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307917 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307918 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307919 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307920 return ret;
7921 }
7922 break;
7923
7924 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307925 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307926 break;
7927 }
7928
7929 return 0;
7930}
7931
Govind Singh20c5dac2016-03-07 15:33:31 +05307932/**
7933 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7934 * @wmi_handle: wmi handle
7935 * @vdev_id: vdev id
7936 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307937 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307938 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307939static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307940{
7941 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7942 wmi_buf_t buf;
7943 int32_t len = sizeof(*cmd);
7944
Govind Singhb53420c2016-03-09 14:32:57 +05307945 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307946 buf = wmi_buf_alloc(wmi_handle, len);
7947 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307948 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307949 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307950 }
7951 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7952 wmi_buf_data(buf);
7953 WMITLV_SET_HDR(&cmd->tlv_header,
7954 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7955 WMITLV_GET_STRUCT_TLVLEN
7956 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7957 cmd->vdev_id = vdev_id;
7958 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7959 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7960 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307961 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307962 __func__);
7963 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307964 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307965 }
7966
7967 return 0;
7968}
7969
7970/**
7971 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7972 * @wmi_handle: wmi handle
7973 * @vdev_id: vdev id
7974 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307975 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307976 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307977static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307978 uint8_t vdev_id)
7979{
7980 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7981 wmi_buf_t buf;
7982 int32_t len = sizeof(*cmd);
7983
Govind Singhb53420c2016-03-09 14:32:57 +05307984 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307985 buf = wmi_buf_alloc(wmi_handle, len);
7986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307987 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307988 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307989 }
7990 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7991 WMITLV_SET_HDR(&cmd->tlv_header,
7992 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7993 WMITLV_GET_STRUCT_TLVLEN
7994 (wmi_csa_offload_enable_cmd_fixed_param));
7995 cmd->vdev_id = vdev_id;
7996 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7997 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7998 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307999 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308000 __func__);
8001 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308002 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308003 }
8004
8005 return 0;
8006}
8007
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008008#ifdef WLAN_FEATURE_CIF_CFR
8009/**
8010 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8011 * @wmi_handle: wmi handle
8012 * @data_len: len of dma cfg req
8013 * @data: dma cfg req
8014 *
8015 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8016 */
8017static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8018 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8019{
8020 wmi_buf_t buf;
8021 uint8_t *cmd;
8022 QDF_STATUS ret;
8023
8024 WMITLV_SET_HDR(cfg,
8025 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8026 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8027
8028 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8029 if (!buf) {
8030 WMI_LOGE(FL("wmi_buf_alloc failed"));
8031 return QDF_STATUS_E_FAILURE;
8032 }
8033
8034 cmd = (uint8_t *) wmi_buf_data(buf);
8035 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8036 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8037 sizeof(*cfg));
8038 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8039 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8040 if (QDF_IS_STATUS_ERROR(ret)) {
8041 WMI_LOGE(FL(":wmi cmd send failed"));
8042 wmi_buf_free(buf);
8043 }
8044
8045 return ret;
8046}
8047#endif
8048
Govind Singh20c5dac2016-03-07 15:33:31 +05308049/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008050 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8051 * @wmi_handle: wmi handle
8052 * @start_11d_scan: 11d scan start request parameters
8053 *
8054 * This function request FW to start 11d scan.
8055 *
8056 * Return: QDF status
8057 */
8058static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8059 struct reg_start_11d_scan_req *start_11d_scan)
8060{
8061 wmi_11d_scan_start_cmd_fixed_param *cmd;
8062 int32_t len;
8063 wmi_buf_t buf;
8064 int ret;
8065
8066 len = sizeof(*cmd);
8067 buf = wmi_buf_alloc(wmi_handle, len);
8068 if (!buf) {
8069 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8070 return QDF_STATUS_E_NOMEM;
8071 }
8072
8073 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8074
8075 WMITLV_SET_HDR(&cmd->tlv_header,
8076 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8077 WMITLV_GET_STRUCT_TLVLEN
8078 (wmi_11d_scan_start_cmd_fixed_param));
8079
8080 cmd->vdev_id = start_11d_scan->vdev_id;
8081 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8082 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8083
8084 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8085
8086 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8087 WMI_11D_SCAN_START_CMDID);
8088 if (ret) {
8089 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8090 wmi_buf_free(buf);
8091 return QDF_STATUS_E_FAILURE;
8092 }
8093
8094 return QDF_STATUS_SUCCESS;
8095}
8096
8097/**
8098 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8099 * @wmi_handle: wmi handle
8100 * @start_11d_scan: 11d scan stop request parameters
8101 *
8102 * This function request FW to stop 11d scan.
8103 *
8104 * Return: QDF status
8105 */
8106static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8107 struct reg_stop_11d_scan_req *stop_11d_scan)
8108{
8109 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8110 int32_t len;
8111 wmi_buf_t buf;
8112 int ret;
8113
8114 len = sizeof(*cmd);
8115 buf = wmi_buf_alloc(wmi_handle, len);
8116 if (!buf) {
8117 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8118 return QDF_STATUS_E_NOMEM;
8119 }
8120
8121 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8122
8123 WMITLV_SET_HDR(&cmd->tlv_header,
8124 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8125 WMITLV_GET_STRUCT_TLVLEN
8126 (wmi_11d_scan_stop_cmd_fixed_param));
8127
8128 cmd->vdev_id = stop_11d_scan->vdev_id;
8129
8130 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8131
8132 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8133 WMI_11D_SCAN_STOP_CMDID);
8134 if (ret) {
8135 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8136 wmi_buf_free(buf);
8137 return QDF_STATUS_E_FAILURE;
8138 }
8139
8140 return QDF_STATUS_SUCCESS;
8141}
8142
8143/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308144 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8145 * @wmi_handle: wmi handle
8146 * @startOemDataReq: start request params
8147 *
8148 * Return: CDF status
8149 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308150static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008151 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308152 uint8_t *data)
8153{
8154 wmi_buf_t buf;
8155 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308156 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308157
8158 buf = wmi_buf_alloc(wmi_handle,
8159 (data_len + WMI_TLV_HDR_SIZE));
8160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308161 WMI_LOGE(FL("wmi_buf_alloc failed"));
8162 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308163 }
8164
8165 cmd = (uint8_t *) wmi_buf_data(buf);
8166
8167 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8168 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308169 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308170 data_len);
8171
Govind Singhb53420c2016-03-09 14:32:57 +05308172 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308173 data_len);
8174
8175 ret = wmi_unified_cmd_send(wmi_handle, buf,
8176 (data_len +
8177 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8178
Govind Singh67922e82016-04-01 16:48:57 +05308179 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308180 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308181 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308182 }
8183
Govind Singh67922e82016-04-01 16:48:57 +05308184 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308185}
8186
8187/**
8188 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8189 * @wmi_handle: wmi handle
8190 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8191 *
8192 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8193 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8194 * to firmware based on phyerr filtering
8195 * offload status.
8196 *
8197 * Return: 1 success, 0 failure
8198 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308199static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308200send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8201 bool dfs_phyerr_filter_offload)
8202{
8203 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8204 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8205 wmi_buf_t buf;
8206 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308207 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308208
8209
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008210 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308211 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308212 __func__);
8213 len = sizeof(*disable_phyerr_offload_cmd);
8214 buf = wmi_buf_alloc(wmi_handle, len);
8215 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308216 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308217 return 0;
8218 }
8219 disable_phyerr_offload_cmd =
8220 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8221 wmi_buf_data(buf);
8222
8223 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8224 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8225 WMITLV_GET_STRUCT_TLVLEN
8226 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8227
8228 /*
8229 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8230 * to the firmware to disable the phyerror
8231 * filtering offload.
8232 */
8233 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8234 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308235 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308236 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308237 __func__, ret);
8238 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308239 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308240 }
Govind Singhb53420c2016-03-09 14:32:57 +05308241 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308242 __func__);
8243 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308244 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308245 __func__);
8246
8247 len = sizeof(*enable_phyerr_offload_cmd);
8248 buf = wmi_buf_alloc(wmi_handle, len);
8249 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308250 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8251 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308252 }
8253
8254 enable_phyerr_offload_cmd =
8255 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8256 wmi_buf_data(buf);
8257
8258 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8259 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8260 WMITLV_GET_STRUCT_TLVLEN
8261 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8262
8263 /*
8264 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8265 * to the firmware to enable the phyerror
8266 * filtering offload.
8267 */
8268 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8269 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8270
Govind Singh67922e82016-04-01 16:48:57 +05308271 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308272 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 __func__, ret);
8274 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308275 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308276 }
Govind Singhb53420c2016-03-09 14:32:57 +05308277 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308278 __func__);
8279 }
8280
Govind Singhb53420c2016-03-09 14:32:57 +05308281 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308282}
8283
8284#if !defined(REMOVE_PKT_LOG)
8285/**
8286 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8287 * @wmi_handle: wmi handle
8288 * @pktlog_event: pktlog event
8289 * @cmd_id: pktlog cmd id
8290 *
8291 * Return: CDF status
8292 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308293static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308294 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308295 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308296{
8297 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8298 WMI_CMD_ID CMD_ID;
8299 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8300 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8301 int len = 0;
8302 wmi_buf_t buf;
8303
8304 PKTLOG_EVENT = pktlog_event;
8305 CMD_ID = cmd_id;
8306
8307 switch (CMD_ID) {
8308 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8309 len = sizeof(*cmd);
8310 buf = wmi_buf_alloc(wmi_handle, len);
8311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308312 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8313 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308314 }
8315 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8316 wmi_buf_data(buf);
8317 WMITLV_SET_HDR(&cmd->tlv_header,
8318 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8319 WMITLV_GET_STRUCT_TLVLEN
8320 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8321 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308322 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8323 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308324 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8325 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8327 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308328 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308329 goto wmi_send_failed;
8330 }
8331 break;
8332 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8333 len = sizeof(*disable_cmd);
8334 buf = wmi_buf_alloc(wmi_handle, len);
8335 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308336 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8337 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308338 }
8339 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8340 wmi_buf_data(buf);
8341 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8342 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8343 WMITLV_GET_STRUCT_TLVLEN
8344 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308345 disable_cmd->pdev_id =
8346 wmi_handle->ops->convert_pdev_id_host_to_target(
8347 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8349 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308350 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308351 goto wmi_send_failed;
8352 }
8353 break;
8354 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308355 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308356 break;
8357 }
8358
Govind Singhb53420c2016-03-09 14:32:57 +05308359 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308360
8361wmi_send_failed:
8362 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308363 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308364}
8365#endif /* REMOVE_PKT_LOG */
8366
8367/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308368 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8369 * @wmi_handle: wmi handle
8370 * @ptrn_id: pattern id
8371 * @vdev_id: vdev id
8372 *
8373 * Return: CDF status
8374 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308375static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8376 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308377{
8378 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8379 wmi_buf_t buf;
8380 int32_t len;
8381 int ret;
8382
8383 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8384
8385
8386 buf = wmi_buf_alloc(wmi_handle, len);
8387 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308388 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8389 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 }
8391
8392 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8393
8394 WMITLV_SET_HDR(&cmd->tlv_header,
8395 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8396 WMITLV_GET_STRUCT_TLVLEN(
8397 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8398 cmd->vdev_id = vdev_id;
8399 cmd->pattern_id = ptrn_id;
8400 cmd->pattern_type = WOW_BITMAP_PATTERN;
8401
Govind Singhb53420c2016-03-09 14:32:57 +05308402 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308403 cmd->pattern_id, vdev_id);
8404
8405 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8406 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8407 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308408 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308409 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308410 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 }
8412
Govind Singhb53420c2016-03-09 14:32:57 +05308413 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308414}
8415
8416/**
8417 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8418 * @wmi_handle: wmi handle
8419 *
8420 * Sends host wakeup indication to FW. On receiving this indication,
8421 * FW will come out of WOW.
8422 *
8423 * Return: CDF status
8424 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308425static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308426{
8427 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8428 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308429 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308430 int32_t len;
8431 int ret;
8432
8433 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8434
8435 buf = wmi_buf_alloc(wmi_handle, len);
8436 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308437 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8438 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308439 }
8440
8441 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8442 wmi_buf_data(buf);
8443 WMITLV_SET_HDR(&cmd->tlv_header,
8444 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8445 WMITLV_GET_STRUCT_TLVLEN
8446 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8447
8448
8449 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8450 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8451 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308452 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308453 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308454 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308455 }
8456
Govind Singhb53420c2016-03-09 14:32:57 +05308457 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308458}
8459
8460/**
8461 * send_del_ts_cmd_tlv() - send DELTS request to fw
8462 * @wmi_handle: wmi handle
8463 * @msg: delts params
8464 *
8465 * Return: CDF status
8466 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308467static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308468 uint8_t ac)
8469{
8470 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8471 wmi_buf_t buf;
8472 int32_t len = sizeof(*cmd);
8473
8474 buf = wmi_buf_alloc(wmi_handle, len);
8475 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308476 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8477 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308478 }
8479 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8480 WMITLV_SET_HDR(&cmd->tlv_header,
8481 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8482 WMITLV_GET_STRUCT_TLVLEN
8483 (wmi_vdev_wmm_delts_cmd_fixed_param));
8484 cmd->vdev_id = vdev_id;
8485 cmd->ac = ac;
8486
Govind Singhb53420c2016-03-09 14:32:57 +05308487 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308488 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8489 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8490 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308491 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308492 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308493 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308494 }
8495
Govind Singhb53420c2016-03-09 14:32:57 +05308496 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308497}
8498
8499/**
8500 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8501 * @wmi_handle: handle to wmi
8502 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8503 *
Govind Singhb53420c2016-03-09 14:32:57 +05308504 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308505 * ADD_TS requestes to firmware in loop for all the ACs with
8506 * active flow.
8507 *
8508 * Return: CDF status
8509 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308510static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308511 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8512{
8513 int i = 0;
8514 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8515 wmi_buf_t buf;
8516 int32_t len = sizeof(*cmd);
8517
8518 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8519 /* if flow in this AC is active */
8520 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8521 /*
8522 * as per implementation of wma_add_ts_req() we
8523 * are not waiting any response from firmware so
8524 * apart from sending ADDTS to firmware just send
8525 * success to upper layers
8526 */
Govind Singhb53420c2016-03-09 14:32:57 +05308527 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308528
8529 buf = wmi_buf_alloc(wmi_handle, len);
8530 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308531 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8532 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308533 }
8534 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8535 wmi_buf_data(buf);
8536 WMITLV_SET_HDR(&cmd->tlv_header,
8537 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8538 WMITLV_GET_STRUCT_TLVLEN
8539 (wmi_vdev_wmm_addts_cmd_fixed_param));
8540 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8541 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308542 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 traffic.userPrio);
8544 cmd->medium_time_us =
8545 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8546 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308547 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308548 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8549 cmd->medium_time_us, cmd->downgrade_type);
8550 if (wmi_unified_cmd_send
8551 (wmi_handle, buf, len,
8552 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308553 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308554 __func__);
8555 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308556 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308557 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308558 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308559 }
8560 }
8561 }
8562
Govind Singhb53420c2016-03-09 14:32:57 +05308563 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308564}
8565
8566/**
8567 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8568 * @wmi_handle: wmi handle
8569 * @msg: ADDTS params
8570 *
8571 * Return: CDF status
8572 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308573static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308574 struct add_ts_param *msg)
8575{
8576 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8577 wmi_buf_t buf;
8578 int32_t len = sizeof(*cmd);
8579
Govind Singhb53420c2016-03-09 14:32:57 +05308580 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308581
8582 buf = wmi_buf_alloc(wmi_handle, len);
8583 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308584 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8585 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308586 }
8587 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8588 WMITLV_SET_HDR(&cmd->tlv_header,
8589 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8590 WMITLV_GET_STRUCT_TLVLEN
8591 (wmi_vdev_wmm_addts_cmd_fixed_param));
8592 cmd->vdev_id = msg->sme_session_id;
8593 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8594 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8595 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308596 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308597 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8598 cmd->downgrade_type, __func__, __LINE__);
8599 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8600 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308601 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8602 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308603 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308604 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308605 }
8606
Govind Singhb53420c2016-03-09 14:32:57 +05308607 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308608}
8609
8610/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308611 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8612 * @wmi_handle: wmi handle
8613 * @pAddPeriodicTxPtrnParams: tx ptrn params
8614 *
8615 * Retrun: CDF status
8616 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308617static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308618 struct periodic_tx_pattern *
8619 pAddPeriodicTxPtrnParams,
8620 uint8_t vdev_id)
8621{
8622 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8623 wmi_buf_t wmi_buf;
8624 uint32_t len;
8625 uint8_t *buf_ptr;
8626 uint32_t ptrn_len, ptrn_len_aligned;
8627 int j;
8628
8629 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8630 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8631 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8632 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8633
8634 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8635 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308636 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8637 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308638 }
8639
8640 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8641
8642 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8643 WMITLV_SET_HDR(&cmd->tlv_header,
8644 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8645 WMITLV_GET_STRUCT_TLVLEN
8646 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8647
8648 /* Pass the pattern id to delete for the corresponding vdev id */
8649 cmd->vdev_id = vdev_id;
8650 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8651 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8652 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8653
8654 /* Pattern info */
8655 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8656 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8657 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308658 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308659 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308660 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308661
Govind Singhb53420c2016-03-09 14:32:57 +05308662 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308663 __func__, cmd->pattern_id, cmd->vdev_id);
8664
8665 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8666 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308667 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308668 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308669 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308670 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308671 }
Govind Singhb53420c2016-03-09 14:32:57 +05308672 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308673}
8674
8675/**
8676 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8677 * @wmi_handle: wmi handle
8678 * @vdev_id: vdev id
8679 * @pattern_id: pattern id
8680 *
8681 * Retrun: CDF status
8682 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308683static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308684 uint8_t vdev_id,
8685 uint8_t pattern_id)
8686{
8687 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8688 wmi_buf_t wmi_buf;
8689 uint32_t len =
8690 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8691
8692 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8693 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308694 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8695 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308696 }
8697
8698 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8699 wmi_buf_data(wmi_buf);
8700 WMITLV_SET_HDR(&cmd->tlv_header,
8701 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8702 WMITLV_GET_STRUCT_TLVLEN
8703 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8704
8705 /* Pass the pattern id to delete for the corresponding vdev id */
8706 cmd->vdev_id = vdev_id;
8707 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308708 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308709 __func__, cmd->pattern_id, cmd->vdev_id);
8710
8711 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8712 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308713 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308714 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308715 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308716 }
Govind Singhb53420c2016-03-09 14:32:57 +05308717 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308718}
8719
8720/**
8721 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8722 * @wmi_handle: wmi handle
8723 * @preq: stats ext params
8724 *
8725 * Return: CDF status
8726 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308727static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308728 struct stats_ext_params *preq)
8729{
Govind Singh67922e82016-04-01 16:48:57 +05308730 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308731 wmi_req_stats_ext_cmd_fixed_param *cmd;
8732 wmi_buf_t buf;
8733 uint16_t len;
8734 uint8_t *buf_ptr;
8735
8736 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8737
8738 buf = wmi_buf_alloc(wmi_handle, len);
8739 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308740 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308741 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308742 }
8743
8744 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8745 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8746
8747 WMITLV_SET_HDR(&cmd->tlv_header,
8748 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8749 WMITLV_GET_STRUCT_TLVLEN
8750 (wmi_req_stats_ext_cmd_fixed_param));
8751 cmd->vdev_id = preq->vdev_id;
8752 cmd->data_len = preq->request_data_len;
8753
Govind Singhb53420c2016-03-09 14:32:57 +05308754 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308755 __func__, preq->request_data_len, preq->vdev_id);
8756
8757 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8758 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8759
8760 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308761 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308762
8763 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8764 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308765 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308766 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308767 ret);
8768 wmi_buf_free(buf);
8769 }
8770
8771 return ret;
8772}
8773
8774/**
8775 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8776 * @wmi_handle: wmi handle
8777 * @params: ext wow params
8778 *
8779 * Return:0 for success or error code
8780 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308781static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308782 struct ext_wow_params *params)
8783{
8784 wmi_extwow_enable_cmd_fixed_param *cmd;
8785 wmi_buf_t buf;
8786 int32_t len;
8787 int ret;
8788
8789 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8790 buf = wmi_buf_alloc(wmi_handle, len);
8791 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308792 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8793 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 }
8795
8796 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8797
8798 WMITLV_SET_HDR(&cmd->tlv_header,
8799 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8800 WMITLV_GET_STRUCT_TLVLEN
8801 (wmi_extwow_enable_cmd_fixed_param));
8802
8803 cmd->vdev_id = params->vdev_id;
8804 cmd->type = params->type;
8805 cmd->wakeup_pin_num = params->wakeup_pin_num;
8806
Govind Singhb53420c2016-03-09 14:32:57 +05308807 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308808 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8809
8810 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8811 WMI_EXTWOW_ENABLE_CMDID);
8812 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308813 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308814 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308815 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308816 }
8817
Govind Singhb53420c2016-03-09 14:32:57 +05308818 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308819
8820}
8821
8822/**
8823 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8824 * @wmi_handle: wmi handle
8825 * @app_type1_params: app type1 params
8826 *
8827 * Return: CDF status
8828 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308829static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308830 struct app_type1_params *app_type1_params)
8831{
8832 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8833 wmi_buf_t buf;
8834 int32_t len;
8835 int ret;
8836
8837 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8838 buf = wmi_buf_alloc(wmi_handle, len);
8839 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308840 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8841 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 }
8843
8844 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8845 wmi_buf_data(buf);
8846
8847 WMITLV_SET_HDR(&cmd->tlv_header,
8848 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8849 WMITLV_GET_STRUCT_TLVLEN
8850 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8851
8852 cmd->vdev_id = app_type1_params->vdev_id;
8853 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8854 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308855 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308856 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308857 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308858 cmd->passwd_len = app_type1_params->pass_length;
8859
Govind Singhb53420c2016-03-09 14:32:57 +05308860 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308861 "identification_id %.8s id_length %u "
8862 "password %.16s pass_length %u",
8863 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8864 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8865
8866 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8867 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8868 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308869 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308871 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 }
8873
Govind Singhb53420c2016-03-09 14:32:57 +05308874 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308875}
8876
8877/**
8878 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8879 * @wmi_handle: wmi handle
8880 * @appType2Params: app type2 params
8881 *
8882 * Return: CDF status
8883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308884static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308885 struct app_type2_params *appType2Params)
8886{
8887 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8888 wmi_buf_t buf;
8889 int32_t len;
8890 int ret;
8891
8892 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8893 buf = wmi_buf_alloc(wmi_handle, len);
8894 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308895 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8896 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308897 }
8898
8899 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8900 wmi_buf_data(buf);
8901
8902 WMITLV_SET_HDR(&cmd->tlv_header,
8903 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8904 WMITLV_GET_STRUCT_TLVLEN
8905 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8906
8907 cmd->vdev_id = appType2Params->vdev_id;
8908
Govind Singhb53420c2016-03-09 14:32:57 +05308909 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308910 cmd->rc4_key_len = appType2Params->rc4_key_len;
8911
8912 cmd->ip_id = appType2Params->ip_id;
8913 cmd->ip_device_ip = appType2Params->ip_device_ip;
8914 cmd->ip_server_ip = appType2Params->ip_server_ip;
8915
8916 cmd->tcp_src_port = appType2Params->tcp_src_port;
8917 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8918 cmd->tcp_seq = appType2Params->tcp_seq;
8919 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8920
8921 cmd->keepalive_init = appType2Params->keepalive_init;
8922 cmd->keepalive_min = appType2Params->keepalive_min;
8923 cmd->keepalive_max = appType2Params->keepalive_max;
8924 cmd->keepalive_inc = appType2Params->keepalive_inc;
8925
8926 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8927 &cmd->gateway_mac);
8928 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8929 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8930
Govind Singhb53420c2016-03-09 14:32:57 +05308931 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308932 "rc4_key %.16s rc4_key_len %u "
8933 "ip_id %x ip_device_ip %x ip_server_ip %x "
8934 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8935 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8936 "keepalive_max %u keepalive_inc %u "
8937 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8938 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8939 cmd->rc4_key, cmd->rc4_key_len,
8940 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8941 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8942 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8943 cmd->keepalive_max, cmd->keepalive_inc,
8944 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8945
8946 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8947 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8948 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308949 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308950 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308951 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308952 }
8953
Govind Singhb53420c2016-03-09 14:32:57 +05308954 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308955
8956}
8957
8958/**
8959 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8960 * @wmi_handle: wmi handle
8961 * @timer_val: auto shutdown timer value
8962 *
8963 * Return: CDF status
8964 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308965static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308966 uint32_t timer_val)
8967{
Govind Singh67922e82016-04-01 16:48:57 +05308968 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308969 wmi_buf_t buf = NULL;
8970 uint8_t *buf_ptr;
8971 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8972 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8973
Govind Singhb53420c2016-03-09 14:32:57 +05308974 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308975 __func__, timer_val);
8976
8977 buf = wmi_buf_alloc(wmi_handle, len);
8978 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308979 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8980 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308981 }
8982
8983 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8984 wmi_auto_sh_cmd =
8985 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8986 wmi_auto_sh_cmd->timer_value = timer_val;
8987
8988 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8989 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8990 WMITLV_GET_STRUCT_TLVLEN
8991 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8992
8993 status = wmi_unified_cmd_send(wmi_handle, buf,
8994 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308995 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308996 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308997 __func__, status);
8998 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308999 }
9000
Govind Singh67922e82016-04-01 16:48:57 +05309001 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309002}
9003
9004/**
9005 * send_nan_req_cmd_tlv() - to send nan request to target
9006 * @wmi_handle: wmi handle
9007 * @nan_req: request data which will be non-null
9008 *
9009 * Return: CDF status
9010 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309011static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309012 struct nan_req_params *nan_req)
9013{
Govind Singh67922e82016-04-01 16:48:57 +05309014 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309015 wmi_nan_cmd_param *cmd;
9016 wmi_buf_t buf;
9017 uint16_t len = sizeof(*cmd);
9018 uint16_t nan_data_len, nan_data_len_aligned;
9019 uint8_t *buf_ptr;
9020
9021 /*
9022 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9023 * +------------+----------+-----------------------+--------------+
9024 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9025 * +------------+----------+-----------------------+--------------+
9026 */
9027 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309028 WMI_LOGE("%s:nan req is not valid", __func__);
9029 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309030 }
9031 nan_data_len = nan_req->request_data_len;
9032 nan_data_len_aligned = roundup(nan_req->request_data_len,
9033 sizeof(uint32_t));
9034 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9035 buf = wmi_buf_alloc(wmi_handle, len);
9036 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309037 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9038 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309039 }
9040 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9041 cmd = (wmi_nan_cmd_param *) buf_ptr;
9042 WMITLV_SET_HDR(&cmd->tlv_header,
9043 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9044 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9045 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309046 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 __func__, nan_req->request_data_len);
9048 buf_ptr += sizeof(wmi_nan_cmd_param);
9049 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9050 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309051 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309052
9053 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9054 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309055 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309056 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309057 __func__, ret);
9058 wmi_buf_free(buf);
9059 }
9060
9061 return ret;
9062}
9063
9064/**
9065 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9066 * @wmi_handle: wmi handle
9067 * @pDhcpSrvOffloadInfo: DHCP server offload info
9068 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309069 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309071static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9073{
9074 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9075 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309076 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309077
9078 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309080 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309081 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309082 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309083 }
9084
9085 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309086 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309087
9088 WMITLV_SET_HDR(&cmd->tlv_header,
9089 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9090 WMITLV_GET_STRUCT_TLVLEN
9091 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9092 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9093 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9094 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9095 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9096 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309097 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309098 sizeof(*cmd),
9099 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309100 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309101 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309102 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309103 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 }
Govind Singhb53420c2016-03-09 14:32:57 +05309105 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309106 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309107
9108 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309109}
9110
9111/**
9112 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9113 * @wmi_handle: wmi handle
9114 * @flashing: flashing request
9115 *
9116 * Return: CDF status
9117 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309118static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309119 struct flashing_req_params *flashing)
9120{
9121 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309122 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 wmi_buf_t buf;
9124 uint8_t *buf_ptr;
9125 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9126
9127 buf = wmi_buf_alloc(wmi_handle, len);
9128 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309129 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309130 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309131 }
9132 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9133 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9134 WMITLV_SET_HDR(&cmd->tlv_header,
9135 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9136 WMITLV_GET_STRUCT_TLVLEN
9137 (wmi_set_led_flashing_cmd_fixed_param));
9138 cmd->pattern_id = flashing->pattern_id;
9139 cmd->led_x0 = flashing->led_x0;
9140 cmd->led_x1 = flashing->led_x1;
9141
9142 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9143 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309144 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309145 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309146 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309147 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309148 }
Govind Singh67922e82016-04-01 16:48:57 +05309149
9150 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309151}
9152
9153/**
9154 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9155 * @wmi_handle: wmi handle
9156 * @ch_avoid_update_req: channel avoid update params
9157 *
9158 * Return: CDF status
9159 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309160static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309161{
Govind Singh67922e82016-04-01 16:48:57 +05309162 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309163 wmi_buf_t buf = NULL;
9164 uint8_t *buf_ptr;
9165 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9166 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9167
9168
9169 buf = wmi_buf_alloc(wmi_handle, len);
9170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9172 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309173 }
9174
9175 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9176 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9177 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9178 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9179 WMITLV_GET_STRUCT_TLVLEN
9180 (wmi_chan_avoid_update_cmd_param));
9181
9182 status = wmi_unified_cmd_send(wmi_handle, buf,
9183 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309184 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309185 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309186 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9187 " returned Error %d", status);
9188 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309189 }
9190
Govind Singh67922e82016-04-01 16:48:57 +05309191 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309192}
9193
9194/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309195 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9196 * @wmi_handle: wmi handle
9197 * @param: pointer to pdev regdomain params
9198 *
9199 * Return: 0 for success or error code
9200 */
9201static QDF_STATUS
9202send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9203 struct pdev_set_regdomain_params *param)
9204{
9205 wmi_buf_t buf;
9206 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9207 int32_t len = sizeof(*cmd);
9208
9209
9210 buf = wmi_buf_alloc(wmi_handle, len);
9211 if (!buf) {
9212 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9213 return QDF_STATUS_E_NOMEM;
9214 }
9215 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9216 WMITLV_SET_HDR(&cmd->tlv_header,
9217 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9218 WMITLV_GET_STRUCT_TLVLEN
9219 (wmi_pdev_set_regdomain_cmd_fixed_param));
9220
9221 cmd->reg_domain = param->currentRDinuse;
9222 cmd->reg_domain_2G = param->currentRD2G;
9223 cmd->reg_domain_5G = param->currentRD5G;
9224 cmd->conformance_test_limit_2G = param->ctl_2G;
9225 cmd->conformance_test_limit_5G = param->ctl_5G;
9226 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309227 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9228 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309229
9230 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9231 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9232 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9233 __func__);
9234 wmi_buf_free(buf);
9235 return QDF_STATUS_E_FAILURE;
9236 }
9237
9238 return QDF_STATUS_SUCCESS;
9239}
9240
9241/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309242 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9243 * @wmi_handle: wmi handle
9244 * @reg_dmn: reg domain
9245 * @regdmn2G: 2G reg domain
9246 * @regdmn5G: 5G reg domain
9247 * @ctl2G: 2G test limit
9248 * @ctl5G: 5G test limit
9249 *
9250 * Return: none
9251 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309252static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 uint32_t reg_dmn, uint16_t regdmn2G,
9254 uint16_t regdmn5G, int8_t ctl2G,
9255 int8_t ctl5G)
9256{
9257 wmi_buf_t buf;
9258 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9259 int32_t len = sizeof(*cmd);
9260
9261
9262 buf = wmi_buf_alloc(wmi_handle, len);
9263 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309264 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9265 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309266 }
9267 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9268 WMITLV_SET_HDR(&cmd->tlv_header,
9269 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9270 WMITLV_GET_STRUCT_TLVLEN
9271 (wmi_pdev_set_regdomain_cmd_fixed_param));
9272 cmd->reg_domain = reg_dmn;
9273 cmd->reg_domain_2G = regdmn2G;
9274 cmd->reg_domain_5G = regdmn5G;
9275 cmd->conformance_test_limit_2G = ctl2G;
9276 cmd->conformance_test_limit_5G = ctl5G;
9277
9278 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9279 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309280 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309281 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309282 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309283 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 }
9285
Govind Singhb53420c2016-03-09 14:32:57 +05309286 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309287}
9288
9289
9290/**
9291 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9292 * @wmi_handle: wmi handle
9293 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9294 *
9295 * This function sets tdls off channel mode
9296 *
9297 * Return: 0 on success; Negative errno otherwise
9298 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309299static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309300 struct tdls_channel_switch_params *chan_switch_params)
9301{
9302 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9303 wmi_buf_t wmi_buf;
9304 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9305
9306 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9307 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309308 WMI_LOGE(FL("wmi_buf_alloc failed"));
9309 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309310 }
9311 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9312 wmi_buf_data(wmi_buf);
9313 WMITLV_SET_HDR(&cmd->tlv_header,
9314 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9315 WMITLV_GET_STRUCT_TLVLEN(
9316 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9317
9318 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9319 &cmd->peer_macaddr);
9320 cmd->vdev_id = chan_switch_params->vdev_id;
9321 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9322 cmd->is_peer_responder = chan_switch_params->is_responder;
9323 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9324 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9325 cmd->offchan_oper_class = chan_switch_params->oper_class;
9326
Govind Singhb53420c2016-03-09 14:32:57 +05309327 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309328 cmd->peer_macaddr.mac_addr31to0,
9329 cmd->peer_macaddr.mac_addr47to32);
9330
Govind Singhb53420c2016-03-09 14:32:57 +05309331 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309332 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9333 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9334 ),
9335 cmd->vdev_id,
9336 cmd->offchan_mode,
9337 cmd->offchan_num,
9338 cmd->offchan_bw_bitmap,
9339 cmd->is_peer_responder,
9340 cmd->offchan_oper_class);
9341
9342 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9343 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309344 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309345 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309346 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309347 }
9348
9349
Govind Singhb53420c2016-03-09 14:32:57 +05309350 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309351}
9352
9353/**
9354 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9355 * @wmi_handle: wmi handle
9356 * @pwmaTdlsparams: TDLS params
9357 *
9358 * Return: 0 for sucess or error code
9359 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309360static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309361 void *tdls_param, uint8_t tdls_state)
9362{
9363 wmi_tdls_set_state_cmd_fixed_param *cmd;
9364 wmi_buf_t wmi_buf;
9365
9366 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9367 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9368
9369 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9370 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309371 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9372 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309373 }
9374 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9375 WMITLV_SET_HDR(&cmd->tlv_header,
9376 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9377 WMITLV_GET_STRUCT_TLVLEN
9378 (wmi_tdls_set_state_cmd_fixed_param));
9379 cmd->vdev_id = wmi_tdls->vdev_id;
9380 cmd->state = tdls_state;
9381 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9382 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9383 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9384 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9385 cmd->rssi_delta = wmi_tdls->rssi_delta;
9386 cmd->tdls_options = wmi_tdls->tdls_options;
9387 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9388 cmd->tdls_peer_traffic_response_timeout_ms =
9389 wmi_tdls->peer_traffic_response_timeout;
9390 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9391 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9392 cmd->tdls_puapsd_rx_frame_threshold =
9393 wmi_tdls->puapsd_rx_frame_threshold;
9394 cmd->teardown_notification_ms =
9395 wmi_tdls->teardown_notification_ms;
9396 cmd->tdls_peer_kickout_threshold =
9397 wmi_tdls->tdls_peer_kickout_threshold;
9398
Govind Singhb53420c2016-03-09 14:32:57 +05309399 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309400 "notification_interval_ms: %d, "
9401 "tx_discovery_threshold: %d, "
9402 "tx_teardown_threshold: %d, "
9403 "rssi_teardown_threshold: %d, "
9404 "rssi_delta: %d, "
9405 "tdls_options: 0x%x, "
9406 "tdls_peer_traffic_ind_window: %d, "
9407 "tdls_peer_traffic_response_timeout: %d, "
9408 "tdls_puapsd_mask: 0x%x, "
9409 "tdls_puapsd_inactivity_time: %d, "
9410 "tdls_puapsd_rx_frame_threshold: %d, "
9411 "teardown_notification_ms: %d, "
9412 "tdls_peer_kickout_threshold: %d",
9413 __func__, tdls_state, cmd->state,
9414 cmd->notification_interval_ms,
9415 cmd->tx_discovery_threshold,
9416 cmd->tx_teardown_threshold,
9417 cmd->rssi_teardown_threshold,
9418 cmd->rssi_delta,
9419 cmd->tdls_options,
9420 cmd->tdls_peer_traffic_ind_window,
9421 cmd->tdls_peer_traffic_response_timeout_ms,
9422 cmd->tdls_puapsd_mask,
9423 cmd->tdls_puapsd_inactivity_time_ms,
9424 cmd->tdls_puapsd_rx_frame_threshold,
9425 cmd->teardown_notification_ms,
9426 cmd->tdls_peer_kickout_threshold);
9427
9428 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9429 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309430 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309431 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309432 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309433 }
Govind Singhb53420c2016-03-09 14:32:57 +05309434 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309435
Govind Singhb53420c2016-03-09 14:32:57 +05309436 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309437}
9438
9439/**
9440 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9441 * @wmi_handle: wmi handle
9442 * @peerStateParams: TDLS peer state params
9443 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309444 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309445 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309446static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309447 struct tdls_peer_state_params *peerStateParams,
9448 uint32_t *ch_mhz)
9449{
9450 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9451 wmi_tdls_peer_capabilities *peer_cap;
9452 wmi_channel *chan_info;
9453 wmi_buf_t wmi_buf;
9454 uint8_t *buf_ptr;
9455 uint32_t i;
9456 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9457 sizeof(wmi_tdls_peer_capabilities);
9458
9459
9460 len += WMI_TLV_HDR_SIZE +
9461 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9462
9463 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9464 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309465 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9466 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309467 }
9468
9469 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9470 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9471 WMITLV_SET_HDR(&cmd->tlv_header,
9472 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9473 WMITLV_GET_STRUCT_TLVLEN
9474 (wmi_tdls_peer_update_cmd_fixed_param));
9475
9476 cmd->vdev_id = peerStateParams->vdevId;
9477 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9478 &cmd->peer_macaddr);
9479
9480
9481 cmd->peer_state = peerStateParams->peerState;
9482
Govind Singhb53420c2016-03-09 14:32:57 +05309483 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309484 "peer_macaddr.mac_addr31to0: 0x%x, "
9485 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9486 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9487 cmd->peer_macaddr.mac_addr31to0,
9488 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9489
9490 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9491 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9492 WMITLV_SET_HDR(&peer_cap->tlv_header,
9493 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9494 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9495
9496 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9497 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9498 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9499 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9500 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9501 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9502 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9503 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9504
9505 /* Ack and More Data Ack are sent as 0, so no need to set
9506 * but fill SP
9507 */
9508 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9509 peerStateParams->peerCap.peerMaxSp);
9510
9511 peer_cap->buff_sta_support =
9512 peerStateParams->peerCap.peerBuffStaSupport;
9513 peer_cap->off_chan_support =
9514 peerStateParams->peerCap.peerOffChanSupport;
9515 peer_cap->peer_curr_operclass =
9516 peerStateParams->peerCap.peerCurrOperClass;
9517 /* self curr operclass is not being used and so pass op class for
9518 * preferred off chan in it.
9519 */
9520 peer_cap->self_curr_operclass =
9521 peerStateParams->peerCap.opClassForPrefOffChan;
9522 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9523 peer_cap->peer_operclass_len =
9524 peerStateParams->peerCap.peerOperClassLen;
9525
Govind Singhb53420c2016-03-09 14:32:57 +05309526 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309527 __func__, peer_cap->peer_operclass_len);
9528 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9529 peer_cap->peer_operclass[i] =
9530 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309531 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309532 __func__, i, peer_cap->peer_operclass[i]);
9533 }
9534
9535 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9536 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9537 peer_cap->pref_offchan_bw =
9538 peerStateParams->peerCap.prefOffChanBandwidth;
9539
Govind Singhb53420c2016-03-09 14:32:57 +05309540 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309541 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9542 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9543 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9544 " %d, pref_offchan_bw: %d",
9545 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9546 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9547 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9548 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9549 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9550
9551 /* next fill variable size array of peer chan info */
9552 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9553 WMITLV_SET_HDR(buf_ptr,
9554 WMITLV_TAG_ARRAY_STRUC,
9555 sizeof(wmi_channel) *
9556 peerStateParams->peerCap.peerChanLen);
9557 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9558
9559 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9560 WMITLV_SET_HDR(&chan_info->tlv_header,
9561 WMITLV_TAG_STRUC_wmi_channel,
9562 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9563 chan_info->mhz = ch_mhz[i];
9564 chan_info->band_center_freq1 = chan_info->mhz;
9565 chan_info->band_center_freq2 = 0;
9566
Govind Singhb53420c2016-03-09 14:32:57 +05309567 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309568
9569 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9570 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309571 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309572 peerStateParams->peerCap.peerChan[i].chanId,
9573 peerStateParams->peerCap.peerChan[i].dfsSet);
9574 }
9575
9576 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9577 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9578 else
9579 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9580
9581 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9582 peerStateParams->peerCap.
9583 peerChan[i].pwr);
9584
9585 WMI_SET_CHANNEL_REG_POWER(chan_info,
9586 peerStateParams->peerCap.peerChan[i].
9587 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309588 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309589 peerStateParams->peerCap.peerChan[i].pwr);
9590
9591 chan_info++;
9592 }
9593
9594 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9595 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309596 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309597 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309598 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309599 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309600 }
9601
9602
Govind Singhb53420c2016-03-09 14:32:57 +05309603 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309604}
9605
9606/*
9607 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9608 * firmware
9609 * @wmi_handle: Pointer to wmi handle
9610 * @mem_dump_req: Pointer for mem_dump_req
9611 *
9612 * This function sends memory dump request to firmware
9613 *
Govind Singhb53420c2016-03-09 14:32:57 +05309614 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309615 *
9616 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309617static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309618 struct fw_dump_req_param *mem_dump_req)
9619{
9620 wmi_get_fw_mem_dump_fixed_param *cmd;
9621 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309622 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309623 int32_t len;
9624 wmi_buf_t buf;
9625 u_int8_t *buf_ptr;
9626 int ret, loop;
9627
9628 /*
9629 * len = sizeof(fixed param) that includes tlv header +
9630 * tlv header for array of struc +
9631 * sizeof (each struct)
9632 */
9633 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9634 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9635 buf = wmi_buf_alloc(wmi_handle, len);
9636
9637 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309638 WMI_LOGE(FL("Failed allocate wmi buffer"));
9639 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309640 }
9641
9642 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309643 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309644 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9645
9646 WMITLV_SET_HDR(&cmd->tlv_header,
9647 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9648 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9649
9650 cmd->request_id = mem_dump_req->request_id;
9651 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9652
9653 /* TLV indicating array of structures to follow */
9654 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9655 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9656 sizeof(wmi_fw_mem_dump) *
9657 cmd->num_fw_mem_dump_segs);
9658
9659 buf_ptr += WMI_TLV_HDR_SIZE;
9660 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9661
Govind Singhb53420c2016-03-09 14:32:57 +05309662 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309663 mem_dump_req->request_id, mem_dump_req->num_seg);
9664 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309665 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309666 ((uint8_t *)(mem_dump_req->segment) +
9667 loop * sizeof(*seg_req));
9668 WMITLV_SET_HDR(&dump_params->tlv_header,
9669 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9670 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9671 dump_params->seg_id = seg_req->seg_id;
9672 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9673 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9674 dump_params->seg_length = seg_req->seg_length;
9675 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9676 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309677 WMI_LOGI(FL("seg_number:%d"), loop);
9678 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309679 dump_params->seg_id, dump_params->seg_start_addr_lo,
9680 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309681 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309682 dump_params->seg_length, dump_params->dest_addr_lo,
9683 dump_params->dest_addr_hi);
9684 dump_params++;
9685 }
9686
9687 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9688 WMI_GET_FW_MEM_DUMP_CMDID);
9689 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309690 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309691 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309692 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309693 }
9694
Govind Singhb53420c2016-03-09 14:32:57 +05309695 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9696 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309697}
9698
9699/*
9700 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9701 * @wmi_handle: Pointer to WMi handle
9702 * @ie_data: Pointer for ie data
9703 *
9704 * This function sends IE information to firmware
9705 *
Govind Singhb53420c2016-03-09 14:32:57 +05309706 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 *
9708 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309709static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309710 struct vdev_ie_info_param *ie_info)
9711{
9712 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9713 wmi_buf_t buf;
9714 uint8_t *buf_ptr;
9715 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309716 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309717
9718
9719 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9720 /* Allocate memory for the WMI command */
9721 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9722
9723 buf = wmi_buf_alloc(wmi_handle, len);
9724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309725 WMI_LOGE(FL("wmi_buf_alloc failed"));
9726 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309727 }
9728
9729 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309730 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309731
9732 /* Populate the WMI command */
9733 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9734
9735 WMITLV_SET_HDR(&cmd->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9737 WMITLV_GET_STRUCT_TLVLEN(
9738 wmi_vdev_set_ie_cmd_fixed_param));
9739 cmd->vdev_id = ie_info->vdev_id;
9740 cmd->ie_id = ie_info->ie_id;
9741 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009742 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309743
Govind Singhb53420c2016-03-09 14:32:57 +05309744 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309745 ie_info->length, ie_info->vdev_id);
9746
9747 buf_ptr += sizeof(*cmd);
9748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9749 buf_ptr += WMI_TLV_HDR_SIZE;
9750
Govind Singhb53420c2016-03-09 14:32:57 +05309751 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309752
9753 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9754 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309755 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309756 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309757 wmi_buf_free(buf);
9758 }
9759
9760 return ret;
9761}
9762
Sathish Kumar497bef42017-03-01 14:02:36 +05309763/**
9764 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9765 *
9766 * @param wmi_handle : handle to WMI.
9767 * @param param : pointer to antenna param
9768 *
9769 * This function sends smart antenna enable command to FW
9770 *
9771 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9772 */
9773static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9774 struct smart_ant_enable_params *param)
9775{
9776 /* Send WMI COMMAND to Enable */
9777 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9778 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9779 wmi_buf_t buf;
9780 uint8_t *buf_ptr;
9781 int len = 0;
9782 QDF_STATUS ret;
9783 int loop = 0;
9784
9785 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9786 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9787 buf = wmi_buf_alloc(wmi_handle, len);
9788
9789 if (!buf) {
9790 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9791 return QDF_STATUS_E_NOMEM;
9792 }
9793
9794 buf_ptr = wmi_buf_data(buf);
9795 qdf_mem_zero(buf_ptr, len);
9796 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9797
9798 WMITLV_SET_HDR(&cmd->tlv_header,
9799 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9800 WMITLV_GET_STRUCT_TLVLEN(
9801 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9802
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309803 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9804 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309805 cmd->enable = param->enable;
9806 cmd->mode = param->mode;
9807 cmd->rx_antenna = param->rx_antenna;
9808 cmd->tx_default_antenna = param->rx_antenna;
9809
9810 /* TLV indicating array of structures to follow */
9811 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9813 WMI_HAL_MAX_SANTENNA *
9814 sizeof(wmi_pdev_smart_ant_gpio_handle));
9815
9816 buf_ptr += WMI_TLV_HDR_SIZE;
9817 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9818
9819 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9820 WMITLV_SET_HDR(&gpio_param->tlv_header,
9821 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9822 WMITLV_GET_STRUCT_TLVLEN(
9823 wmi_pdev_smart_ant_gpio_handle));
9824 if (param->mode == SMART_ANT_MODE_SERIAL) {
9825 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9826 gpio_param->gpio_pin = param->gpio_pin[loop];
9827 gpio_param->gpio_func = param->gpio_func[loop];
9828 } else {
9829 gpio_param->gpio_pin = 0;
9830 gpio_param->gpio_func = 0;
9831 }
9832 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9833 gpio_param->gpio_pin = param->gpio_pin[loop];
9834 gpio_param->gpio_func = param->gpio_func[loop];
9835 }
9836 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309837 gpio_param->pdev_id =
9838 wmi_handle->ops->convert_pdev_id_host_to_target(
9839 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309840 gpio_param++;
9841 }
9842
9843 ret = wmi_unified_cmd_send(wmi_handle,
9844 buf,
9845 len,
9846 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9847
9848 if (ret != 0) {
9849 WMI_LOGE(" %s :WMI Failed\n", __func__);
9850 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9851 cmd->enable,
9852 cmd->mode,
9853 cmd->rx_antenna,
9854 param->gpio_pin[0], param->gpio_pin[1],
9855 param->gpio_pin[2], param->gpio_pin[3],
9856 param->gpio_func[0], param->gpio_func[1],
9857 param->gpio_func[2], param->gpio_func[3],
9858 ret);
9859 wmi_buf_free(buf);
9860 }
9861
9862 return ret;
9863}
9864
9865/**
9866 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9867 *
9868 * @param wmi_handle : handle to WMI.
9869 * @param param : pointer to rx antenna param
9870 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9871 */
9872static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9873 struct smart_ant_rx_ant_params *param)
9874{
9875 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9876 wmi_buf_t buf;
9877 uint8_t *buf_ptr;
9878 uint32_t len;
9879 QDF_STATUS ret;
9880
9881 len = sizeof(*cmd);
9882 buf = wmi_buf_alloc(wmi_handle, len);
9883 WMI_LOGD("%s:\n", __func__);
9884 if (!buf) {
9885 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9886 return QDF_STATUS_E_NOMEM;
9887 }
9888
9889 buf_ptr = wmi_buf_data(buf);
9890 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9891 WMITLV_SET_HDR(&cmd->tlv_header,
9892 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9893 WMITLV_GET_STRUCT_TLVLEN(
9894 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9895 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309896 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9897 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309898
9899 ret = wmi_unified_cmd_send(wmi_handle,
9900 buf,
9901 len,
9902 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9903
9904 if (ret != 0) {
9905 WMI_LOGE(" %s :WMI Failed\n", __func__);
9906 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9907 __func__,
9908 cmd->rx_antenna,
9909 ret);
9910 wmi_buf_free(buf);
9911 }
9912
9913 return ret;
9914}
9915
9916/**
9917 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9918 * @wmi_handle: wmi handle
9919 * @param: pointer to hold ctl table param
9920 *
9921 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9922 */
9923static QDF_STATUS
9924send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9925 struct ctl_table_params *param)
9926{
9927 uint16_t len, ctl_tlv_len;
9928 uint8_t *buf_ptr;
9929 wmi_buf_t buf;
9930 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9931 uint32_t *ctl_array;
9932
9933 if (!param->ctl_array)
9934 return QDF_STATUS_E_FAILURE;
9935
9936 if (param->ctl_cmd_len !=
9937 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9938 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9939 qdf_print("CTL array len not correct\n");
9940 return QDF_STATUS_E_FAILURE;
9941 }
9942
9943 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9944 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9945 len = sizeof(*cmd) + ctl_tlv_len;
9946
9947 buf = wmi_buf_alloc(wmi_handle, len);
9948 if (!buf) {
9949 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9950 return QDF_STATUS_E_FAILURE;
9951 }
9952
9953 buf_ptr = wmi_buf_data(buf);
9954 qdf_mem_zero(buf_ptr, len);
9955
9956 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9957
9958 WMITLV_SET_HDR(&cmd->tlv_header,
9959 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9960 WMITLV_GET_STRUCT_TLVLEN(
9961 wmi_pdev_set_ctl_table_cmd_fixed_param));
9962 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309963 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9964 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309965
9966 buf_ptr += sizeof(*cmd);
9967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9968 (cmd->ctl_len));
9969 buf_ptr += WMI_TLV_HDR_SIZE;
9970 ctl_array = (uint32_t *)buf_ptr;
9971
9972 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9973 sizeof(param->ctl_band));
9974 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9975 param->ctl_cmd_len -
9976 sizeof(param->ctl_band));
9977
9978 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9979 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9980 WMI_LOGE("%s:Failed to send command\n", __func__);
9981 wmi_buf_free(buf);
9982 return QDF_STATUS_E_FAILURE;
9983 }
9984
9985 return QDF_STATUS_SUCCESS;
9986}
9987
9988/**
9989 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9990 * @wmi_handle: wmi handle
9991 * @param: pointer to hold mimogain table param
9992 *
9993 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9994 */
9995static QDF_STATUS
9996send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9997 struct mimogain_table_params *param)
9998{
9999 uint16_t len, table_tlv_len;
10000 wmi_buf_t buf;
10001 uint8_t *buf_ptr;
10002 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10003 uint32_t *gain_table;
10004
10005 if (!param->array_gain)
10006 return QDF_STATUS_E_FAILURE;
10007
10008 /* len must be multiple of a single array gain table */
10009 if (param->tbl_len %
10010 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10011 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10012 WMI_LOGE("Array gain table len not correct\n");
10013 return QDF_STATUS_E_FAILURE;
10014 }
10015
10016 table_tlv_len = WMI_TLV_HDR_SIZE +
10017 roundup(param->tbl_len, sizeof(uint32_t));
10018 len = sizeof(*cmd) + table_tlv_len;
10019
10020 buf = wmi_buf_alloc(wmi_handle, len);
10021 if (!buf) {
10022 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10023 return QDF_STATUS_E_FAILURE;
10024 }
10025
10026 buf_ptr = wmi_buf_data(buf);
10027 qdf_mem_zero(buf_ptr, len);
10028
10029 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10030
10031 WMITLV_SET_HDR(&cmd->tlv_header,
10032 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10033 WMITLV_GET_STRUCT_TLVLEN(
10034 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10035
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010036 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10037 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010038 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10039 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10040 param->multichain_gain_bypass);
10041
10042 buf_ptr += sizeof(*cmd);
10043 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10044 (param->tbl_len));
10045 buf_ptr += WMI_TLV_HDR_SIZE;
10046 gain_table = (uint32_t *)buf_ptr;
10047
10048 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10049 param->array_gain,
10050 param->tbl_len);
10051
10052 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10053 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10054 return QDF_STATUS_E_FAILURE;
10055 }
10056
10057 return QDF_STATUS_SUCCESS;
10058}
10059
10060/**
10061 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10062 * info to fw
10063 * @wmi_handle: wmi handle
10064 * @param: pointer to hold packet power info param
10065 *
10066 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10067 */
10068static QDF_STATUS
10069send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10070 struct packet_power_info_params *param)
10071{
10072 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10073 wmi_buf_t wmibuf;
10074 uint8_t *buf_ptr;
10075 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10076
10077 wmibuf = wmi_buf_alloc(wmi_handle, len);
10078 if (wmibuf == NULL)
10079 return QDF_STATUS_E_NOMEM;
10080
10081 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10082
10083 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10084 WMITLV_SET_HDR(&cmd->tlv_header,
10085 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10086 WMITLV_GET_STRUCT_TLVLEN(
10087 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010088 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10089 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010090 cmd->rate_flags = param->rate_flags;
10091 cmd->nss = param->nss;
10092 cmd->preamble = param->preamble;
10093 cmd->hw_rate = param->hw_rate;
10094 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10095 __func__,
10096 __LINE__,
10097 WMI_PDEV_GET_TPC_CMDID,
10098 *((u_int32_t *)cmd));
10099 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10100 WMI_PDEV_GET_TPC_CMDID)) {
10101 WMI_LOGE(FL("Failed to get tpc command\n"));
10102 wmi_buf_free(wmibuf);
10103 return QDF_STATUS_E_FAILURE;
10104 }
10105
10106 return QDF_STATUS_SUCCESS;
10107}
10108
10109/**
10110 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10111 * @wmi_handle: wmi handle
10112 * @param: pointer to hold config ratemask params
10113 *
10114 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10115 */
10116static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10117 struct config_ratemask_params *param)
10118{
10119 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10120 wmi_buf_t buf;
10121 int32_t len = sizeof(*cmd);
10122
10123 buf = wmi_buf_alloc(wmi_handle, len);
10124 if (!buf) {
10125 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10126 return QDF_STATUS_E_FAILURE;
10127 }
10128 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10129 WMITLV_SET_HDR(&cmd->tlv_header,
10130 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10131 WMITLV_GET_STRUCT_TLVLEN(
10132 wmi_vdev_config_ratemask_cmd_fixed_param));
10133 cmd->vdev_id = param->vdev_id;
10134 cmd->type = param->type;
10135 cmd->mask_lower32 = param->lower32;
10136 cmd->mask_higher32 = param->higher32;
10137 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10138 param->vdev_id, param->type, param->lower32, param->higher32);
10139
10140 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10141 WMI_VDEV_RATEMASK_CMDID)) {
10142 WMI_LOGE("Seting vdev ratemask failed\n");
10143 wmi_buf_free(buf);
10144 return QDF_STATUS_E_FAILURE;
10145 }
10146
10147 return QDF_STATUS_SUCCESS;
10148}
10149
10150/**
10151 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10152 * @wmi_handle: wmi handle
10153 * @param: pointer to hold vap dscp tid map param
10154 *
10155 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10156 */
10157static QDF_STATUS
10158send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10159 struct vap_dscp_tid_map_params *param)
10160{
10161 wmi_buf_t buf;
10162 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10163 int32_t len = sizeof(*cmd);
10164
10165 buf = wmi_buf_alloc(wmi_handle, len);
10166 if (!buf) {
10167 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10168 return QDF_STATUS_E_FAILURE;
10169 }
10170
10171 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10172 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10173 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10174
10175 cmd->vdev_id = param->vdev_id;
10176 cmd->enable_override = 0;
10177
10178 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10179 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10180 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10181 WMI_LOGE("Failed to set dscp cmd\n");
10182 wmi_buf_free(buf);
10183 return QDF_STATUS_E_FAILURE;
10184 }
10185
10186 return QDF_STATUS_SUCCESS;
10187}
10188
10189/**
10190 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10191 * @wmi_handle: wmi handle
10192 * @macaddr: vdev mac address
10193 * @param: pointer to hold neigbour rx param
10194 *
10195 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10196 */
10197static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10198 uint8_t macaddr[IEEE80211_ADDR_LEN],
10199 struct set_neighbour_rx_params *param)
10200{
10201 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10202 wmi_buf_t buf;
10203 int32_t len = sizeof(*cmd);
10204
10205 buf = wmi_buf_alloc(wmi_handle, len);
10206 if (!buf) {
10207 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10208 return QDF_STATUS_E_FAILURE;
10209 }
10210 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10211 WMITLV_SET_HDR(&cmd->tlv_header,
10212 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10213 WMITLV_GET_STRUCT_TLVLEN(
10214 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10215 cmd->vdev_id = param->vdev_id;
10216 cmd->bssid_idx = param->idx;
10217 cmd->action = param->action;
10218 cmd->type = param->type;
10219 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10220 cmd->flag = 0;
10221
10222 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10223 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10224 WMI_LOGE("Failed to set neighbour rx param\n");
10225 wmi_buf_free(buf);
10226 return QDF_STATUS_E_FAILURE;
10227 }
10228
10229 return QDF_STATUS_SUCCESS;
10230}
10231
10232/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010233 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010234 * @param wmi_handle : handle to WMI.
10235 * @param macaddr : vdev mac address
10236 * @param param : pointer to tx antenna param
10237 *
10238 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10239 */
10240static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10241 uint8_t macaddr[IEEE80211_ADDR_LEN],
10242 struct smart_ant_tx_ant_params *param)
10243{
10244 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10245 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10246 wmi_buf_t buf;
10247 int32_t len = 0;
10248 int i;
10249 uint8_t *buf_ptr;
10250 QDF_STATUS ret;
10251
10252 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10253 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10254 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10255 buf = wmi_buf_alloc(wmi_handle, len);
10256
10257 if (!buf) {
10258 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10259 return QDF_STATUS_E_NOMEM;
10260 }
10261
10262 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10263 qdf_mem_zero(buf_ptr, len);
10264 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10265
10266 WMITLV_SET_HDR(&cmd->tlv_header,
10267 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10268 WMITLV_GET_STRUCT_TLVLEN(
10269 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10270
10271 cmd->vdev_id = param->vdev_id;
10272 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10273
10274 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10275 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10276 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10277 buf_ptr += WMI_TLV_HDR_SIZE;
10278 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10279
10280 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10281 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10282 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10283 WMITLV_GET_STRUCT_TLVLEN(
10284 wmi_peer_smart_ant_set_tx_antenna_series));
10285 ant_tx_series->antenna_series = param->antenna_array[i];
10286 ant_tx_series++;
10287 }
10288
10289 ret = wmi_unified_cmd_send(wmi_handle,
10290 buf,
10291 len,
10292 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10293
10294 if (ret != 0) {
10295 WMI_LOGE(" %s :WMI Failed\n", __func__);
10296 wmi_buf_free(buf);
10297 }
10298
10299 return ret;
10300}
10301
Sathish Kumar02c3b542017-02-22 17:24:45 +053010302/**
10303 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10304 * @wmi_handle: wmi handle
10305 * @param: pointer to hold ant switch tbl param
10306 *
10307 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10308 */
10309static QDF_STATUS
10310send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10311 struct ant_switch_tbl_params *param)
10312{
10313 uint8_t len;
10314 wmi_buf_t buf;
10315 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10316 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10317 uint8_t *buf_ptr;
10318
10319 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10320 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10321 buf = wmi_buf_alloc(wmi_handle, len);
10322
10323 if (!buf) {
10324 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10325 return QDF_STATUS_E_NOMEM;
10326 }
10327
10328 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10329 qdf_mem_zero(buf_ptr, len);
10330 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10331
10332 WMITLV_SET_HDR(&cmd->tlv_header,
10333 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10334 WMITLV_GET_STRUCT_TLVLEN(
10335 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10336
10337 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10338 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010339 cmd->mac_id =
10340 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010341
10342 /* TLV indicating array of structures to follow */
10343 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10344 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10345 sizeof(wmi_pdev_set_ant_ctrl_chain));
10346 buf_ptr += WMI_TLV_HDR_SIZE;
10347 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10348
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010349 ctrl_chain->pdev_id =
10350 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010351 ctrl_chain->antCtrlChain = param->antCtrlChain;
10352
10353 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10354 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10355 wmi_buf_free(buf);
10356 return QDF_STATUS_E_FAILURE;
10357 }
10358
10359 return QDF_STATUS_SUCCESS;
10360}
10361
10362/**
10363 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10364 * training information function
10365 * @param wmi_handle : handle to WMI.
10366 * @macaddr : vdev mac address
10367 * @param param : pointer to tx antenna param
10368 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10369 */
10370static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10371 wmi_unified_t wmi_handle,
10372 uint8_t macaddr[IEEE80211_ADDR_LEN],
10373 struct smart_ant_training_info_params *param)
10374{
10375 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10376 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10377 wmi_buf_t buf;
10378 uint8_t *buf_ptr;
10379 int32_t len = 0;
10380 QDF_STATUS ret;
10381 int loop;
10382
10383 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10384 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10385 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10386 buf = wmi_buf_alloc(wmi_handle, len);
10387
10388 if (!buf) {
10389 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10390 return QDF_STATUS_E_NOMEM;
10391 }
10392
10393 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10394 qdf_mem_zero(buf_ptr, len);
10395 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10396
10397 WMITLV_SET_HDR(&cmd->tlv_header,
10398 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10399 WMITLV_GET_STRUCT_TLVLEN(
10400 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10401
10402 cmd->vdev_id = param->vdev_id;
10403 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10404 cmd->num_pkts = param->numpkts;
10405
10406 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10407 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10408 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10409 WMI_SMART_ANT_MAX_RATE_SERIES);
10410
10411 buf_ptr += WMI_TLV_HDR_SIZE;
10412 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10413
10414 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10415 WMITLV_SET_HDR(&train_param->tlv_header,
10416 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10417 WMITLV_GET_STRUCT_TLVLEN(
10418 wmi_peer_smart_ant_set_train_antenna_param));
10419 train_param->train_rate_series = param->rate_array[loop];
10420 train_param->train_antenna_series = param->antenna_array[loop];
10421 train_param->rc_flags = 0;
10422 WMI_LOGI(FL("Series number:%d\n"), loop);
10423 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10424 train_param->train_rate_series,
10425 train_param->train_antenna_series);
10426 train_param++;
10427 }
10428
10429 ret = wmi_unified_cmd_send(wmi_handle,
10430 buf,
10431 len,
10432 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10433
10434 if (ret != 0) {
10435 WMI_LOGE(" %s :WMI Failed\n", __func__);
10436 wmi_buf_free(buf);
10437 return QDF_STATUS_E_FAILURE;
10438 }
10439
10440 return ret;
10441}
10442
10443/**
10444 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10445 * configuration function
10446 * @param wmi_handle : handle to WMI.
10447 * @macaddr : vdev mad address
10448 * @param param : pointer to tx antenna param
10449 *
10450 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10451 */
10452static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10453 wmi_unified_t wmi_handle,
10454 uint8_t macaddr[IEEE80211_ADDR_LEN],
10455 struct smart_ant_node_config_params *param)
10456{
10457 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10458 wmi_buf_t buf;
10459 uint8_t *buf_ptr;
10460 int32_t len = 0, args_tlv_len;
10461 int ret;
10462 int i = 0;
10463 A_UINT32 *node_config_args;
10464
10465 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10466 len = sizeof(*cmd) + args_tlv_len;
10467
10468 if ((param->args_count == 0)) {
10469 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10470 __func__, param->args_count);
10471 return QDF_STATUS_E_FAILURE;
10472 }
10473
10474 buf = wmi_buf_alloc(wmi_handle, len);
10475 if (!buf) {
10476 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10477 return QDF_STATUS_E_NOMEM;
10478 }
10479
10480 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10481 wmi_buf_data(buf);
10482 buf_ptr = (uint8_t *)cmd;
10483 WMITLV_SET_HDR(&cmd->tlv_header,
10484 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10485 WMITLV_GET_STRUCT_TLVLEN(
10486 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10487 cmd->vdev_id = param->vdev_id;
10488 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10489 cmd->cmd_id = param->cmd_id;
10490 cmd->args_count = param->args_count;
10491 buf_ptr += sizeof(
10492 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10494 (cmd->args_count * sizeof(A_UINT32)));
10495 buf_ptr += WMI_TLV_HDR_SIZE;
10496 node_config_args = (A_UINT32 *)buf_ptr;
10497
10498 for (i = 0; i < param->args_count; i++) {
10499 node_config_args[i] = param->args_arr[i];
10500 WMI_LOGI("%d", param->args_arr[i]);
10501 }
10502
10503 ret = wmi_unified_cmd_send(wmi_handle,
10504 buf,
10505 len,
10506 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10507
10508 if (ret != 0) {
10509 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10510 __func__, param->cmd_id, macaddr[0],
10511 macaddr[1], macaddr[2], macaddr[3],
10512 macaddr[4], macaddr[5], ret);
10513 wmi_buf_free(buf);
10514 }
10515
10516 return ret;
10517}
10518
10519/**
10520 * send_set_atf_cmd_tlv() - send set atf command to fw
10521 * @wmi_handle: wmi handle
10522 * @param: pointer to set atf param
10523 *
10524 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10525 */
10526static QDF_STATUS
10527send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10528 struct set_atf_params *param)
10529{
10530 wmi_atf_peer_info *peer_info;
10531 wmi_peer_atf_request_fixed_param *cmd;
10532 wmi_buf_t buf;
10533 uint8_t *buf_ptr;
10534 int i;
10535 int32_t len = 0;
10536 QDF_STATUS retval;
10537
10538 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10539 len += param->num_peers * sizeof(wmi_atf_peer_info);
10540 buf = wmi_buf_alloc(wmi_handle, len);
10541 if (!buf) {
10542 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10543 return QDF_STATUS_E_FAILURE;
10544 }
10545 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10546 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10547 WMITLV_SET_HDR(&cmd->tlv_header,
10548 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10549 WMITLV_GET_STRUCT_TLVLEN(
10550 wmi_peer_atf_request_fixed_param));
10551 cmd->num_peers = param->num_peers;
10552
10553 buf_ptr += sizeof(*cmd);
10554 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10555 sizeof(wmi_atf_peer_info) *
10556 cmd->num_peers);
10557 buf_ptr += WMI_TLV_HDR_SIZE;
10558 peer_info = (wmi_atf_peer_info *)buf_ptr;
10559
10560 for (i = 0; i < cmd->num_peers; i++) {
10561 WMITLV_SET_HDR(&peer_info->tlv_header,
10562 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10563 WMITLV_GET_STRUCT_TLVLEN(
10564 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010565 qdf_mem_copy(&(peer_info->peer_macaddr),
10566 &(param->peer_info[i].peer_macaddr),
10567 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010568 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010569 peer_info->vdev_id = param->peer_info[i].vdev_id;
10570 peer_info->pdev_id =
10571 wmi_handle->ops->convert_pdev_id_host_to_target(
10572 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010573 /*
10574 * TLV definition for peer atf request fixed param combines
10575 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10576 * stats and atf extension stats as two different
10577 * implementations.
10578 * Need to discuss with FW on this.
10579 *
10580 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10581 * peer_info->atf_units_reserved =
10582 * param->peer_ext_info[i].atf_index_reserved;
10583 */
10584 peer_info++;
10585 }
10586
10587 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10588 WMI_PEER_ATF_REQUEST_CMDID);
10589
10590 if (retval != QDF_STATUS_SUCCESS) {
10591 WMI_LOGE("%s : WMI Failed\n", __func__);
10592 wmi_buf_free(buf);
10593 }
10594
10595 return retval;
10596}
10597
10598/**
10599 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10600 * @wmi_handle: wmi handle
10601 * @param: pointer to hold fwtest param
10602 *
10603 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10604 */
10605static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10606 struct set_fwtest_params *param)
10607{
10608 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10609 wmi_buf_t buf;
10610 int32_t len = sizeof(*cmd);
10611
10612 buf = wmi_buf_alloc(wmi_handle, len);
10613
10614 if (!buf) {
10615 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10616 return QDF_STATUS_E_FAILURE;
10617 }
10618
10619 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10620 WMITLV_SET_HDR(&cmd->tlv_header,
10621 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10622 WMITLV_GET_STRUCT_TLVLEN(
10623 wmi_fwtest_set_param_cmd_fixed_param));
10624 cmd->param_id = param->arg;
10625 cmd->param_value = param->value;
10626
10627 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10628 WMI_LOGE("Setting FW test param failed\n");
10629 wmi_buf_free(buf);
10630 return QDF_STATUS_E_FAILURE;
10631 }
10632
10633 return QDF_STATUS_SUCCESS;
10634}
10635
10636/**
10637 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10638 * @wmi_handle: wmi handle
10639 * @param: pointer to qboost params
10640 * @macaddr: vdev mac address
10641 *
10642 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10643 */
10644static QDF_STATUS
10645send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10646 uint8_t macaddr[IEEE80211_ADDR_LEN],
10647 struct set_qboost_params *param)
10648{
10649 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10650 wmi_buf_t buf;
10651 int32_t len;
10652 QDF_STATUS ret;
10653
10654 len = sizeof(*cmd);
10655
10656 buf = wmi_buf_alloc(wmi_handle, len);
10657 if (!buf) {
10658 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10659 return QDF_STATUS_E_FAILURE;
10660 }
10661
10662 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10663 WMITLV_SET_HDR(&cmd->tlv_header,
10664 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10665 WMITLV_GET_STRUCT_TLVLEN(
10666 WMI_QBOOST_CFG_CMD_fixed_param));
10667 cmd->vdev_id = param->vdev_id;
10668 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10669 cmd->qb_enable = param->value;
10670
10671 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10672 WMI_QBOOST_CFG_CMDID);
10673
10674 if (ret != 0) {
10675 WMI_LOGE("Setting qboost cmd failed\n");
10676 wmi_buf_free(buf);
10677 }
10678
10679 return ret;
10680}
10681
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010682/**
10683 * send_gpio_config_cmd_tlv() - send gpio config to fw
10684 * @wmi_handle: wmi handle
10685 * @param: pointer to hold gpio config param
10686 *
10687 * Return: 0 for success or error code
10688 */
10689static QDF_STATUS
10690send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10691 struct gpio_config_params *param)
10692{
10693 wmi_gpio_config_cmd_fixed_param *cmd;
10694 wmi_buf_t buf;
10695 int32_t len;
10696 QDF_STATUS ret;
10697
10698 len = sizeof(*cmd);
10699
10700 /* Sanity Checks */
10701 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10702 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10703 return QDF_STATUS_E_FAILURE;
10704 }
10705
10706 buf = wmi_buf_alloc(wmi_handle, len);
10707 if (!buf) {
10708 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10709 return QDF_STATUS_E_FAILURE;
10710 }
10711
10712 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10713 WMITLV_SET_HDR(&cmd->tlv_header,
10714 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10715 WMITLV_GET_STRUCT_TLVLEN(
10716 wmi_gpio_config_cmd_fixed_param));
10717 cmd->gpio_num = param->gpio_num;
10718 cmd->input = param->input;
10719 cmd->pull_type = param->pull_type;
10720 cmd->intr_mode = param->intr_mode;
10721
10722 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10723 WMI_GPIO_CONFIG_CMDID);
10724
10725 if (ret != 0) {
10726 WMI_LOGE("Sending GPIO config cmd failed\n");
10727 wmi_buf_free(buf);
10728 }
10729
10730 return ret;
10731}
10732
10733/**
10734 * send_gpio_output_cmd_tlv() - send gpio output to fw
10735 * @wmi_handle: wmi handle
10736 * @param: pointer to hold gpio output param
10737 *
10738 * Return: 0 for success or error code
10739 */
10740static QDF_STATUS
10741send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10742 struct gpio_output_params *param)
10743{
10744 wmi_gpio_output_cmd_fixed_param *cmd;
10745 wmi_buf_t buf;
10746 int32_t len;
10747 QDF_STATUS ret;
10748
10749 len = sizeof(*cmd);
10750
10751 buf = wmi_buf_alloc(wmi_handle, len);
10752 if (!buf) {
10753 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10754 return QDF_STATUS_E_FAILURE;
10755 }
10756
10757 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10758 WMITLV_SET_HDR(&cmd->tlv_header,
10759 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10760 WMITLV_GET_STRUCT_TLVLEN(
10761 wmi_gpio_output_cmd_fixed_param));
10762 cmd->gpio_num = param->gpio_num;
10763 cmd->set = param->set;
10764
10765 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10766 WMI_GPIO_OUTPUT_CMDID);
10767
10768 if (ret != 0) {
10769 WMI_LOGE("Sending GPIO output cmd failed\n");
10770 wmi_buf_free(buf);
10771 }
10772
10773 return ret;
10774
10775}
10776
10777/**
10778 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10779 *
10780 * @param wmi_handle : handle to WMI.
10781 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10782 */
10783static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10784{
10785 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10786 wmi_buf_t buf;
10787 QDF_STATUS ret;
10788 int32_t len;
10789
10790 len = sizeof(*cmd);
10791
10792 buf = wmi_buf_alloc(wmi_handle, len);
10793 if (!buf) {
10794 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10795 return QDF_STATUS_E_FAILURE;
10796 }
10797
10798 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10799 WMITLV_SET_HDR(&cmd->tlv_header,
10800 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10801 WMITLV_GET_STRUCT_TLVLEN(
10802 wmi_pdev_dfs_disable_cmd_fixed_param));
10803 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010804 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10805 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010806
10807 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10808 WMI_PDEV_DFS_DISABLE_CMDID);
10809
10810 if (ret != 0) {
10811 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10812 wmi_buf_free(buf);
10813 }
10814
10815 return ret;
10816}
10817
10818/**
10819 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10820 *
10821 * @param wmi_handle : handle to WMI.
10822 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10823 */
10824static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10825{
10826 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10827 wmi_buf_t buf;
10828 QDF_STATUS ret;
10829 int32_t len;
10830
10831 len = sizeof(*cmd);
10832
10833 buf = wmi_buf_alloc(wmi_handle, len);
10834 if (!buf) {
10835 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10836 return QDF_STATUS_E_FAILURE;
10837 }
10838
10839 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10840 WMITLV_SET_HDR(&cmd->tlv_header,
10841 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10842 WMITLV_GET_STRUCT_TLVLEN(
10843 wmi_pdev_dfs_enable_cmd_fixed_param));
10844 /* Reserved for future use */
10845 cmd->reserved0 = 0;
10846
10847 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10848 WMI_PDEV_DFS_ENABLE_CMDID);
10849
10850 if (ret != 0) {
10851 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10852 wmi_buf_free(buf);
10853 }
10854
10855 return ret;
10856}
10857
10858/**
10859 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10860 * @wmi_handle: wmi handle
10861 *
10862 * Return: 0 for success or error code
10863 */
10864static QDF_STATUS
10865send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10866{
10867 wmi_buf_t buf;
10868 QDF_STATUS ret;
10869
10870 buf = wmi_buf_alloc(wmi_handle, 0);
10871 if (buf == NULL)
10872 return QDF_STATUS_E_NOMEM;
10873
10874 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10875 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10876 if (ret != 0) {
10877 WMI_LOGE("Sending get nfcal power cmd failed\n");
10878 wmi_buf_free(buf);
10879 }
10880
10881 return ret;
10882}
10883
10884/**
10885 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10886 * @wmi_handle: wmi handle
10887 * @param: pointer to ht ie param
10888 *
10889 * Return: 0 for success or error code
10890 */
10891static QDF_STATUS
10892send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10893 struct ht_ie_params *param)
10894{
10895 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10896 wmi_buf_t buf;
10897 QDF_STATUS ret;
10898 int32_t len;
10899 uint8_t *buf_ptr;
10900
10901 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10902 roundup(param->ie_len, sizeof(uint32_t));
10903
10904 buf = wmi_buf_alloc(wmi_handle, len);
10905 if (!buf) {
10906 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10907 return QDF_STATUS_E_FAILURE;
10908 }
10909
10910 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10911 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10912 WMITLV_SET_HDR(&cmd->tlv_header,
10913 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10914 WMITLV_GET_STRUCT_TLVLEN(
10915 wmi_pdev_set_ht_ie_cmd_fixed_param));
10916 cmd->reserved0 = 0;
10917 cmd->ie_len = param->ie_len;
10918 cmd->tx_streams = param->tx_streams;
10919 cmd->rx_streams = param->rx_streams;
10920
10921 buf_ptr += sizeof(*cmd);
10922 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10923 buf_ptr += WMI_TLV_HDR_SIZE;
10924 if (param->ie_len)
10925 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10926 cmd->ie_len);
10927
10928 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10929 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10930
10931 if (ret != 0) {
10932 WMI_LOGE("Sending set ht ie cmd failed\n");
10933 wmi_buf_free(buf);
10934 }
10935
10936 return ret;
10937}
10938
10939/**
10940 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10941 * @wmi_handle: wmi handle
10942 * @param: pointer to vht ie param
10943 *
10944 * Return: 0 for success or error code
10945 */
10946static QDF_STATUS
10947send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10948 struct vht_ie_params *param)
10949{
10950 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10951 wmi_buf_t buf;
10952 QDF_STATUS ret;
10953 int32_t len;
10954 uint8_t *buf_ptr;
10955
10956 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10957 roundup(param->ie_len, sizeof(uint32_t));
10958
10959 buf = wmi_buf_alloc(wmi_handle, len);
10960 if (!buf) {
10961 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10962 return QDF_STATUS_E_FAILURE;
10963 }
10964
10965 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10966 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10967 WMITLV_SET_HDR(&cmd->tlv_header,
10968 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10969 WMITLV_GET_STRUCT_TLVLEN(
10970 wmi_pdev_set_vht_ie_cmd_fixed_param));
10971 cmd->reserved0 = 0;
10972 cmd->ie_len = param->ie_len;
10973 cmd->tx_streams = param->tx_streams;
10974 cmd->rx_streams = param->rx_streams;
10975
10976 buf_ptr += sizeof(*cmd);
10977 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10978 buf_ptr += WMI_TLV_HDR_SIZE;
10979 if (param->ie_len)
10980 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10981 cmd->ie_len);
10982
10983 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10984 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10985
10986 if (ret != 0) {
10987 WMI_LOGE("Sending set vht ie cmd failed\n");
10988 wmi_buf_free(buf);
10989 }
10990
10991 return ret;
10992}
10993
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010994/**
10995 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
10996 * @wmi_handle: wmi handle
10997 * @param: pointer to quiet mode params
10998 *
10999 * Return: 0 for success or error code
11000 */
11001static QDF_STATUS
11002send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11003 struct set_quiet_mode_params *param)
11004{
11005 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11006 wmi_buf_t buf;
11007 QDF_STATUS ret;
11008 int32_t len;
11009
11010 len = sizeof(*quiet_cmd);
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 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11018 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11019 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11020 WMITLV_GET_STRUCT_TLVLEN(
11021 wmi_pdev_set_quiet_cmd_fixed_param));
11022 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11023 quiet_cmd->enabled = param->enabled;
11024 quiet_cmd->period = (param->period)*(param->intval);
11025 quiet_cmd->duration = param->duration;
11026 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011027 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11028 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011029
11030 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11031 WMI_PDEV_SET_QUIET_MODE_CMDID);
11032
11033 if (ret != 0) {
11034 WMI_LOGE("Sending set quiet cmd failed\n");
11035 wmi_buf_free(buf);
11036 }
11037
11038 return ret;
11039}
11040
11041/**
11042 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11043 * @wmi_handle: wmi handle
11044 * @param: pointer to set bwf param
11045 *
11046 * Return: 0 for success or error code
11047 */
11048static QDF_STATUS
11049send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11050 struct set_bwf_params *param)
11051{
11052 wmi_bwf_peer_info *peer_info;
11053 wmi_peer_bwf_request_fixed_param *cmd;
11054 wmi_buf_t buf;
11055 QDF_STATUS retval;
11056 int32_t len;
11057 uint8_t *buf_ptr;
11058 int i;
11059
11060 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11061 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11062 buf = wmi_buf_alloc(wmi_handle, len);
11063 if (!buf) {
11064 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11065 return QDF_STATUS_E_FAILURE;
11066 }
11067 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11068 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11069 WMITLV_SET_HDR(&cmd->tlv_header,
11070 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11071 WMITLV_GET_STRUCT_TLVLEN(
11072 wmi_peer_bwf_request_fixed_param));
11073 cmd->num_peers = param->num_peers;
11074
11075 buf_ptr += sizeof(*cmd);
11076 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11077 sizeof(wmi_bwf_peer_info) *
11078 cmd->num_peers);
11079 buf_ptr += WMI_TLV_HDR_SIZE;
11080 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11081
11082 for (i = 0; i < cmd->num_peers; i++) {
11083 WMITLV_SET_HDR(&peer_info->tlv_header,
11084 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11085 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11086 peer_info->bwf_guaranteed_bandwidth =
11087 param->peer_info[i].throughput;
11088 peer_info->bwf_max_airtime =
11089 param->peer_info[i].max_airtime;
11090 peer_info->bwf_peer_priority =
11091 param->peer_info[i].priority;
11092 qdf_mem_copy(&peer_info->peer_macaddr,
11093 &param->peer_info[i].peer_macaddr,
11094 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011095 peer_info->vdev_id =
11096 param->peer_info[i].vdev_id;
11097 peer_info->pdev_id =
11098 wmi_handle->ops->convert_pdev_id_host_to_target(
11099 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011100 peer_info++;
11101 }
11102
11103 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11104 WMI_PEER_BWF_REQUEST_CMDID);
11105
11106 if (retval != QDF_STATUS_SUCCESS) {
11107 WMI_LOGE("%s : WMI Failed\n", __func__);
11108 wmi_buf_free(buf);
11109 }
11110
11111 return retval;
11112}
11113
11114/**
11115 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11116 * @wmi_handle: wmi handle
11117 * @param: pointer to hold mcast update param
11118 *
11119 * Return: 0 for success or error code
11120 */
11121static QDF_STATUS
11122send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11123 struct mcast_group_update_params *param)
11124{
11125 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11126 wmi_buf_t buf;
11127 QDF_STATUS ret;
11128 int32_t len;
11129 int offset = 0;
11130 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11131
11132 len = sizeof(*cmd);
11133 buf = wmi_buf_alloc(wmi_handle, len);
11134 if (!buf) {
11135 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11136 return QDF_STATUS_E_FAILURE;
11137 }
11138 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11139 WMITLV_SET_HDR(&cmd->tlv_header,
11140 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11141 WMITLV_GET_STRUCT_TLVLEN(
11142 wmi_peer_mcast_group_cmd_fixed_param));
11143 /* confirm the buffer is 4-byte aligned */
11144 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11145 qdf_mem_zero(cmd, sizeof(*cmd));
11146
11147 cmd->vdev_id = param->vap_id;
11148 /* construct the message assuming our endianness matches the target */
11149 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11150 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11151 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11152 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11153 if (param->is_action_delete)
11154 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11155
11156 if (param->is_mcast_addr_len)
11157 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11158
11159 if (param->is_filter_mode_snoop)
11160 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11161
11162 /* unicast address spec only applies for non-wildcard cases */
11163 if (!param->wildcard && param->ucast_mac_addr) {
11164 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11165 &cmd->ucast_mac_addr);
11166 }
11167 if (param->mcast_ip_addr) {
11168 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11169 sizeof(cmd->mcast_ip_addr));
11170 offset = sizeof(cmd->mcast_ip_addr) -
11171 param->mcast_ip_addr_bytes;
11172 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11173 param->mcast_ip_addr,
11174 param->mcast_ip_addr_bytes);
11175 }
11176 if (!param->mask)
11177 param->mask = &dummymask[0];
11178
11179 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11180 param->mask,
11181 param->mcast_ip_addr_bytes);
11182
11183 if (param->srcs && param->nsrcs) {
11184 cmd->num_filter_addr = param->nsrcs;
11185 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11186 sizeof(cmd->filter_addr));
11187
11188 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11189 param->nsrcs * param->mcast_ip_addr_bytes);
11190 }
11191
11192 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11193 WMI_PEER_MCAST_GROUP_CMDID);
11194
11195 if (ret != QDF_STATUS_SUCCESS) {
11196 WMI_LOGE("%s : WMI Failed\n", __func__);
11197 wmi_buf_free(buf);
11198 }
11199
11200 return ret;
11201}
11202
11203/**
11204 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11205 * command to fw
11206 * @wmi_handle: wmi handle
11207 * @param: pointer to hold spectral config parameter
11208 *
11209 * Return: 0 for success or error code
11210 */
11211static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11212 struct vdev_spectral_configure_params *param)
11213{
11214 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11215 wmi_buf_t buf;
11216 QDF_STATUS ret;
11217 int32_t len;
11218
11219 len = sizeof(*cmd);
11220 buf = wmi_buf_alloc(wmi_handle, len);
11221 if (!buf) {
11222 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11223 return QDF_STATUS_E_FAILURE;
11224 }
11225
11226 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11227 WMITLV_SET_HDR(&cmd->tlv_header,
11228 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11229 WMITLV_GET_STRUCT_TLVLEN(
11230 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
11231
11232 cmd->vdev_id = param->vdev_id;
11233 cmd->spectral_scan_count = param->count;
11234 cmd->spectral_scan_period = param->period;
11235 cmd->spectral_scan_priority = param->spectral_pri;
11236 cmd->spectral_scan_fft_size = param->fft_size;
11237 cmd->spectral_scan_gc_ena = param->gc_enable;
11238 cmd->spectral_scan_restart_ena = param->restart_enable;
11239 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11240 cmd->spectral_scan_init_delay = param->init_delay;
11241 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11242 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11243 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11244 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11245 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11246 cmd->spectral_scan_pwr_format = param->pwr_format;
11247 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11248 cmd->spectral_scan_bin_scale = param->bin_scale;
11249 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11250 cmd->spectral_scan_chn_mask = param->chn_mask;
11251
11252 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11253 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11254
11255 if (ret != 0) {
11256 WMI_LOGE("Sending set quiet cmd failed\n");
11257 wmi_buf_free(buf);
11258 }
11259
11260 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11261 __func__);
11262
11263 WMI_LOGI("vdev_id = %u\n"
11264 "spectral_scan_count = %u\n"
11265 "spectral_scan_period = %u\n"
11266 "spectral_scan_priority = %u\n"
11267 "spectral_scan_fft_size = %u\n"
11268 "spectral_scan_gc_ena = %u\n"
11269 "spectral_scan_restart_ena = %u\n"
11270 "spectral_scan_noise_floor_ref = %u\n"
11271 "spectral_scan_init_delay = %u\n"
11272 "spectral_scan_nb_tone_thr = %u\n"
11273 "spectral_scan_str_bin_thr = %u\n"
11274 "spectral_scan_wb_rpt_mode = %u\n"
11275 "spectral_scan_rssi_rpt_mode = %u\n"
11276 "spectral_scan_rssi_thr = %u\n"
11277 "spectral_scan_pwr_format = %u\n"
11278 "spectral_scan_rpt_mode = %u\n"
11279 "spectral_scan_bin_scale = %u\n"
11280 "spectral_scan_dBm_adj = %u\n"
11281 "spectral_scan_chn_mask = %u\n",
11282 param->vdev_id,
11283 param->count,
11284 param->period,
11285 param->spectral_pri,
11286 param->fft_size,
11287 param->gc_enable,
11288 param->restart_enable,
11289 param->noise_floor_ref,
11290 param->init_delay,
11291 param->nb_tone_thr,
11292 param->str_bin_thr,
11293 param->wb_rpt_mode,
11294 param->rssi_rpt_mode,
11295 param->rssi_thr,
11296 param->pwr_format,
11297 param->rpt_mode,
11298 param->bin_scale,
11299 param->dBm_adj,
11300 param->chn_mask);
11301 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11302
11303 return ret;
11304}
11305
11306/**
11307 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11308 * command to fw
11309 * @wmi_handle: wmi handle
11310 * @param: pointer to hold spectral enable parameter
11311 *
11312 * Return: 0 for success or error code
11313 */
11314static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11315 struct vdev_spectral_enable_params *param)
11316{
11317 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11318 wmi_buf_t buf;
11319 QDF_STATUS ret;
11320 int32_t len;
11321
11322 len = sizeof(*cmd);
11323 buf = wmi_buf_alloc(wmi_handle, len);
11324 if (!buf) {
11325 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11326 return QDF_STATUS_E_FAILURE;
11327 }
11328
11329 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11330 WMITLV_SET_HDR(&cmd->tlv_header,
11331 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11332 WMITLV_GET_STRUCT_TLVLEN(
11333 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11334
11335 cmd->vdev_id = param->vdev_id;
11336
11337 if (param->active_valid) {
11338 cmd->trigger_cmd = param->active ? 1 : 2;
11339 /* 1: Trigger, 2: Clear Trigger */
11340 } else {
11341 cmd->trigger_cmd = 0; /* 0: Ignore */
11342 }
11343
11344 if (param->enabled_valid) {
11345 cmd->enable_cmd = param->enabled ? 1 : 2;
11346 /* 1: Enable 2: Disable */
11347 } else {
11348 cmd->enable_cmd = 0; /* 0: Ignore */
11349 }
11350
11351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11352 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11353
11354 if (ret != 0) {
11355 WMI_LOGE("Sending scan enable CMD failed\n");
11356 wmi_buf_free(buf);
11357 }
11358
11359 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11360
11361 WMI_LOGI("vdev_id = %u\n"
11362 "trigger_cmd = %u\n"
11363 "enable_cmd = %u\n",
11364 cmd->vdev_id,
11365 cmd->trigger_cmd,
11366 cmd->enable_cmd);
11367
11368 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11369
11370 return ret;
11371}
11372
11373/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011374 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11375 * @param wmi_handle : handle to WMI.
11376 * @param param : pointer to hold thermal mitigation param
11377 *
11378 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11379 */
11380static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11381 wmi_unified_t wmi_handle,
11382 struct thermal_mitigation_params *param)
11383{
11384 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11385 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11386 wmi_buf_t buf = NULL;
11387 uint8_t *buf_ptr = NULL;
11388 int error;
11389 int32_t len;
11390 int i;
11391
11392 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11393 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11394
11395 buf = wmi_buf_alloc(wmi_handle, len);
11396 if (!buf) {
11397 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11398 return QDF_STATUS_E_NOMEM;
11399 }
11400 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11401
11402 /* init fixed params */
11403 WMITLV_SET_HDR(tt_conf,
11404 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11405 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11406
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011407 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11408 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011409 tt_conf->enable = param->enable;
11410 tt_conf->dc = param->dc;
11411 tt_conf->dc_per_event = param->dc_per_event;
11412 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11413
11414 buf_ptr = (uint8_t *) ++tt_conf;
11415 /* init TLV params */
11416 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11417 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11418
11419 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11420 for (i = 0; i < THERMAL_LEVELS; i++) {
11421 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11422 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11423 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11424 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11425 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11426 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11427 lvl_conf->prio = param->levelconf[i].priority;
11428 lvl_conf++;
11429 }
11430
11431 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11432 WMI_THERM_THROT_SET_CONF_CMDID);
11433 if (QDF_IS_STATUS_ERROR(error)) {
11434 wmi_buf_free(buf);
11435 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11436 }
11437
11438 return error;
11439}
11440
11441/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011442 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11443 * @wmi_handle: wmi handle
11444 * @param: pointer to pdev_qvit_params
11445 *
11446 * Return: 0 for success or error code
11447 */
11448static QDF_STATUS
11449send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11450 struct pdev_qvit_params *param)
11451{
11452 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011453 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011454 uint8_t *cmd;
11455 static uint8_t msgref = 1;
11456 uint8_t segnumber = 0, seginfo, numsegments;
11457 uint16_t chunk_len, total_bytes;
11458 uint8_t *bufpos;
11459 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11460
11461 bufpos = param->utf_payload;
11462 total_bytes = param->len;
11463 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11464 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11465 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11466
11467 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11468 numsegments++;
11469
11470 while (param->len) {
11471 if (param->len > MAX_WMI_QVIT_LEN)
11472 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11473 else
11474 chunk_len = param->len;
11475
11476 buf = wmi_buf_alloc(wmi_handle,
11477 (chunk_len + sizeof(seghdrinfo) +
11478 WMI_TLV_HDR_SIZE));
11479 if (!buf) {
11480 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11481 return QDF_STATUS_E_NOMEM;
11482 }
11483
11484 cmd = (uint8_t *) wmi_buf_data(buf);
11485
11486 seghdrinfo.len = total_bytes;
11487 seghdrinfo.msgref = msgref;
11488 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11489 seghdrinfo.segmentInfo = seginfo;
11490
11491 segnumber++;
11492
11493 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11494 (chunk_len + sizeof(seghdrinfo)));
11495 cmd += WMI_TLV_HDR_SIZE;
11496 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11497 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11498
11499 ret = wmi_unified_cmd_send(wmi_handle, buf,
11500 (chunk_len + sizeof(seghdrinfo) +
11501 WMI_TLV_HDR_SIZE),
11502 WMI_PDEV_QVIT_CMDID);
11503
11504 if (ret != 0) {
11505 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11506 wmi_buf_free(buf);
11507 break;
11508 }
11509
11510 param->len -= chunk_len;
11511 bufpos += chunk_len;
11512 }
11513 msgref++;
11514
11515 return ret;
11516}
11517
11518/**
11519 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11520 * @wmi_handle: wmi handle
11521 * @param: pointer to wmm update param
11522 *
11523 * Return: 0 for success or error code
11524 */
11525static QDF_STATUS
11526send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11527 struct wmm_update_params *param)
11528{
11529 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11530 wmi_wmm_params *wmm_param;
11531 wmi_buf_t buf;
11532 QDF_STATUS ret;
11533 int32_t len;
11534 int ac = 0;
11535 struct wmi_host_wmeParams *wmep;
11536 uint8_t *buf_ptr;
11537
11538 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11539 buf = wmi_buf_alloc(wmi_handle, len);
11540 if (!buf) {
11541 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11542 return QDF_STATUS_E_FAILURE;
11543 }
11544
11545 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11546 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11547 WMITLV_SET_HDR(&cmd->tlv_header,
11548 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11549 WMITLV_GET_STRUCT_TLVLEN
11550 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11551
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011552 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011553
11554 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11555
11556 for (ac = 0; ac < WME_NUM_AC; ac++) {
11557 wmep = &param->wmep_array[ac];
11558 wmm_param = (wmi_wmm_params *)buf_ptr;
11559 WMITLV_SET_HDR(&wmm_param->tlv_header,
11560 WMITLV_TAG_STRUC_wmi_wmm_params,
11561 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11562 wmm_param->aifs = wmep->wmep_aifsn;
11563 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11564 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11565 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11566 wmm_param->acm = wmep->wmep_acm;
11567 wmm_param->no_ack = wmep->wmep_noackPolicy;
11568 buf_ptr += sizeof(wmi_wmm_params);
11569 }
11570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11571 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11572
11573 if (ret != 0) {
11574 WMI_LOGE("Sending WMM update CMD failed\n");
11575 wmi_buf_free(buf);
11576 }
11577
11578 return ret;
11579}
11580
Sathish Kumar80f4f382017-04-24 11:36:00 +053011581/**
11582 * send_coex_config_cmd_tlv() - send coex config command to fw
11583 * @wmi_handle: wmi handle
11584 * @param: pointer to coex config param
11585 *
11586 * Return: 0 for success or error code
11587 */
11588static QDF_STATUS
11589send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
11590 struct coex_config_params *param)
11591{
11592 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
11593 wmi_buf_t buf;
11594 QDF_STATUS ret;
11595 int32_t len;
11596
11597 len = sizeof(*cmd);
11598 buf = wmi_buf_alloc(wmi_handle, len);
11599 if (!buf) {
11600 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11601 return QDF_STATUS_E_FAILURE;
11602 }
11603
11604 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
11605 WMITLV_SET_HDR(&cmd->tlv_header,
11606 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
11607 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053011608 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053011609
11610 cmd->vdev_id = param->vdev_id;
11611 cmd->config_type = param->config_type;
11612 cmd->config_arg1 = param->config_arg1;
11613 cmd->config_arg2 = param->config_arg2;
11614 cmd->config_arg3 = param->config_arg3;
11615 cmd->config_arg4 = param->config_arg4;
11616 cmd->config_arg5 = param->config_arg5;
11617 cmd->config_arg6 = param->config_arg6;
11618
11619 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11620 WMI_COEX_CONFIG_CMDID);
11621
11622 if (ret != 0) {
11623 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
11624 wmi_buf_free(buf);
11625 }
11626
11627 return ret;
11628}
11629
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011630static
Govind Singh9ddd5162016-03-07 16:30:32 +053011631void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011632 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011633{
Govind Singhe7f2f342016-05-23 12:12:52 +053011634 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011635 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11636 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11637 resource_cfg->num_offload_reorder_buffs =
11638 tgt_res_cfg->num_offload_reorder_buffs;
11639 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11640 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11641 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11642 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11643 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11644 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11645 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11646 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11647 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11648 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11649 resource_cfg->scan_max_pending_req =
11650 tgt_res_cfg->scan_max_pending_req;
11651 resource_cfg->bmiss_offload_max_vdev =
11652 tgt_res_cfg->bmiss_offload_max_vdev;
11653 resource_cfg->roam_offload_max_vdev =
11654 tgt_res_cfg->roam_offload_max_vdev;
11655 resource_cfg->roam_offload_max_ap_profiles =
11656 tgt_res_cfg->roam_offload_max_ap_profiles;
11657 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11658 resource_cfg->num_mcast_table_elems =
11659 tgt_res_cfg->num_mcast_table_elems;
11660 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11661 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11662 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11663 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11664 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11665 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11666 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11667 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11668 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11669 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11670 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11671 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11672 resource_cfg->num_tdls_conn_table_entries =
11673 tgt_res_cfg->num_tdls_conn_table_entries;
11674 resource_cfg->beacon_tx_offload_max_vdev =
11675 tgt_res_cfg->beacon_tx_offload_max_vdev;
11676 resource_cfg->num_multicast_filter_entries =
11677 tgt_res_cfg->num_multicast_filter_entries;
11678 resource_cfg->num_wow_filters =
11679 tgt_res_cfg->num_wow_filters;
11680 resource_cfg->num_keep_alive_pattern =
11681 tgt_res_cfg->num_keep_alive_pattern;
11682 resource_cfg->keep_alive_pattern_size =
11683 tgt_res_cfg->keep_alive_pattern_size;
11684 resource_cfg->max_tdls_concurrent_sleep_sta =
11685 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11686 resource_cfg->max_tdls_concurrent_buffer_sta =
11687 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11688 resource_cfg->wmi_send_separate =
11689 tgt_res_cfg->wmi_send_separate;
11690 resource_cfg->num_ocb_vdevs =
11691 tgt_res_cfg->num_ocb_vdevs;
11692 resource_cfg->num_ocb_channels =
11693 tgt_res_cfg->num_ocb_channels;
11694 resource_cfg->num_ocb_schedules =
11695 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011696 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11697 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11698 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011699
11700 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
11701 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053011702}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011703#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011704/**
11705 * send_init_cmd_tlv() - wmi init command
11706 * @wmi_handle: pointer to wmi handle
11707 * @res_cfg: resource config
11708 * @num_mem_chunks: no of mem chunck
11709 * @mem_chunk: pointer to mem chunck structure
11710 *
11711 * This function sends IE information to firmware
11712 *
Govind Singhb53420c2016-03-09 14:32:57 +053011713 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011714 *
11715 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011716static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011717 wmi_resource_config *tgt_res_cfg,
11718 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11719 bool action)
11720{
11721 wmi_buf_t buf;
11722 wmi_init_cmd_fixed_param *cmd;
11723 wmi_abi_version my_vers;
11724 int num_whitelist;
11725 uint8_t *buf_ptr;
11726 wmi_resource_config *resource_cfg;
11727 wlan_host_memory_chunk *host_mem_chunks;
11728 uint32_t mem_chunk_len = 0;
11729 uint16_t idx;
11730 int len;
11731 int ret;
11732
11733 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11734 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11735 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011737 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11738 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011739 }
11740
11741 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11742 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11743 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11744
11745 host_mem_chunks = (wlan_host_memory_chunk *)
11746 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11747 + WMI_TLV_HDR_SIZE);
11748
11749 WMITLV_SET_HDR(&cmd->tlv_header,
11750 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11751 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11752
Govind Singhb53420c2016-03-09 14:32:57 +053011753 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011754 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11755 WMITLV_TAG_STRUC_wmi_resource_config,
11756 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11757
11758 for (idx = 0; idx < num_mem_chunks; ++idx) {
11759 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11760 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11761 WMITLV_GET_STRUCT_TLVLEN
11762 (wlan_host_memory_chunk));
11763 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11764 host_mem_chunks[idx].size = mem_chunks[idx].len;
11765 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011766 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011767 idx, host_mem_chunks[idx].size,
11768 host_mem_chunks[idx].ptr);
11769 }
11770 cmd->num_host_mem_chunks = num_mem_chunks;
11771 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11772 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11773 WMITLV_TAG_ARRAY_STRUC,
11774 (sizeof(wlan_host_memory_chunk) *
11775 num_mem_chunks));
11776
11777 num_whitelist = sizeof(version_whitelist) /
11778 sizeof(wmi_whitelist_version_info);
11779 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11780 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11781 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11782 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11783 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11784 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011785#ifdef CONFIG_MCL
11786 /* This needs to be enabled for WIN Lithium after removing dependency
11787 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011788 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11789 &my_vers,
11790 &wmi_handle->fw_abi_version,
11791 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011792#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011793 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011794 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11795 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11796 cmd->host_abi_vers.abi_version_ns_0,
11797 cmd->host_abi_vers.abi_version_ns_1,
11798 cmd->host_abi_vers.abi_version_ns_2,
11799 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011800#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011801 /* Save version sent from host -
11802 * Will be used to check ready event
11803 */
Govind Singhb53420c2016-03-09 14:32:57 +053011804 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011805 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011806#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011807 if (action) {
11808 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11809 WMI_INIT_CMDID);
11810 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011811 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011812 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011813 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011814 }
11815 } else {
11816 wmi_handle->saved_wmi_init_cmd.buf = buf;
11817 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11818 }
11819
Govind Singhb53420c2016-03-09 14:32:57 +053011820 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011821
11822}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011823#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011824/**
11825 * send_saved_init_cmd_tlv() - wmi init command
11826 * @wmi_handle: pointer to wmi handle
11827 *
11828 * This function sends IE information to firmware
11829 *
Govind Singhb53420c2016-03-09 14:32:57 +053011830 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011831 *
11832 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011833static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011834{
11835 int status;
11836
11837 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11838 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011839 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11840 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011841 }
11842 status = wmi_unified_cmd_send(wmi_handle,
11843 wmi_handle->saved_wmi_init_cmd.buf,
11844 wmi_handle->saved_wmi_init_cmd.buf_len,
11845 WMI_INIT_CMDID);
11846 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011847 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011848 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011849 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011850 }
11851 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11852 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11853
Govind Singhb53420c2016-03-09 14:32:57 +053011854 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011855}
11856
Sathish Kumarfd347372017-02-13 12:29:09 +053011857static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011858{
11859 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11860 wmi_service_ready_event_fixed_param *ev;
11861
11862
11863 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11864
11865 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11866 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011867 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011868
Govind Singh87542482016-06-08 19:40:11 +053011869#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011870 /*Save fw version from service ready message */
11871 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011872 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011873 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011874#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011875 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011876}
11877
11878/**
11879 * wmi_unified_save_fw_version_cmd() - save fw version
11880 * @wmi_handle: pointer to wmi handle
11881 * @res_cfg: resource config
11882 * @num_mem_chunks: no of mem chunck
11883 * @mem_chunk: pointer to mem chunck structure
11884 *
11885 * This function sends IE information to firmware
11886 *
Govind Singhb53420c2016-03-09 14:32:57 +053011887 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011888 *
11889 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011890static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011891 void *evt_buf)
11892{
11893 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11894 wmi_ready_event_fixed_param *ev = NULL;
11895
11896 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11897 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053011898#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011899 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
11900 &ev->fw_abi_vers)) {
11901 /*
11902 * Error: Our host version and the given firmware version
11903 * are incompatible.
11904 **/
Govind Singhb53420c2016-03-09 14:32:57 +053011905 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053011906 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
11907 __func__,
11908 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
11909 abi_version_0),
11910 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
11911 abi_version_0),
11912 wmi_handle->final_abi_vers.abi_version_ns_0,
11913 wmi_handle->final_abi_vers.abi_version_ns_1,
11914 wmi_handle->final_abi_vers.abi_version_ns_2,
11915 wmi_handle->final_abi_vers.abi_version_ns_3,
11916 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
11917 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
11918 ev->fw_abi_vers.abi_version_ns_0,
11919 ev->fw_abi_vers.abi_version_ns_1,
11920 ev->fw_abi_vers.abi_version_ns_2,
11921 ev->fw_abi_vers.abi_version_ns_3);
11922
Govind Singhb53420c2016-03-09 14:32:57 +053011923 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011924 }
Govind Singhb53420c2016-03-09 14:32:57 +053011925 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011926 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053011927 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011928 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011929#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011930
Govind Singhb53420c2016-03-09 14:32:57 +053011931 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011932}
Govind Singha4836fd2016-03-07 16:45:38 +053011933
11934/**
11935 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
11936 * @wmi_handle: wmi handle
11937 * @custom_addr: base mac address
11938 *
Govind Singhe7f2f342016-05-23 12:12:52 +053011939 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053011940 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011941static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011942 uint8_t *custom_addr)
11943{
11944 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
11945 wmi_buf_t buf;
11946 int err;
11947
11948 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11949 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011950 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053011951 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011952 }
11953
11954 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011955 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053011956
11957 WMITLV_SET_HDR(&cmd->tlv_header,
11958 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
11959 WMITLV_GET_STRUCT_TLVLEN
11960 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
11961 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011962 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11963 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053011964 err = wmi_unified_cmd_send(wmi_handle, buf,
11965 sizeof(*cmd),
11966 WMI_PDEV_SET_BASE_MACADDR_CMDID);
11967 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053011968 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053011969 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011970 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011971 }
11972
11973 return 0;
11974}
11975
11976/**
11977 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
11978 * @handle: wmi handle
11979 * @event: Event received from FW
11980 * @len: Length of the event
11981 *
11982 * Enables the low frequency events and disables the high frequency
11983 * events. Bit 17 indicates if the event if low/high frequency.
11984 * 1 - high frequency, 0 - low frequency
11985 *
11986 * Return: 0 on successfully enabling/disabling the events
11987 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011988static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011989 uint8_t *event,
11990 uint32_t len)
11991{
11992 uint32_t num_of_diag_events_logs;
11993 wmi_diag_event_log_config_fixed_param *cmd;
11994 wmi_buf_t buf;
11995 uint8_t *buf_ptr;
11996 uint32_t *cmd_args, *evt_args;
11997 uint32_t buf_len, i;
11998
11999 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12000 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12001
Govind Singhb53420c2016-03-09 14:32:57 +053012002 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012003
12004 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12005 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012006 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012007 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012008 }
12009 wmi_event = param_buf->fixed_param;
12010 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12011 evt_args = param_buf->diag_events_logs_list;
12012 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012013 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012014 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012015 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012016 }
12017
Govind Singhb53420c2016-03-09 14:32:57 +053012018 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012019 __func__, num_of_diag_events_logs);
12020
12021 /* Free any previous allocation */
12022 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012023 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012024
12025 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012026 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012027 sizeof(uint32_t));
12028 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012029 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012030 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012031 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012032 }
12033 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12034
12035 /* Prepare the send buffer */
12036 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12037 (num_of_diag_events_logs * sizeof(uint32_t));
12038
12039 buf = wmi_buf_alloc(wmi_handle, buf_len);
12040 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012041 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12042 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012043 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012044 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012045 }
12046
12047 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12048 buf_ptr = (uint8_t *) cmd;
12049
12050 WMITLV_SET_HDR(&cmd->tlv_header,
12051 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12052 WMITLV_GET_STRUCT_TLVLEN(
12053 wmi_diag_event_log_config_fixed_param));
12054
12055 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12056
12057 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12058
12059 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12060 (num_of_diag_events_logs * sizeof(uint32_t)));
12061
12062 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12063
12064 /* Populate the events */
12065 for (i = 0; i < num_of_diag_events_logs; i++) {
12066 /* Low freq (0) - Enable (1) the event
12067 * High freq (1) - Disable (0) the event
12068 */
12069 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12070 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12071 /* Set the event ID */
12072 WMI_DIAG_ID_SET(cmd_args[i],
12073 WMI_DIAG_ID_GET(evt_args[i]));
12074 /* Set the type */
12075 WMI_DIAG_TYPE_SET(cmd_args[i],
12076 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012077 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012078 wmi_handle->events_logs_list[i] = evt_args[i];
12079 }
12080
12081 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12082 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012083 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012084 __func__);
12085 wmi_buf_free(buf);
12086 /* Not clearing events_logs_list, though wmi cmd failed.
12087 * Host can still have this list
12088 */
Govind Singh67922e82016-04-01 16:48:57 +053012089 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012090 }
12091
12092 return 0;
12093}
12094
12095/**
12096 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12097 * @wmi_handle: wmi handle
12098 * @start_log: Start logging related parameters
12099 *
12100 * Send the command to the FW based on which specific logging of diag
12101 * event/log id can be started/stopped
12102 *
12103 * Return: None
12104 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012105static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012106 struct wmi_wifi_start_log *start_log)
12107{
12108 wmi_diag_event_log_config_fixed_param *cmd;
12109 wmi_buf_t buf;
12110 uint8_t *buf_ptr;
12111 uint32_t len, count, log_level, i;
12112 uint32_t *cmd_args;
12113 uint32_t total_len;
12114 count = 0;
12115
12116 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012117 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012118 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012119 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012120 }
12121 /* total_len stores the number of events where BITS 17 and 18 are set.
12122 * i.e., events of high frequency (17) and for extended debugging (18)
12123 */
12124 total_len = 0;
12125 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12126 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12127 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12128 total_len++;
12129 }
12130
12131 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12132 (total_len * sizeof(uint32_t));
12133
12134 buf = wmi_buf_alloc(wmi_handle, len);
12135 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012136 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012137 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012138 }
12139 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12140 buf_ptr = (uint8_t *) cmd;
12141
12142 WMITLV_SET_HDR(&cmd->tlv_header,
12143 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12144 WMITLV_GET_STRUCT_TLVLEN(
12145 wmi_diag_event_log_config_fixed_param));
12146
12147 cmd->num_of_diag_events_logs = total_len;
12148
12149 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12150
12151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12152 (total_len * sizeof(uint32_t)));
12153
12154 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12155
Govind Singh224a7312016-06-21 14:33:26 +053012156 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012157 log_level = 1;
12158 else
12159 log_level = 0;
12160
Govind Singhb53420c2016-03-09 14:32:57 +053012161 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012162 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12163 uint32_t val = wmi_handle->events_logs_list[i];
12164 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12165 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12166
12167 WMI_DIAG_ID_SET(cmd_args[count],
12168 WMI_DIAG_ID_GET(val));
12169 WMI_DIAG_TYPE_SET(cmd_args[count],
12170 WMI_DIAG_TYPE_GET(val));
12171 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12172 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012173 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012174 count++;
12175 }
12176 }
12177
12178 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12179 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012180 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012181 __func__);
12182 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012183 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012184 }
12185
Govind Singhb53420c2016-03-09 14:32:57 +053012186 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012187}
12188
12189/**
12190 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12191 * @wmi_handle: WMI handle
12192 *
12193 * This function is used to send the flush command to the FW,
12194 * that will flush the fw logs that are residue in the FW
12195 *
12196 * Return: None
12197 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012198static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012199{
12200 wmi_debug_mesg_flush_fixed_param *cmd;
12201 wmi_buf_t buf;
12202 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012203 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012204
12205 buf = wmi_buf_alloc(wmi_handle, len);
12206 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012207 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012208 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012209 }
12210
12211 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12212 WMITLV_SET_HDR(&cmd->tlv_header,
12213 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12214 WMITLV_GET_STRUCT_TLVLEN(
12215 wmi_debug_mesg_flush_fixed_param));
12216 cmd->reserved0 = 0;
12217
12218 ret = wmi_unified_cmd_send(wmi_handle,
12219 buf,
12220 len,
12221 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012222 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012223 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012224 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012225 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012226 }
Govind Singhb53420c2016-03-09 14:32:57 +053012227 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012228
Govind Singh67922e82016-04-01 16:48:57 +053012229 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012230}
12231
12232/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012233 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012234 * @wmi_handle: wmi handle
12235 * @msg: PCL structure containing the PCL and the number of channels
12236 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012237 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012238 * firmware. The DBS Manager is the consumer of this information in the WLAN
12239 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12240 * to migrate to a new channel without host driver involvement. An example of
12241 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12242 * manage the channel selection without firmware involvement.
12243 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012244 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12245 * channel list. The weights corresponds to the channels sent in
12246 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12247 * weightage compared to the non PCL channels.
12248 *
Govind Singha4836fd2016-03-07 16:45:38 +053012249 * Return: Success if the cmd is sent successfully to the firmware
12250 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012251static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012252 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012253{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012254 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012255 wmi_buf_t buf;
12256 uint8_t *buf_ptr;
12257 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012258 uint32_t chan_len;
12259
12260 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012261
12262 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012263 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012264
12265 buf = wmi_buf_alloc(wmi_handle, len);
12266 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012267 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12268 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012269 }
12270
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012271 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012272 buf_ptr = (uint8_t *) cmd;
12273 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012274 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12275 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012276
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012277 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12278 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012279 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053012280 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012281
12282 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012283 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012284 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012285 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012286 for (i = 0; i < chan_len ; i++) {
12287 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053012288 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012289 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012290 }
12291 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012292 WMI_PDEV_SET_PCL_CMDID)) {
12293 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012294 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012295 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012296 }
Govind Singhb53420c2016-03-09 14:32:57 +053012297 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012298}
12299
12300/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012301 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012302 * @wmi_handle: wmi handle
12303 * @msg: Structure containing the following parameters
12304 *
12305 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12306 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12307 *
12308 * Provides notification to the WLAN firmware that host driver is requesting a
12309 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12310 * configurations that include the Dual Band Simultaneous (DBS) feature.
12311 *
12312 * Return: Success if the cmd is sent successfully to the firmware
12313 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012314static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012315 uint32_t hw_mode_index)
12316{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012317 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012318 wmi_buf_t buf;
12319 uint32_t len;
12320
12321 len = sizeof(*cmd);
12322
12323 buf = wmi_buf_alloc(wmi_handle, len);
12324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012325 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12326 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012327 }
12328
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012329 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012330 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012331 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12332 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12333
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012334 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12335 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012336 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012337 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012338
12339 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012340 WMI_PDEV_SET_HW_MODE_CMDID)) {
12341 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012342 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012343 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012344 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012345 }
12346
Govind Singhb53420c2016-03-09 14:32:57 +053012347 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012348}
12349
12350/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012351 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012352 * @wmi_handle: wmi handle
12353 * @msg: Dual MAC config parameters
12354 *
12355 * Configures WLAN firmware with the dual MAC features
12356 *
Govind Singhb53420c2016-03-09 14:32:57 +053012357 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012358 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012359static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012360QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012361 struct wmi_dual_mac_config *msg)
12362{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012363 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012364 wmi_buf_t buf;
12365 uint32_t len;
12366
12367 len = sizeof(*cmd);
12368
12369 buf = wmi_buf_alloc(wmi_handle, len);
12370 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012371 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12372 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012373 }
12374
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012375 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012376 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012377 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012378 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012379 wmi_pdev_set_mac_config_cmd_fixed_param));
12380
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012381 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12382 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012383 cmd->concurrent_scan_config_bits = msg->scan_config;
12384 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012385 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012386 __func__, msg->scan_config, msg->fw_mode_config);
12387
12388 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012389 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12390 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012391 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012392 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012393 }
Govind Singhb53420c2016-03-09 14:32:57 +053012394 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012395}
12396
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012397#ifdef BIG_ENDIAN_HOST
12398/**
12399* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12400* @param data_len - data length
12401* @param data - pointer to data
12402*
12403* Return: QDF_STATUS - success or error status
12404*/
12405static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12406 struct fips_params *param)
12407{
12408 unsigned char *key_unaligned, *data_unaligned;
12409 int c;
12410 u_int8_t *key_aligned = NULL;
12411 u_int8_t *data_aligned = NULL;
12412
12413 /* Assigning unaligned space to copy the key */
12414 key_unaligned = qdf_mem_malloc(
12415 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12416 data_unaligned = qdf_mem_malloc(
12417 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12418
12419 /* Checking if kmalloc is succesful to allocate space */
12420 if (key_unaligned == NULL)
12421 return QDF_STATUS_SUCCESS;
12422 /* Checking if space is aligned */
12423 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12424 /* align to 4 */
12425 key_aligned =
12426 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12427 FIPS_ALIGN);
12428 } else {
12429 key_aligned = (u_int8_t *)key_unaligned;
12430 }
12431
12432 /* memset and copy content from key to key aligned */
12433 OS_MEMSET(key_aligned, 0, param->key_len);
12434 OS_MEMCPY(key_aligned, param->key, param->key_len);
12435
12436 /* print a hexdump for host debug */
12437 print_hex_dump(KERN_DEBUG,
12438 "\t Aligned and Copied Key:@@@@ ",
12439 DUMP_PREFIX_NONE,
12440 16, 1, key_aligned, param->key_len, true);
12441
12442 /* Checking if kmalloc is succesful to allocate space */
12443 if (data_unaligned == NULL)
12444 return QDF_STATUS_SUCCESS;
12445 /* Checking of space is aligned */
12446 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12447 /* align to 4 */
12448 data_aligned =
12449 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12450 FIPS_ALIGN);
12451 } else {
12452 data_aligned = (u_int8_t *)data_unaligned;
12453 }
12454
12455 /* memset and copy content from data to data aligned */
12456 OS_MEMSET(data_aligned, 0, param->data_len);
12457 OS_MEMCPY(data_aligned, param->data, param->data_len);
12458
12459 /* print a hexdump for host debug */
12460 print_hex_dump(KERN_DEBUG,
12461 "\t Properly Aligned and Copied Data:@@@@ ",
12462 DUMP_PREFIX_NONE,
12463 16, 1, data_aligned, param->data_len, true);
12464
12465 /* converting to little Endian both key_aligned and
12466 * data_aligned*/
12467 for (c = 0; c < param->key_len/4; c++) {
12468 *((u_int32_t *)key_aligned+c) =
12469 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12470 }
12471 for (c = 0; c < param->data_len/4; c++) {
12472 *((u_int32_t *)data_aligned+c) =
12473 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12474 }
12475
12476 /* update endian data to key and data vectors */
12477 OS_MEMCPY(param->key, key_aligned, param->key_len);
12478 OS_MEMCPY(param->data, data_aligned, param->data_len);
12479
12480 /* clean up allocated spaces */
12481 qdf_mem_free(key_unaligned);
12482 key_unaligned = NULL;
12483 key_aligned = NULL;
12484
12485 qdf_mem_free(data_unaligned);
12486 data_unaligned = NULL;
12487 data_aligned = NULL;
12488
12489 return QDF_STATUS_SUCCESS;
12490}
12491#else
12492/**
12493* fips_align_data_be() - DUMMY for LE platform
12494*
12495* Return: QDF_STATUS - success
12496*/
12497static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12498 struct fips_params *param)
12499{
12500 return QDF_STATUS_SUCCESS;
12501}
12502#endif
12503
12504
12505/**
12506 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12507 * @wmi_handle: wmi handle
12508 * @param: pointer to hold pdev fips param
12509 *
12510 * Return: 0 for success or error code
12511 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012512static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012513send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12514 struct fips_params *param)
12515{
12516 wmi_pdev_fips_cmd_fixed_param *cmd;
12517 wmi_buf_t buf;
12518 uint8_t *buf_ptr;
12519 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12520 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12521
12522 /* Length TLV placeholder for array of bytes */
12523 len += WMI_TLV_HDR_SIZE;
12524 if (param->data_len)
12525 len += (param->data_len*sizeof(uint8_t));
12526
12527 /*
12528 * Data length must be multiples of 16 bytes - checked against 0xF -
12529 * and must be less than WMI_SVC_MSG_SIZE - static size of
12530 * wmi_pdev_fips_cmd structure
12531 */
12532
12533 /* do sanity on the input */
12534 if (!(((param->data_len & 0xF) == 0) &&
12535 ((param->data_len > 0) &&
12536 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12537 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12538 return QDF_STATUS_E_INVAL;
12539 }
12540
12541 buf = wmi_buf_alloc(wmi_handle, len);
12542 if (!buf) {
12543 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12544 return QDF_STATUS_E_FAILURE;
12545 }
12546
12547 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12548 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12549 WMITLV_SET_HDR(&cmd->tlv_header,
12550 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12551 WMITLV_GET_STRUCT_TLVLEN
12552 (wmi_pdev_fips_cmd_fixed_param));
12553
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012554 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12555 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012556 if (param->key != NULL && param->data != NULL) {
12557 cmd->key_len = param->key_len;
12558 cmd->data_len = param->data_len;
12559 cmd->fips_cmd = !!(param->op);
12560
12561 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12562 return QDF_STATUS_E_FAILURE;
12563
12564 qdf_mem_copy(cmd->key, param->key, param->key_len);
12565
12566 if (param->mode == FIPS_ENGINE_AES_CTR ||
12567 param->mode == FIPS_ENGINE_AES_MIC) {
12568 cmd->mode = param->mode;
12569 } else {
12570 cmd->mode = FIPS_ENGINE_AES_CTR;
12571 }
12572 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12573 cmd->key_len, cmd->data_len);
12574
12575 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12576 cmd->key, cmd->key_len, true);
12577 buf_ptr += sizeof(*cmd);
12578
12579 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12580
12581 buf_ptr += WMI_TLV_HDR_SIZE;
12582 if (param->data_len)
12583 qdf_mem_copy(buf_ptr,
12584 (uint8_t *) param->data, param->data_len);
12585
12586 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12587 16, 1, buf_ptr, cmd->data_len, true);
12588
12589 buf_ptr += param->data_len;
12590
12591 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12592 WMI_PDEV_FIPS_CMDID);
12593 qdf_print("%s return value %d\n", __func__, retval);
12594 } else {
12595 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12596 wmi_buf_free(buf);
12597 retval = -QDF_STATUS_E_BADMSG;
12598 }
12599
12600 return retval;
12601}
12602
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012603#ifdef WLAN_PMO_ENABLE
12604/**
12605 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12606 * @wmi_handle: wmi handle
12607 * @vdev_id: vdev id
12608 * @bitmap: Event bitmap
12609 * @enable: enable/disable
12610 *
12611 * Return: CDF status
12612 */
12613static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12614 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012615 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012616 bool enable)
12617{
12618 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12619 uint16_t len;
12620 wmi_buf_t buf;
12621 int ret;
12622
12623 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12624 buf = wmi_buf_alloc(wmi_handle, len);
12625 if (!buf) {
12626 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12627 return QDF_STATUS_E_NOMEM;
12628 }
12629 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12630 WMITLV_SET_HDR(&cmd->tlv_header,
12631 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12632 WMITLV_GET_STRUCT_TLVLEN
12633 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12634 cmd->vdev_id = vdev_id;
12635 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012636 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
12637 WMI_WOW_MAX_EVENT_BM_LEN);
12638
12639 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
12640 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
12641 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012642
12643 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12644 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12645 if (ret) {
12646 WMI_LOGE("Failed to config wow wakeup event");
12647 wmi_buf_free(buf);
12648 return QDF_STATUS_E_FAILURE;
12649 }
12650
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012651 return QDF_STATUS_SUCCESS;
12652}
12653
12654/**
12655 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12656 * @wmi_handle: wmi handle
12657 * @vdev_id: vdev id
12658 * @ptrn_id: pattern id
12659 * @ptrn: pattern
12660 * @ptrn_len: pattern length
12661 * @ptrn_offset: pattern offset
12662 * @mask: mask
12663 * @mask_len: mask length
12664 * @user: true for user configured pattern and false for default pattern
12665 * @default_patterns: default patterns
12666 *
12667 * Return: CDF status
12668 */
12669static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12670 uint8_t vdev_id, uint8_t ptrn_id,
12671 const uint8_t *ptrn, uint8_t ptrn_len,
12672 uint8_t ptrn_offset, const uint8_t *mask,
12673 uint8_t mask_len, bool user,
12674 uint8_t default_patterns)
12675{
12676 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12677 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12678 wmi_buf_t buf;
12679 uint8_t *buf_ptr;
12680 int32_t len;
12681 int ret;
12682
12683 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12684 WMI_TLV_HDR_SIZE +
12685 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12686 WMI_TLV_HDR_SIZE +
12687 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12688 WMI_TLV_HDR_SIZE +
12689 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12690 WMI_TLV_HDR_SIZE +
12691 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12692 WMI_TLV_HDR_SIZE +
12693 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12694
12695 buf = wmi_buf_alloc(wmi_handle, len);
12696 if (!buf) {
12697 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12698 return QDF_STATUS_E_NOMEM;
12699 }
12700
12701 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12702 buf_ptr = (uint8_t *) cmd;
12703
12704 WMITLV_SET_HDR(&cmd->tlv_header,
12705 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12706 WMITLV_GET_STRUCT_TLVLEN
12707 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12708 cmd->vdev_id = vdev_id;
12709 cmd->pattern_id = ptrn_id;
12710
12711 cmd->pattern_type = WOW_BITMAP_PATTERN;
12712 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12713
12714 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12715 sizeof(WOW_BITMAP_PATTERN_T));
12716 buf_ptr += WMI_TLV_HDR_SIZE;
12717 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12718
12719 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12720 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12721 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12722
12723 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12724 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12725
12726 bitmap_pattern->pattern_offset = ptrn_offset;
12727 bitmap_pattern->pattern_len = ptrn_len;
12728
12729 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12730 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12731
12732 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12733 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12734
12735 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12736 bitmap_pattern->pattern_id = ptrn_id;
12737
12738 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12739 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12740 bitmap_pattern->pattern_offset, user);
12741 WMI_LOGI("Pattern : ");
12742 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12743 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12744
12745 WMI_LOGI("Mask : ");
12746 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12747 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12748
12749 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12750
12751 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12752 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12753 buf_ptr += WMI_TLV_HDR_SIZE;
12754
12755 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12757 buf_ptr += WMI_TLV_HDR_SIZE;
12758
12759 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12760 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12761 buf_ptr += WMI_TLV_HDR_SIZE;
12762
12763 /* Fill TLV for pattern_info_timeout but no data. */
12764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12765 buf_ptr += WMI_TLV_HDR_SIZE;
12766
12767 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12768 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12769 buf_ptr += WMI_TLV_HDR_SIZE;
12770 *(A_UINT32 *) buf_ptr = 0;
12771
12772 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12773 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12774 if (ret) {
12775 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12776 wmi_buf_free(buf);
12777 return QDF_STATUS_E_FAILURE;
12778 }
12779
12780 return QDF_STATUS_SUCCESS;
12781}
12782
Govind Singha4836fd2016-03-07 16:45:38 +053012783/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012784 * fill_arp_offload_params_tlv() - Fill ARP offload data
12785 * @wmi_handle: wmi handle
12786 * @offload_req: offload request
12787 * @buf_ptr: buffer pointer
12788 *
12789 * To fill ARP offload data to firmware
12790 * when target goes to wow mode.
12791 *
12792 * Return: None
12793 */
12794static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012795 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012796{
12797
12798 int i;
12799 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012800 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012801
12802 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12803 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12804 *buf_ptr += WMI_TLV_HDR_SIZE;
12805 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12806 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12807 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12808 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12809 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12810
12811 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012812 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012813 /* Copy the target ip addr and flags */
12814 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12815 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012816 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012817 WMI_IPV4_ADDR_LEN);
12818 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012819 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012820 }
12821 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12822 }
12823}
12824
12825#ifdef WLAN_NS_OFFLOAD
12826/**
12827 * fill_ns_offload_params_tlv() - Fill NS offload data
12828 * @wmi|_handle: wmi handle
12829 * @offload_req: offload request
12830 * @buf_ptr: buffer pointer
12831 *
12832 * To fill NS offload data to firmware
12833 * when target goes to wow mode.
12834 *
12835 * Return: None
12836 */
12837static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012838 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012839{
12840
12841 int i;
12842 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012843
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012844 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12845 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12846 *buf_ptr += WMI_TLV_HDR_SIZE;
12847 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12848 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12849 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12850 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12851 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12852
12853 /*
12854 * Fill data only for NS offload in the first ARP tuple for LA
12855 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012856 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012857 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12858 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012859 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012860 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012861 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012862 sizeof(WMI_IPV6_ADDR));
12863 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012864 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012865 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012866 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012867 ns_tuple->flags |=
12868 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12869 }
12870 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012871 i, &ns_req->self_ipv6_addr[i],
12872 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012873
12874 /* target MAC is optional, check if it is valid,
12875 * if this is not valid, the target will use the known
12876 * local MAC address rather than the tuple
12877 */
12878 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012879 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012880 &ns_tuple->target_mac);
12881 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12882 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12883 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12884 }
12885 }
12886 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12887 }
12888}
12889
12890
12891/**
12892 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
12893 * @wmi: wmi handle
12894 * @offload_req: offload request
12895 * @buf_ptr: buffer pointer
12896 *
12897 * To fill extended NS offload extended data to firmware
12898 * when target goes to wow mode.
12899 *
12900 * Return: None
12901 */
12902static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012903 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012904{
12905 int i;
12906 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
12907 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012908
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012909 count = ns_req->num_ns_offload_count;
12910 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012911 WMI_MAX_NS_OFFLOADS;
12912
12913 /* Populate extended NS offload tuples */
12914 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12915 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12916 *buf_ptr += WMI_TLV_HDR_SIZE;
12917 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
12918 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12919 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12920 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12921 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
12922
12923 /*
12924 * Fill data only for NS offload in the first ARP tuple for LA
12925 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012926 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012927 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12928 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012929 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012930 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012931 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012932 sizeof(WMI_IPV6_ADDR));
12933 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012934 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012935 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012936 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012937 ns_tuple->flags |=
12938 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12939 }
12940 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012941 i, &ns_req->self_ipv6_addr[i],
12942 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012943
12944 /* target MAC is optional, check if it is valid,
12945 * if this is not valid, the target will use the
12946 * known local MAC address rather than the tuple
12947 */
12948 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012949 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012950 &ns_tuple->target_mac);
12951 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12952 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12953 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12954 }
12955 }
12956 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12957 }
12958}
12959#else
12960static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012961 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012962{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012963}
12964
12965static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012966 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012967{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012968}
12969#endif
12970
12971/**
Govind Singha4836fd2016-03-07 16:45:38 +053012972 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
12973 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012974 * @arp_offload_req: arp offload request
12975 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053012976 * @arp_only: flag
12977 *
12978 * To configure ARP NS off load data to firmware
12979 * when target goes to wow mode.
12980 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012981 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053012982 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012983static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012984 struct pmo_arp_offload_params *arp_offload_req,
12985 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053012986 uint8_t vdev_id)
12987{
Govind Singha4836fd2016-03-07 16:45:38 +053012988 int32_t res;
12989 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012990 A_UINT8 *buf_ptr;
12991 wmi_buf_t buf;
12992 int32_t len;
12993 uint32_t count = 0, num_ns_ext_tuples = 0;
12994
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012995 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053012996
Govind Singha4836fd2016-03-07 16:45:38 +053012997 /*
12998 * TLV place holder size for array of NS tuples
12999 * TLV place holder size for array of ARP tuples
13000 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013001 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13002 WMI_TLV_HDR_SIZE +
13003 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13004 WMI_TLV_HDR_SIZE +
13005 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013006
13007 /*
13008 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13009 * extra length for extended NS offload tuples which follows ARP offload
13010 * tuples. Host needs to fill this structure in following format:
13011 * 2 NS ofload tuples
13012 * 2 ARP offload tuples
13013 * N numbers of extended NS offload tuples if HDD has given more than
13014 * 2 NS offload addresses
13015 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013016 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013017 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013018 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13019 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013020 }
13021
13022 buf = wmi_buf_alloc(wmi_handle, len);
13023 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013024 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013025 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013026 }
13027
13028 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13029 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13030 WMITLV_SET_HDR(&cmd->tlv_header,
13031 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13032 WMITLV_GET_STRUCT_TLVLEN
13033 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13034 cmd->flags = 0;
13035 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013036 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013037
Govind Singhb53420c2016-03-09 14:32:57 +053013038 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013039
Govind Singha4836fd2016-03-07 16:45:38 +053013040 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013041 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13042 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13043 if (num_ns_ext_tuples)
13044 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013045
13046 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13047 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13048 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013049 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013050 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013051 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013052 }
13053
Govind Singhb53420c2016-03-09 14:32:57 +053013054 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013055}
13056
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013057/**
13058 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13059 * @wmi_handle: wmi handle
13060 * @vdev_id: vdev id
13061 * @action: true for enable else false
13062 *
13063 * To enable enhance multicast offload to firmware
13064 * when target goes to wow mode.
13065 *
13066 * Return: QDF Status
13067 */
13068
13069static
13070QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13071 wmi_unified_t wmi_handle,
13072 uint8_t vdev_id, bool action)
13073{
13074 QDF_STATUS status;
13075 wmi_buf_t buf;
13076 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13077
13078 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13079 if (!buf) {
13080 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13081 return QDF_STATUS_E_NOMEM;
13082 }
13083
13084 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13085 wmi_buf_data(buf);
13086
13087 WMITLV_SET_HDR(&cmd->tlv_header,
13088 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13089 WMITLV_GET_STRUCT_TLVLEN(
13090 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13091
13092 cmd->vdev_id = vdev_id;
13093 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13094 ENHANCED_MCAST_FILTER_ENABLED);
13095 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13096 __func__, action, vdev_id);
13097 status = wmi_unified_cmd_send(wmi_handle, buf,
13098 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13099 if (status != QDF_STATUS_SUCCESS) {
13100 qdf_nbuf_free(buf);
13101 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13102 __func__);
13103 }
13104
13105 return status;
13106}
13107
13108/**
13109 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13110 * @wmi_handle: wmi handle
13111 * @param evt_buf: pointer to event buffer
13112 * @param hdr: Pointer to hold header
13113 * @param bufp: Pointer to hold pointer to rx param buffer
13114 *
13115 * Return: QDF_STATUS_SUCCESS for success or error code
13116 */
13117static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13118 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13119{
13120 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13121 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13122
13123 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13124 if (!param_buf) {
13125 WMI_LOGE("gtk param_buf is NULL");
13126 return QDF_STATUS_E_INVAL;
13127 }
13128
13129 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13130 WMI_LOGE("Invalid length for GTK status");
13131 return QDF_STATUS_E_INVAL;
13132 }
13133
13134 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13135 param_buf->fixed_param;
13136 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13137 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13138 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13139 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13140 &fixed_param->replay_counter,
13141 GTK_REPLAY_COUNTER_BYTES);
13142
13143 return QDF_STATUS_SUCCESS;
13144
13145}
13146
13147#ifdef FEATURE_WLAN_RA_FILTERING
13148/**
13149 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13150 * @wmi_handle: wmi handle
13151 * @vdev_id: vdev id
13152 *
13153 * Return: CDF status
13154 */
13155static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13156 uint8_t vdev_id, uint8_t default_pattern,
13157 uint16_t rate_limit_interval)
13158{
13159
13160 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13161 wmi_buf_t buf;
13162 uint8_t *buf_ptr;
13163 int32_t len;
13164 int ret;
13165
13166 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13167 WMI_TLV_HDR_SIZE +
13168 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13169 WMI_TLV_HDR_SIZE +
13170 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13171 WMI_TLV_HDR_SIZE +
13172 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13173 WMI_TLV_HDR_SIZE +
13174 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13175 WMI_TLV_HDR_SIZE +
13176 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13177
13178 buf = wmi_buf_alloc(wmi_handle, len);
13179 if (!buf) {
13180 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13181 return QDF_STATUS_E_NOMEM;
13182 }
13183
13184 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13185 buf_ptr = (uint8_t *) cmd;
13186
13187 WMITLV_SET_HDR(&cmd->tlv_header,
13188 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13189 WMITLV_GET_STRUCT_TLVLEN
13190 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13191 cmd->vdev_id = vdev_id;
13192 cmd->pattern_id = default_pattern,
13193 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13194 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13195
13196 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13197 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13198 buf_ptr += WMI_TLV_HDR_SIZE;
13199
13200 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13202 buf_ptr += WMI_TLV_HDR_SIZE;
13203
13204 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13205 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13206 buf_ptr += WMI_TLV_HDR_SIZE;
13207
13208 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13210 buf_ptr += WMI_TLV_HDR_SIZE;
13211
13212 /* Fill TLV for pattern_info_timeout but no data. */
13213 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13214 buf_ptr += WMI_TLV_HDR_SIZE;
13215
13216 /* Fill TLV for ra_ratelimit_interval. */
13217 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13218 buf_ptr += WMI_TLV_HDR_SIZE;
13219
13220 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13221
13222 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13223 rate_limit_interval, vdev_id);
13224
13225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13226 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13227 if (ret) {
13228 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13229 wmi_buf_free(buf);
13230 return QDF_STATUS_E_FAILURE;
13231 }
13232
13233 return QDF_STATUS_SUCCESS;
13234
13235}
13236#endif /* FEATURE_WLAN_RA_FILTERING */
13237
13238/**
13239 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13240 * @wmi_handle: wmi handle
13241 * @vdev_id: vdev id
13242 * @multicastAddr: mcast address
13243 * @clearList: clear list flag
13244 *
13245 * Return: QDF_STATUS_SUCCESS for success or error code
13246 */
13247static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13248 uint8_t vdev_id,
13249 struct qdf_mac_addr multicast_addr,
13250 bool clearList)
13251{
13252 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13253 wmi_buf_t buf;
13254 int err;
13255
13256 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13257 if (!buf) {
13258 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13259 return QDF_STATUS_E_NOMEM;
13260 }
13261
13262 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13263 qdf_mem_zero(cmd, sizeof(*cmd));
13264
13265 WMITLV_SET_HDR(&cmd->tlv_header,
13266 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13267 WMITLV_GET_STRUCT_TLVLEN
13268 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13269 cmd->action =
13270 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13271 cmd->vdev_id = vdev_id;
13272 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13273
13274 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13275 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13276
13277 err = wmi_unified_cmd_send(wmi_handle, buf,
13278 sizeof(*cmd),
13279 WMI_SET_MCASTBCAST_FILTER_CMDID);
13280 if (err) {
13281 WMI_LOGE("Failed to send set_param cmd");
13282 wmi_buf_free(buf);
13283 return QDF_STATUS_E_FAILURE;
13284 }
13285
13286 return QDF_STATUS_SUCCESS;
13287}
13288
13289/**
13290 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13291 * @wmi_handle: wmi handle
13292 * @vdev_id: vdev id
13293 * @params: GTK offload parameters
13294 *
13295 * Return: CDF status
13296 */
13297static
13298QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13299 struct pmo_gtk_req *params,
13300 bool enable_offload,
13301 uint32_t gtk_offload_opcode)
13302{
13303 int len;
13304 wmi_buf_t buf;
13305 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13306 QDF_STATUS status = QDF_STATUS_SUCCESS;
13307
13308 WMI_LOGD("%s Enter", __func__);
13309
13310 len = sizeof(*cmd);
13311
13312 /* alloc wmi buffer */
13313 buf = wmi_buf_alloc(wmi_handle, len);
13314 if (!buf) {
13315 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13316 status = QDF_STATUS_E_NOMEM;
13317 goto out;
13318 }
13319
13320 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13321 WMITLV_SET_HDR(&cmd->tlv_header,
13322 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13323 WMITLV_GET_STRUCT_TLVLEN
13324 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13325
13326 cmd->vdev_id = vdev_id;
13327
13328 /* Request target to enable GTK offload */
13329 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13330 cmd->flags = gtk_offload_opcode;
13331
13332 /* Copy the keys and replay counter */
13333 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13334 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13335 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13336 GTK_REPLAY_COUNTER_BYTES);
13337 } else {
13338 cmd->flags = gtk_offload_opcode;
13339 }
13340
13341 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13342
13343 /* send the wmi command */
13344 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13345 WMI_GTK_OFFLOAD_CMDID)) {
13346 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13347 wmi_buf_free(buf);
13348 status = QDF_STATUS_E_FAILURE;
13349 }
13350
13351out:
13352 WMI_LOGD("%s Exit", __func__);
13353 return status;
13354}
13355
13356/**
13357 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13358 * @wmi_handle: wmi handle
13359 * @params: GTK offload params
13360 *
13361 * Return: CDF status
13362 */
13363static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13364 wmi_unified_t wmi_handle,
13365 uint8_t vdev_id,
13366 uint64_t offload_req_opcode)
13367{
13368 int len;
13369 wmi_buf_t buf;
13370 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13371 QDF_STATUS status = QDF_STATUS_SUCCESS;
13372
13373 len = sizeof(*cmd);
13374
13375 /* alloc wmi buffer */
13376 buf = wmi_buf_alloc(wmi_handle, len);
13377 if (!buf) {
13378 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13379 status = QDF_STATUS_E_NOMEM;
13380 goto out;
13381 }
13382
13383 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13384 WMITLV_SET_HDR(&cmd->tlv_header,
13385 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13386 WMITLV_GET_STRUCT_TLVLEN
13387 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13388
13389 /* Request for GTK offload status */
13390 cmd->flags = offload_req_opcode;
13391 cmd->vdev_id = vdev_id;
13392
13393 /* send the wmi command */
13394 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13395 WMI_GTK_OFFLOAD_CMDID)) {
13396 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13397 wmi_buf_free(buf);
13398 status = QDF_STATUS_E_FAILURE;
13399 }
13400
13401out:
13402 return status;
13403}
13404
13405/**
13406 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13407 * @wmi_handle: wmi handler
13408 * @action_params: pointer to action_params
13409 *
13410 * Return: 0 for success, otherwise appropriate error code
13411 */
13412static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13413 struct pmo_action_wakeup_set_params *action_params)
13414{
13415 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13416 wmi_buf_t buf;
13417 int i;
13418 int32_t err;
13419
13420 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13421 if (!buf) {
13422 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13423 return QDF_STATUS_E_NOMEM;
13424 }
13425 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13426 WMITLV_SET_HDR(&cmd->tlv_header,
13427 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13428 WMITLV_GET_STRUCT_TLVLEN(
13429 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13430
13431 cmd->vdev_id = action_params->vdev_id;
13432 cmd->operation = action_params->operation;
13433
13434 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13435 cmd->action_category_map[i] =
13436 action_params->action_category_map[i];
13437
13438 err = wmi_unified_cmd_send(wmi_handle, buf,
13439 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13440 if (err) {
13441 WMI_LOGE("Failed to send ap_ps_egap cmd");
13442 wmi_buf_free(buf);
13443 return QDF_STATUS_E_FAILURE;
13444 }
13445
13446 return QDF_STATUS_SUCCESS;
13447}
13448
13449#ifdef FEATURE_WLAN_LPHB
13450
13451/**
13452 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13453 * @wmi_handle: wmi handle
13454 * @lphb_conf_req: configuration info
13455 *
13456 * Return: CDF status
13457 */
13458static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13459 wmi_hb_set_enable_cmd_fixed_param *params)
13460{
13461 QDF_STATUS status;
13462 wmi_buf_t buf = NULL;
13463 uint8_t *buf_ptr;
13464 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13465 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13466
13467
13468 buf = wmi_buf_alloc(wmi_handle, len);
13469 if (!buf) {
13470 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13471 return QDF_STATUS_E_NOMEM;
13472 }
13473
13474 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13475 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13476 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13477 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13478 WMITLV_GET_STRUCT_TLVLEN
13479 (wmi_hb_set_enable_cmd_fixed_param));
13480
13481 /* fill in values */
13482 hb_enable_fp->vdev_id = params->session;
13483 hb_enable_fp->enable = params->enable;
13484 hb_enable_fp->item = params->item;
13485 hb_enable_fp->session = params->session;
13486
13487 status = wmi_unified_cmd_send(wmi_handle, buf,
13488 len, WMI_HB_SET_ENABLE_CMDID);
13489 if (QDF_IS_STATUS_ERROR(status)) {
13490 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13491 status);
13492 wmi_buf_free(buf);
13493 }
13494
13495 return status;
13496}
13497
13498/**
13499 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13500 * @wmi_handle: wmi handle
13501 * @lphb_conf_req: lphb config request
13502 *
13503 * Return: CDF status
13504 */
13505static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13506 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13507{
13508 QDF_STATUS status;
13509 wmi_buf_t buf = NULL;
13510 uint8_t *buf_ptr;
13511 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13512 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13513
13514 buf = wmi_buf_alloc(wmi_handle, len);
13515 if (!buf) {
13516 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13517 return QDF_STATUS_E_NOMEM;
13518 }
13519
13520 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13521 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13522 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13523 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13524 WMITLV_GET_STRUCT_TLVLEN
13525 (wmi_hb_set_tcp_params_cmd_fixed_param));
13526
13527 /* fill in values */
13528 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13529 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13530 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13531 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13532 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13533 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13534 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13535 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13536 hb_tcp_params_fp->session = lphb_conf_req->session;
13537 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13538 &lphb_conf_req->gateway_mac,
13539 sizeof(hb_tcp_params_fp->gateway_mac));
13540
13541 status = wmi_unified_cmd_send(wmi_handle, buf,
13542 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13543 if (QDF_IS_STATUS_ERROR(status)) {
13544 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13545 status);
13546 wmi_buf_free(buf);
13547 }
13548
13549 return status;
13550}
13551
13552/**
13553 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13554 * @wmi_handle: wmi handle
13555 * @lphb_conf_req: lphb config request
13556 *
13557 * Return: CDF status
13558 */
13559static
13560QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13561 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13562{
13563 QDF_STATUS status;
13564 wmi_buf_t buf = NULL;
13565 uint8_t *buf_ptr;
13566 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13567 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13568
13569 buf = wmi_buf_alloc(wmi_handle, len);
13570 if (!buf) {
13571 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13572 return QDF_STATUS_E_NOMEM;
13573 }
13574
13575 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13576 hb_tcp_filter_fp =
13577 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13578 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13579 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13580 WMITLV_GET_STRUCT_TLVLEN
13581 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13582
13583 /* fill in values */
13584 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13585 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13586 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13587 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13588 memcpy((void *)&hb_tcp_filter_fp->filter,
13589 (void *)&g_hb_tcp_filter_fp->filter,
13590 WMI_WLAN_HB_MAX_FILTER_SIZE);
13591
13592 status = wmi_unified_cmd_send(wmi_handle, buf,
13593 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13594 if (QDF_IS_STATUS_ERROR(status)) {
13595 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13596 status);
13597 wmi_buf_free(buf);
13598 }
13599
13600 return status;
13601}
13602
13603/**
13604 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13605 * @wmi_handle: wmi handle
13606 * @lphb_conf_req: lphb config request
13607 *
13608 * Return: CDF status
13609 */
13610static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13611 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13612{
13613 QDF_STATUS status;
13614 wmi_buf_t buf = NULL;
13615 uint8_t *buf_ptr;
13616 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13617 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13618
13619 buf = wmi_buf_alloc(wmi_handle, len);
13620 if (!buf) {
13621 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13622 return QDF_STATUS_E_NOMEM;
13623 }
13624
13625 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13626 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13627 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13628 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13629 WMITLV_GET_STRUCT_TLVLEN
13630 (wmi_hb_set_udp_params_cmd_fixed_param));
13631
13632 /* fill in values */
13633 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13634 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13635 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13636 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13637 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13638 hb_udp_params_fp->interval = lphb_conf_req->interval;
13639 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13640 hb_udp_params_fp->session = lphb_conf_req->session;
13641 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13642 &lphb_conf_req->gateway_mac,
13643 sizeof(lphb_conf_req->gateway_mac));
13644
13645 status = wmi_unified_cmd_send(wmi_handle, buf,
13646 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13647 if (QDF_IS_STATUS_ERROR(status)) {
13648 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13649 status);
13650 wmi_buf_free(buf);
13651 }
13652
13653 return status;
13654}
13655
13656/**
13657 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13658 * @wmi_handle: wmi handle
13659 * @lphb_conf_req: lphb config request
13660 *
13661 * Return: CDF status
13662 */
13663static
13664QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13665 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13666{
13667 QDF_STATUS status;
13668 wmi_buf_t buf = NULL;
13669 uint8_t *buf_ptr;
13670 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13671 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13672
13673 buf = wmi_buf_alloc(wmi_handle, len);
13674 if (!buf) {
13675 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13676 return QDF_STATUS_E_NOMEM;
13677 }
13678
13679 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13680 hb_udp_filter_fp =
13681 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13682 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13683 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13684 WMITLV_GET_STRUCT_TLVLEN
13685 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13686
13687 /* fill in values */
13688 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13689 hb_udp_filter_fp->length = lphb_conf_req->length;
13690 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13691 hb_udp_filter_fp->session = lphb_conf_req->session;
13692 memcpy((void *)&hb_udp_filter_fp->filter,
13693 (void *)&lphb_conf_req->filter,
13694 WMI_WLAN_HB_MAX_FILTER_SIZE);
13695
13696 status = wmi_unified_cmd_send(wmi_handle, buf,
13697 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13698 if (QDF_IS_STATUS_ERROR(status)) {
13699 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13700 status);
13701 wmi_buf_free(buf);
13702 }
13703
13704 return status;
13705}
13706#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013707
Dustin Brownf31f88b2017-05-12 14:01:44 -070013708static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
13709 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013710{
Dustin Brownf31f88b2017-05-12 14:01:44 -070013711 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013712 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070013713 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013714
Dustin Brownf31f88b2017-05-12 14:01:44 -070013715 if (!req) {
13716 WMI_LOGE("req is null");
13717 return QDF_STATUS_E_INVAL;
13718 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013719
Dustin Brownf31f88b2017-05-12 14:01:44 -070013720 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
13721 if (!wmi_buf) {
13722 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013723 return QDF_STATUS_E_NOMEM;
13724 }
13725
Dustin Brownf31f88b2017-05-12 14:01:44 -070013726 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013727 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070013728 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13729 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
13730 cmd->vdev_id = req->vdev_id;
13731 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
13732 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013733
Dustin Brownf31f88b2017-05-12 14:01:44 -070013734 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
13735 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013736
Dustin Brownf31f88b2017-05-12 14:01:44 -070013737 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
13738 WMI_HW_DATA_FILTER_CMDID);
13739 if (QDF_IS_STATUS_ERROR(status)) {
13740 WMI_LOGE("Failed to configure hw filter");
13741 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013742 }
13743
Dustin Brownf31f88b2017-05-12 14:01:44 -070013744 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013745}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053013746
13747/**
13748 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
13749 * @wmi_handle: wmi handle
13750 * @vdev_id: vdev id
13751 * @enable: Flag to enable/disable packet filter
13752 *
13753 * Return: QDF_STATUS_SUCCESS for success or error code
13754 */
13755static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
13756 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
13757{
13758 int32_t len;
13759 int ret = 0;
13760 wmi_buf_t buf;
13761 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
13762
13763 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
13764
13765 buf = wmi_buf_alloc(wmi_handle, len);
13766 if (!buf) {
13767 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13768 return QDF_STATUS_E_NOMEM;
13769 }
13770
13771 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
13772 WMITLV_SET_HDR(&cmd->tlv_header,
13773 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
13774 WMITLV_GET_STRUCT_TLVLEN(
13775 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
13776
13777 cmd->vdev_id = vdev_id;
13778 if (enable)
13779 cmd->enable = PACKET_FILTER_SET_ENABLE;
13780 else
13781 cmd->enable = PACKET_FILTER_SET_DISABLE;
13782
13783 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
13784 __func__, cmd->enable, vdev_id);
13785
13786 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13787 WMI_PACKET_FILTER_ENABLE_CMDID);
13788 if (ret) {
13789 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
13790 wmi_buf_free(buf);
13791 }
13792
13793 return ret;
13794}
13795
13796/**
13797 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
13798 * @wmi_handle: wmi handle
13799 * @vdev_id: vdev id
13800 * @rcv_filter_param: Packet filter parameters
13801 * @filter_id: Filter id
13802 * @enable: Flag to add/delete packet filter configuration
13803 *
13804 * Return: QDF_STATUS_SUCCESS for success or error code
13805 */
13806static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
13807 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
13808 uint8_t filter_id, bool enable)
13809{
13810 int len, i;
13811 int err = 0;
13812 wmi_buf_t buf;
13813 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
13814
13815
13816 /* allocate the memory */
13817 len = sizeof(*cmd);
13818 buf = wmi_buf_alloc(wmi_handle, len);
13819 if (!buf) {
13820 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13821 return QDF_STATUS_E_NOMEM;
13822 }
13823
13824 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13825 WMITLV_SET_HDR(&cmd->tlv_header,
13826 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
13827 WMITLV_GET_STRUCT_TLVLEN
13828 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
13829
13830 cmd->vdev_id = vdev_id;
13831 cmd->filter_id = filter_id;
13832 if (enable)
13833 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
13834 else
13835 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
13836
13837 if (enable) {
13838 cmd->num_params = QDF_MIN(
13839 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
13840 rcv_filter_param->num_params);
13841 cmd->filter_type = rcv_filter_param->filter_type;
13842 cmd->coalesce_time = rcv_filter_param->coalesce_time;
13843
13844 for (i = 0; i < cmd->num_params; i++) {
13845 cmd->paramsData[i].proto_type =
13846 rcv_filter_param->params_data[i].protocol_layer;
13847 cmd->paramsData[i].cmp_type =
13848 rcv_filter_param->params_data[i].compare_flag;
13849 cmd->paramsData[i].data_length =
13850 rcv_filter_param->params_data[i].data_length;
13851 cmd->paramsData[i].data_offset =
13852 rcv_filter_param->params_data[i].data_offset;
13853 memcpy(&cmd->paramsData[i].compareData,
13854 rcv_filter_param->params_data[i].compare_data,
13855 sizeof(cmd->paramsData[i].compareData));
13856 memcpy(&cmd->paramsData[i].dataMask,
13857 rcv_filter_param->params_data[i].data_mask,
13858 sizeof(cmd->paramsData[i].dataMask));
13859 }
13860 }
13861
13862 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
13863 cmd->filter_action, cmd->filter_id, cmd->num_params);
13864 /* send the command along with data */
13865 err = wmi_unified_cmd_send(wmi_handle, buf, len,
13866 WMI_PACKET_FILTER_CONFIG_CMDID);
13867 if (err) {
13868 WMI_LOGE("Failed to send pkt_filter cmd");
13869 wmi_buf_free(buf);
13870 return QDF_STATUS_E_FAILURE;
13871 }
13872
13873 return QDF_STATUS_SUCCESS;
13874}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053013875#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013876
Govind Singha4836fd2016-03-07 16:45:38 +053013877/**
13878 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13879 * @wmi_handle: wmi handle
13880 * @request: SSID hotlist set request
13881 *
Govind Singhb53420c2016-03-09 14:32:57 +053013882 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013883 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013884static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013885send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13886 struct ssid_hotlist_request_params *request)
13887{
13888 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13889 wmi_buf_t wmi_buf;
13890 uint32_t len;
13891 uint32_t array_size;
13892 uint8_t *buf_ptr;
13893
13894 /* length of fixed portion */
13895 len = sizeof(*cmd);
13896
13897 /* length of variable portion */
13898 array_size =
13899 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
13900 len += WMI_TLV_HDR_SIZE + array_size;
13901
13902 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13903 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013904 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13905 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013906 }
13907
13908 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
13909 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
13910 buf_ptr;
13911 WMITLV_SET_HDR
13912 (&cmd->tlv_header,
13913 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
13914 WMITLV_GET_STRUCT_TLVLEN
13915 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
13916
13917 cmd->request_id = request->request_id;
13918 cmd->requestor_id = 0;
13919 cmd->vdev_id = request->session_id;
13920 cmd->table_id = 0;
13921 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
13922 cmd->total_entries = request->ssid_count;
13923 cmd->num_entries_in_page = request->ssid_count;
13924 cmd->first_entry_index = 0;
13925
13926 buf_ptr += sizeof(*cmd);
13927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
13928
13929 if (request->ssid_count) {
13930 wmi_extscan_hotlist_ssid_entry *entry;
13931 int i;
13932
13933 buf_ptr += WMI_TLV_HDR_SIZE;
13934 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
13935 for (i = 0; i < request->ssid_count; i++) {
13936 WMITLV_SET_HDR
13937 (entry,
13938 WMITLV_TAG_ARRAY_STRUC,
13939 WMITLV_GET_STRUCT_TLVLEN
13940 (wmi_extscan_hotlist_ssid_entry));
13941 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053013942 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053013943 request->ssids[i].ssid.mac_ssid,
13944 request->ssids[i].ssid.length);
13945 entry->band = request->ssids[i].band;
13946 entry->min_rssi = request->ssids[i].rssi_low;
13947 entry->max_rssi = request->ssids[i].rssi_high;
13948 entry++;
13949 }
13950 cmd->mode = WMI_EXTSCAN_MODE_START;
13951 } else {
13952 cmd->mode = WMI_EXTSCAN_MODE_STOP;
13953 }
13954
13955 if (wmi_unified_cmd_send
13956 (wmi_handle, wmi_buf, len,
13957 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013958 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013959 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013960 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013961 }
13962
Govind Singhb53420c2016-03-09 14:32:57 +053013963 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013964}
13965
13966/**
13967 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
13968 * @wmi_handle: wmi handle
13969 * @vdev_id: vdev id
13970 *
13971 * This function sends roam synch complete event to fw.
13972 *
13973 * Return: CDF STATUS
13974 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013975static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013976 uint8_t vdev_id)
13977{
13978 wmi_roam_synch_complete_fixed_param *cmd;
13979 wmi_buf_t wmi_buf;
13980 uint8_t *buf_ptr;
13981 uint16_t len;
13982 len = sizeof(wmi_roam_synch_complete_fixed_param);
13983
13984 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13985 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013986 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13987 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013988 }
13989 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
13990 buf_ptr = (uint8_t *) cmd;
13991 WMITLV_SET_HDR(&cmd->tlv_header,
13992 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
13993 WMITLV_GET_STRUCT_TLVLEN
13994 (wmi_roam_synch_complete_fixed_param));
13995 cmd->vdev_id = vdev_id;
13996 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13997 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013998 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053013999 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014000 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014001 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014002 }
14003
Govind Singhb53420c2016-03-09 14:32:57 +053014004 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014005}
14006
14007/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014008 * send_fw_test_cmd_tlv() - send fw test command to fw.
14009 * @wmi_handle: wmi handle
14010 * @wmi_fwtest: fw test command
14011 *
14012 * This function sends fw test command to fw.
14013 *
14014 * Return: CDF STATUS
14015 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014016static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014017QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14018 struct set_fwtest_params *wmi_fwtest)
14019{
14020 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14021 wmi_buf_t wmi_buf;
14022 uint16_t len;
14023
14024 len = sizeof(*cmd);
14025
14026 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14027 if (!wmi_buf) {
14028 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14029 return QDF_STATUS_E_NOMEM;
14030 }
14031
14032 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14033 WMITLV_SET_HDR(&cmd->tlv_header,
14034 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14035 WMITLV_GET_STRUCT_TLVLEN(
14036 wmi_fwtest_set_param_cmd_fixed_param));
14037 cmd->param_id = wmi_fwtest->arg;
14038 cmd->param_value = wmi_fwtest->value;
14039
14040 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14041 WMI_FWTEST_CMDID)) {
14042 WMI_LOGP("%s: failed to send fw test command", __func__);
14043 qdf_nbuf_free(wmi_buf);
14044 return QDF_STATUS_E_FAILURE;
14045 }
14046
14047 return QDF_STATUS_SUCCESS;
14048}
14049
14050/**
Govind Singha4836fd2016-03-07 16:45:38 +053014051 * send_unit_test_cmd_tlv() - send unit test command to fw.
14052 * @wmi_handle: wmi handle
14053 * @wmi_utest: unit test command
14054 *
14055 * This function send unit test command to fw.
14056 *
14057 * Return: CDF STATUS
14058 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014059static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014060 struct wmi_unit_test_cmd *wmi_utest)
14061{
14062 wmi_unit_test_cmd_fixed_param *cmd;
14063 wmi_buf_t wmi_buf;
14064 uint8_t *buf_ptr;
14065 int i;
14066 uint16_t len, args_tlv_len;
14067 A_UINT32 *unit_test_cmd_args;
14068
14069 args_tlv_len =
14070 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14071 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14072
14073 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14074 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014075 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14076 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014077 }
14078
14079 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14080 buf_ptr = (uint8_t *) cmd;
14081 WMITLV_SET_HDR(&cmd->tlv_header,
14082 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14083 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14084 cmd->vdev_id = wmi_utest->vdev_id;
14085 cmd->module_id = wmi_utest->module_id;
14086 cmd->num_args = wmi_utest->num_args;
14087 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14088 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14089 (wmi_utest->num_args * sizeof(uint32_t)));
14090 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014091 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014092 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14093 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014094 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014095 }
14096 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14097 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014098 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014099 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014100 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014101 }
14102
Govind Singhb53420c2016-03-09 14:32:57 +053014103 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014104}
14105
14106/**
14107 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14108 * @wmi_handle: wma handle
14109 * @roaminvoke: roam invoke command
14110 *
14111 * Send roam invoke command to fw for fastreassoc.
14112 *
14113 * Return: CDF STATUS
14114 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014115static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014116 struct wmi_roam_invoke_cmd *roaminvoke,
14117 uint32_t ch_hz)
14118{
14119 wmi_roam_invoke_cmd_fixed_param *cmd;
14120 wmi_buf_t wmi_buf;
14121 u_int8_t *buf_ptr;
14122 u_int16_t len, args_tlv_len;
14123 A_UINT32 *channel_list;
14124 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014125 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014126
14127 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014128 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14129 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14130 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014131 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14132 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14133 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014134 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14135 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014136 }
14137
14138 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14139 buf_ptr = (u_int8_t *) cmd;
14140 WMITLV_SET_HDR(&cmd->tlv_header,
14141 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14142 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14143 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014144 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014145
14146 if (roaminvoke->frame_len)
14147 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
14148 else
14149 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
14150
Govind Singha4836fd2016-03-07 16:45:38 +053014151 cmd->roam_ap_sel_mode = 0;
14152 cmd->roam_delay = 0;
14153 cmd->num_chan = 1;
14154 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014155 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14156 cmd->num_buf = 1;
14157
Govind Singha4836fd2016-03-07 16:45:38 +053014158 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14159 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14160 (sizeof(u_int32_t)));
14161 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14162 *channel_list = ch_hz;
14163 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14164 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14165 (sizeof(wmi_mac_addr)));
14166 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14167 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014168
14169 /* move to next tlv i.e. bcn_prb_buf_list */
14170 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14171
14172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14173 sizeof(wmi_tlv_buf_len_param));
14174
14175 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14176 buf_len_tlv->buf_len = roaminvoke->frame_len;
14177
14178 /* move to next tlv i.e. bcn_prb_frm */
14179 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14180 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14181 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14182
14183 /* copy frame after the header */
14184 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14185 roaminvoke->frame_buf,
14186 roaminvoke->frame_len);
14187
14188 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14189 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14190 buf_ptr + WMI_TLV_HDR_SIZE,
14191 roaminvoke->frame_len);
Varun Reddy Yeturu1ad240c2017-03-21 10:44:28 -070014192 WMI_LOGD(FL("flags:%d, scan_mode:%d"), cmd->flags, cmd->roam_scan_mode);
Naveen Rawat77797922017-01-20 17:00:07 -080014193
Govind Singha4836fd2016-03-07 16:45:38 +053014194 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14195 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014196 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014197 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014198 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014199 }
14200
Govind Singhb53420c2016-03-09 14:32:57 +053014201 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014202}
14203
14204/**
14205 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14206 * @wmi_handle: wmi handle
14207 * @command: command
14208 * @vdev_id: vdev id
14209 *
14210 * This function set roam offload command to fw.
14211 *
14212 * Return: CDF status
14213 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014214static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014215 uint32_t command, uint32_t vdev_id)
14216{
Govind Singh67922e82016-04-01 16:48:57 +053014217 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014218 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14219 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014220 int len;
14221 uint8_t *buf_ptr;
14222
14223 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14224 buf = wmi_buf_alloc(wmi_handle, len);
14225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014226 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14227 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014228 }
14229
14230 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14231
14232 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14233 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14234 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14235 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14236 cmd_fp->vdev_id = vdev_id;
14237 cmd_fp->command_arg = command;
14238
14239 status = wmi_unified_cmd_send(wmi_handle, buf,
14240 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014241 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014242 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014243 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014244 goto error;
14245 }
14246
Govind Singhb53420c2016-03-09 14:32:57 +053014247 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14248 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014249
14250error:
14251 wmi_buf_free(buf);
14252
Govind Singh67922e82016-04-01 16:48:57 +053014253 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014254}
14255
14256/**
14257 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14258 * @wmi_handle: wmi handle
14259 * @ap_profile_p: ap profile
14260 * @vdev_id: vdev id
14261 *
14262 * Send WMI_ROAM_AP_PROFILE to firmware
14263 *
14264 * Return: CDF status
14265 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014266static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014267 wmi_ap_profile *ap_profile_p,
14268 uint32_t vdev_id)
14269{
Govind Singha4836fd2016-03-07 16:45:38 +053014270 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014271 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014272 int len;
14273 uint8_t *buf_ptr;
14274 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14275
14276 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14277
14278 buf = wmi_buf_alloc(wmi_handle, len);
14279 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014280 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14281 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014282 }
14283
14284 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14285 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14286 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14287 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14288 WMITLV_GET_STRUCT_TLVLEN
14289 (wmi_roam_ap_profile_fixed_param));
14290 /* fill in threshold values */
14291 roam_ap_profile_fp->vdev_id = vdev_id;
14292 roam_ap_profile_fp->id = 0;
14293 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14294
Govind Singhb53420c2016-03-09 14:32:57 +053014295 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014296 WMITLV_SET_HDR(buf_ptr,
14297 WMITLV_TAG_STRUC_wmi_ap_profile,
14298 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14299 status = wmi_unified_cmd_send(wmi_handle, buf,
14300 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014301 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014302 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014303 status);
Govind Singh67922e82016-04-01 16:48:57 +053014304 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014305 }
14306
Govind Singhb53420c2016-03-09 14:32:57 +053014307 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014308
Govind Singh67922e82016-04-01 16:48:57 +053014309 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014310}
14311
14312/**
14313 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14314 * @wmi_handle: wmi handle
14315 * @scan_period: scan period
14316 * @scan_age: scan age
14317 * @vdev_id: vdev id
14318 *
14319 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14320 *
14321 * Return: CDF status
14322 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014323static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014324 uint32_t scan_period,
14325 uint32_t scan_age,
14326 uint32_t vdev_id)
14327{
Govind Singh67922e82016-04-01 16:48:57 +053014328 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014329 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014330 int len;
14331 uint8_t *buf_ptr;
14332 wmi_roam_scan_period_fixed_param *scan_period_fp;
14333
14334 /* Send scan period values */
14335 len = sizeof(wmi_roam_scan_period_fixed_param);
14336 buf = wmi_buf_alloc(wmi_handle, len);
14337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014338 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14339 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014340 }
14341
14342 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14343 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14344 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14345 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14346 WMITLV_GET_STRUCT_TLVLEN
14347 (wmi_roam_scan_period_fixed_param));
14348 /* fill in scan period values */
14349 scan_period_fp->vdev_id = vdev_id;
14350 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14351 scan_period_fp->roam_scan_age = scan_age;
14352
14353 status = wmi_unified_cmd_send(wmi_handle, buf,
14354 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014355 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014356 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014357 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014358 goto error;
14359 }
14360
Govind Singhb53420c2016-03-09 14:32:57 +053014361 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014362 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014363 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014364error:
14365 wmi_buf_free(buf);
14366
Govind Singh67922e82016-04-01 16:48:57 +053014367 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014368}
14369
14370/**
14371 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14372 * @wmi_handle: wmi handle
14373 * @chan_count: channel count
14374 * @chan_list: channel list
14375 * @list_type: list type
14376 * @vdev_id: vdev id
14377 *
14378 * Set roam offload channel list.
14379 *
14380 * Return: CDF status
14381 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014382static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014383 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014384 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014385 uint8_t list_type, uint32_t vdev_id)
14386{
Govind Singha4836fd2016-03-07 16:45:38 +053014387 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014388 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014389 int len, list_tlv_len;
14390 int i;
14391 uint8_t *buf_ptr;
14392 wmi_roam_chan_list_fixed_param *chan_list_fp;
14393 A_UINT32 *roam_chan_list_array;
14394
14395 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014396 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014397 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014398 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014399 }
14400 /* Channel list is a table of 2 TLV's */
14401 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14402 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14403 buf = wmi_buf_alloc(wmi_handle, len);
14404 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014405 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14406 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014407 }
14408
14409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14410 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14411 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14412 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14413 WMITLV_GET_STRUCT_TLVLEN
14414 (wmi_roam_chan_list_fixed_param));
14415 chan_list_fp->vdev_id = vdev_id;
14416 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014417 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014418 /* external app is controlling channel list */
14419 chan_list_fp->chan_list_type =
14420 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14421 } else {
14422 /* umac supplied occupied channel list in LFR */
14423 chan_list_fp->chan_list_type =
14424 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14425 }
14426
14427 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14428 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14429 (chan_list_fp->num_chan * sizeof(uint32_t)));
14430 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014431 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014432 for (i = 0; ((i < chan_list_fp->num_chan) &&
14433 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14434 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014435 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014436 }
14437
14438 status = wmi_unified_cmd_send(wmi_handle, buf,
14439 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014440 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014441 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014442 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014443 goto error;
14444 }
14445
Govind Singhb53420c2016-03-09 14:32:57 +053014446 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
14447 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014448error:
14449 wmi_buf_free(buf);
14450
Govind Singh67922e82016-04-01 16:48:57 +053014451 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014452}
14453
14454/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014455 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14456 * @wmi_handle: wmi handle
14457 * @req_buf: per roam config buffer
14458 *
14459 * Return: QDF status
14460 */
14461static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14462 struct wmi_per_roam_config_req *req_buf)
14463{
14464 wmi_buf_t buf = NULL;
14465 QDF_STATUS status;
14466 int len;
14467 uint8_t *buf_ptr;
14468 wmi_roam_per_config_fixed_param *wmi_per_config;
14469
14470 len = sizeof(wmi_roam_per_config_fixed_param);
14471 buf = wmi_buf_alloc(wmi_handle, len);
14472 if (!buf) {
14473 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14474 return QDF_STATUS_E_NOMEM;
14475 }
14476
14477 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14478 wmi_per_config =
14479 (wmi_roam_per_config_fixed_param *) buf_ptr;
14480 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14481 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14482 WMITLV_GET_STRUCT_TLVLEN
14483 (wmi_roam_per_config_fixed_param));
14484
14485 /* fill in per roam config values */
14486 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014487
14488 wmi_per_config->enable = req_buf->per_config.enable;
14489 wmi_per_config->high_rate_thresh =
14490 (req_buf->per_config.tx_high_rate_thresh << 16) |
14491 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14492 wmi_per_config->low_rate_thresh =
14493 (req_buf->per_config.tx_low_rate_thresh << 16) |
14494 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14495 wmi_per_config->pkt_err_rate_thresh_pct =
14496 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14497 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14498 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014499 wmi_per_config->pkt_err_rate_mon_time =
14500 (req_buf->per_config.tx_per_mon_time << 16) |
14501 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014502 wmi_per_config->min_candidate_rssi =
14503 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014504
14505 /* Send per roam config parameters */
14506 status = wmi_unified_cmd_send(wmi_handle, buf,
14507 len, WMI_ROAM_PER_CONFIG_CMDID);
14508 if (QDF_IS_STATUS_ERROR(status)) {
14509 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14510 status);
14511 wmi_buf_free(buf);
14512 return status;
14513 }
14514
14515 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14516 req_buf->per_config.enable, req_buf->vdev_id);
14517 return QDF_STATUS_SUCCESS;
14518}
14519
14520/**
Govind Singha4836fd2016-03-07 16:45:38 +053014521 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14522 * @wmi_handle: wmi handle
14523 * @rssi_change_thresh: RSSI Change threshold
14524 * @bcn_rssi_weight: beacon RSSI weight
14525 * @vdev_id: vdev id
14526 *
14527 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14528 *
14529 * Return: CDF status
14530 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014531static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014532 uint32_t vdev_id,
14533 int32_t rssi_change_thresh,
14534 uint32_t bcn_rssi_weight,
14535 uint32_t hirssi_delay_btw_scans)
14536{
Govind Singha4836fd2016-03-07 16:45:38 +053014537 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014538 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014539 int len;
14540 uint8_t *buf_ptr;
14541 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14542
14543 /* Send rssi change parameters */
14544 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14545 buf = wmi_buf_alloc(wmi_handle, len);
14546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014547 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14548 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014549 }
14550
14551 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14552 rssi_change_fp =
14553 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14554 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14555 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14556 WMITLV_GET_STRUCT_TLVLEN
14557 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14558 /* fill in rssi change threshold (hysteresis) values */
14559 rssi_change_fp->vdev_id = vdev_id;
14560 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14561 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14562 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14563
14564 status = wmi_unified_cmd_send(wmi_handle, buf,
14565 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014566 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014567 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014568 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014569 goto error;
14570 }
14571
Govind Singhb53420c2016-03-09 14:32:57 +053014572 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014573 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014574 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14575 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014576error:
14577 wmi_buf_free(buf);
14578
Govind Singh67922e82016-04-01 16:48:57 +053014579 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014580}
14581
14582/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14583 * @wmi_handle: wmi handle.
14584 * @cmd: size of command structure.
14585 * @per_entry_size: per entry size.
14586 *
14587 * This utility function calculates how many hotlist entries can
14588 * fit in one page.
14589 *
14590 * Return: number of entries
14591 */
14592static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14593 size_t cmd_size,
14594 size_t per_entry_size)
14595{
14596 uint32_t avail_space = 0;
14597 int num_entries = 0;
14598 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14599
14600 /* Calculate number of hotlist entries that can
14601 * be passed in wma message request.
14602 */
14603 avail_space = max_msg_len - cmd_size;
14604 num_entries = avail_space / per_entry_size;
14605 return num_entries;
14606}
14607
14608/**
14609 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14610 * @wmi_handle: wmi handle
14611 * @photlist: hotlist command params
14612 * @buf_len: buffer length
14613 *
14614 * This function fills individual elements for hotlist request and
14615 * TLV for bssid entries
14616 *
14617 * Return: CDF Status.
14618 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014619static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014620 struct ext_scan_setbssi_hotlist_params *
14621 photlist, int *buf_len)
14622{
14623 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14624 wmi_extscan_hotlist_entry *dest_hotlist;
14625 struct ap_threshold_params *src_ap = photlist->ap;
14626 wmi_buf_t buf;
14627 uint8_t *buf_ptr;
14628
14629 int j, index = 0;
14630 int cmd_len = 0;
14631 int num_entries;
14632 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014633 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014634 int len = sizeof(*cmd);
14635
14636 len += WMI_TLV_HDR_SIZE;
14637 cmd_len = len;
14638
14639 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14640 cmd_len,
14641 sizeof(*dest_hotlist));
14642 /* setbssid hotlist expects the bssid list
14643 * to be non zero value
14644 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014645 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014646 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014647 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014648 }
14649
14650 /* Split the hot list entry pages and send multiple command
14651 * requests if the buffer reaches the maximum request size
14652 */
14653 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014654 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014655 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14656 buf = wmi_buf_alloc(wmi_handle, len);
14657 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014658 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14659 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014660 }
14661 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14662 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14663 buf_ptr;
14664 WMITLV_SET_HDR(&cmd->tlv_header,
14665 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14666 WMITLV_GET_STRUCT_TLVLEN
14667 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14668
14669 /* Multiple requests are sent until the num_entries_in_page
14670 * matches the total_entries
14671 */
14672 cmd->request_id = photlist->requestId;
14673 cmd->vdev_id = photlist->sessionId;
14674 cmd->total_entries = numap;
14675 cmd->mode = 1;
14676 cmd->num_entries_in_page = min_entries;
14677 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14678 cmd->first_entry_index = index;
14679
Govind Singhb53420c2016-03-09 14:32:57 +053014680 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014681 __func__, cmd->vdev_id, cmd->total_entries,
14682 cmd->num_entries_in_page,
14683 cmd->lost_ap_scan_count);
14684
14685 buf_ptr += sizeof(*cmd);
14686 WMITLV_SET_HDR(buf_ptr,
14687 WMITLV_TAG_ARRAY_STRUC,
14688 min_entries * sizeof(wmi_extscan_hotlist_entry));
14689 dest_hotlist = (wmi_extscan_hotlist_entry *)
14690 (buf_ptr + WMI_TLV_HDR_SIZE);
14691
14692 /* Populate bssid, channel info and rssi
14693 * for the bssid's that are sent as hotlists.
14694 */
14695 for (j = 0; j < min_entries; j++) {
14696 WMITLV_SET_HDR(dest_hotlist,
14697 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14698 WMITLV_GET_STRUCT_TLVLEN
14699 (wmi_extscan_hotlist_entry));
14700
14701 dest_hotlist->min_rssi = src_ap->low;
14702 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14703 &dest_hotlist->bssid);
14704
Govind Singhb53420c2016-03-09 14:32:57 +053014705 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014706 __func__, dest_hotlist->channel,
14707 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014708 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014709 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14710 __func__, dest_hotlist->bssid.mac_addr31to0,
14711 dest_hotlist->bssid.mac_addr47to32);
14712 dest_hotlist++;
14713 src_ap++;
14714 }
14715 buf_ptr += WMI_TLV_HDR_SIZE +
14716 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14717
14718 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14719 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014720 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014721 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014722 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014723 }
14724 index = index + min_entries;
14725 num_entries = numap - min_entries;
14726 len = cmd_len;
14727 }
Govind Singhb53420c2016-03-09 14:32:57 +053014728 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014729}
14730
Govind Singhbca3b1b2016-05-02 17:59:24 +053014731/**
Dustin Brown4423f632017-01-13 15:24:07 -080014732 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14733 * @wmi_handle: the WMI handle
14734 * @vdev_id: the Id of the vdev to apply the configuration to
14735 * @ucast_mode: the active BPF mode to configure for unicast packets
14736 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14737 * packets
14738 *
14739 * Return: QDF status
14740 */
14741static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14742 uint8_t vdev_id,
14743 enum wmi_host_active_bpf_mode ucast_mode,
14744 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14745{
14746 const WMITLV_TAG_ID tag_id =
14747 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14748 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14749 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14750 QDF_STATUS status;
14751 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14752 wmi_buf_t buf;
14753
14754 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
14755 vdev_id, ucast_mode, mcast_bcast_mode);
14756
14757 /* allocate command buffer */
14758 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14759 if (!buf) {
14760 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14761 return QDF_STATUS_E_NOMEM;
14762 }
14763
14764 /* set TLV header */
14765 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14766 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14767
14768 /* populate data */
14769 cmd->vdev_id = vdev_id;
14770 cmd->uc_mode = ucast_mode;
14771 cmd->mcbc_mode = mcast_bcast_mode;
14772
14773 /* send to FW */
14774 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14775 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14776 if (QDF_IS_STATUS_ERROR(status)) {
14777 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14778 status);
14779 wmi_buf_free(buf);
14780 return status;
14781 }
14782
14783 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
14784
14785 return QDF_STATUS_SUCCESS;
14786}
14787
14788/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014789 * send_power_dbg_cmd_tlv() - send power debug commands
14790 * @wmi_handle: wmi handle
14791 * @param: wmi power debug parameter
14792 *
14793 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14794 *
14795 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14796 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014797static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14798 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014799{
14800 wmi_buf_t buf = NULL;
14801 QDF_STATUS status;
14802 int len, args_tlv_len;
14803 uint8_t *buf_ptr;
14804 uint8_t i;
14805 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14806 uint32_t *cmd_args;
14807
14808 /* Prepare and send power debug cmd parameters */
14809 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14810 len = sizeof(*cmd) + args_tlv_len;
14811 buf = wmi_buf_alloc(wmi_handle, len);
14812 if (!buf) {
14813 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14814 return QDF_STATUS_E_NOMEM;
14815 }
14816
14817 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14818 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14819 WMITLV_SET_HDR(&cmd->tlv_header,
14820 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14821 WMITLV_GET_STRUCT_TLVLEN
14822 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14823
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014824 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14825 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053014826 cmd->module_id = param->module_id;
14827 cmd->num_args = param->num_args;
14828 buf_ptr += sizeof(*cmd);
14829 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14830 (param->num_args * sizeof(uint32_t)));
14831 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14832 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14833 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14834 cmd_args[i] = param->args[i];
14835 WMI_LOGI("%d,", param->args[i]);
14836 }
14837
14838 status = wmi_unified_cmd_send(wmi_handle, buf,
14839 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14840 if (QDF_IS_STATUS_ERROR(status)) {
14841 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14842 status);
14843 goto error;
14844 }
14845
14846 return QDF_STATUS_SUCCESS;
14847error:
14848 wmi_buf_free(buf);
14849
14850 return status;
14851}
14852
Kiran Venkatappa26117052016-12-23 19:58:54 +053014853/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014854 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014855 * @buf_ptr: pointer to current position in init command buffer
14856 * @len: pointer to length. This will be updated with current lenght of cmd
14857 * @param: point host parameters for init command
14858 *
14859 * Return: Updated pointer of buf_ptr.
14860 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014861static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
14862 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053014863{
14864 uint16_t idx;
14865
14866 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14867 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14868 wmi_pdev_band_to_mac *band_to_mac;
14869
14870 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14871 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14872 sizeof(wmi_resource_config) +
14873 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14874 sizeof(wlan_host_memory_chunk)));
14875
14876 WMITLV_SET_HDR(&hw_mode->tlv_header,
14877 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14878 (WMITLV_GET_STRUCT_TLVLEN
14879 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14880
14881 hw_mode->hw_mode_index = param->hw_mode_id;
14882 hw_mode->num_band_to_mac = param->num_band_to_mac;
14883
14884 buf_ptr = (uint8_t *) (hw_mode + 1);
14885 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14886 WMI_TLV_HDR_SIZE);
14887 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14888 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14889 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14890 WMITLV_GET_STRUCT_TLVLEN
14891 (wmi_pdev_band_to_mac));
14892 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014893 wmi_handle->ops->convert_pdev_id_host_to_target(
14894 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014895 band_to_mac[idx].start_freq =
14896 param->band_to_mac[idx].start_freq;
14897 band_to_mac[idx].end_freq =
14898 param->band_to_mac[idx].end_freq;
14899 }
14900 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14901 (param->num_band_to_mac *
14902 sizeof(wmi_pdev_band_to_mac)) +
14903 WMI_TLV_HDR_SIZE;
14904
14905 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14906 (param->num_band_to_mac *
14907 sizeof(wmi_pdev_band_to_mac)));
14908 }
14909
14910 return buf_ptr;
14911}
14912
Govind Singhe7f2f342016-05-23 12:12:52 +053014913/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014914 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
14915 * @wmi_handle: wmi handle
14916 * @param: wmi multiple vdev restart req param
14917 *
14918 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
14919 *
14920 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14921 */
14922static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
14923 wmi_unified_t wmi_handle,
14924 struct multiple_vdev_restart_params *param)
14925{
14926 wmi_buf_t buf;
14927 QDF_STATUS qdf_status;
14928 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
14929 int i;
14930 uint8_t *buf_ptr;
14931 uint32_t *vdev_ids;
14932 wmi_channel *chan_info;
14933 struct channel_param *tchan_info;
14934 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
14935
14936 len += sizeof(wmi_channel);
14937 if (param->num_vdevs)
14938 len += sizeof(uint32_t) * param->num_vdevs;
14939
14940 buf = wmi_buf_alloc(wmi_handle, len);
14941 if (!buf) {
14942 WMI_LOGE("Failed to allocate memory\n");
14943 qdf_status = QDF_STATUS_E_NOMEM;
14944 goto end;
14945 }
14946
14947 buf_ptr = (uint8_t *)wmi_buf_data(buf);
14948 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
14949 buf_ptr;
14950
14951 WMITLV_SET_HDR(&cmd->tlv_header,
14952 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
14953 WMITLV_GET_STRUCT_TLVLEN
14954 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014955 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14956 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053014957 cmd->requestor_id = param->requestor_id;
14958 cmd->disable_hw_ack = param->disable_hw_ack;
14959 cmd->cac_duration_ms = param->cac_duration_ms;
14960 cmd->num_vdevs = param->num_vdevs;
14961
14962 buf_ptr += sizeof(*cmd);
14963
14964 WMITLV_SET_HDR(buf_ptr,
14965 WMITLV_TAG_ARRAY_UINT32,
14966 sizeof(A_UINT32) * param->num_vdevs);
14967 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
14968 for (i = 0; i < param->num_vdevs; i++) {
14969 vdev_ids[i] = param->vdev_ids[i];
14970 }
14971
14972 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
14973
14974 WMITLV_SET_HDR(buf_ptr,
14975 WMITLV_TAG_STRUC_wmi_channel,
14976 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053014977 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053014978 tchan_info = &(param->ch_param);
14979 chan_info->mhz = tchan_info->mhz;
14980 chan_info->band_center_freq1 = tchan_info->cfreq1;
14981 chan_info->band_center_freq2 = tchan_info->cfreq2;
14982 if (tchan_info->is_chan_passive)
14983 WMI_SET_CHANNEL_FLAG(chan_info,
14984 WMI_CHAN_FLAG_PASSIVE);
14985 if (tchan_info->allow_vht)
14986 WMI_SET_CHANNEL_FLAG(chan_info,
14987 WMI_CHAN_FLAG_ALLOW_VHT);
14988 else if (tchan_info->allow_ht)
14989 WMI_SET_CHANNEL_FLAG(chan_info,
14990 WMI_CHAN_FLAG_ALLOW_HT);
14991 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
14992 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
14993 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
14994 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
14995 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
14996 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
14997
14998 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
14999 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15000
15001 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15002 WMI_LOGE("%s: Failed to send\n", __func__);
15003 wmi_buf_free(buf);
15004 }
15005
15006end:
15007 return qdf_status;
15008}
15009
15010/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015011 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15012 * @wmi_handle: wmi handle
15013 * @pdev_id: pdev id
15014 *
15015 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15016 *
15017 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15018 */
15019static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15020 uint32_t pdev_id)
15021{
15022 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15023 wmi_buf_t buf;
15024 uint16_t len;
15025 QDF_STATUS ret;
15026
15027 len = sizeof(*cmd);
15028 buf = wmi_buf_alloc(wmi_handle, len);
15029
15030 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15031
15032 if (!buf) {
15033 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15034 return QDF_STATUS_E_NOMEM;
15035 }
15036
15037 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15038 wmi_buf_data(buf);
15039
15040 WMITLV_SET_HDR(&cmd->tlv_header,
15041 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15042 WMITLV_GET_STRUCT_TLVLEN(
15043 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15044
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015045 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015046 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15047 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15048 if (QDF_IS_STATUS_ERROR(ret)) {
15049 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15050 __func__, ret, pdev_id);
15051 wmi_buf_free(buf);
15052 return QDF_STATUS_E_FAILURE;
15053 }
15054
15055 return QDF_STATUS_SUCCESS;
15056}
15057
15058/**
15059 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15060 * @wmi_handle: wmi handle
15061 * @pdev_id: pdev id
15062 *
15063 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15064 *
15065 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15066 */
15067static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15068 uint32_t pdev_id)
15069{
15070 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15071 wmi_buf_t buf;
15072 uint16_t len;
15073 QDF_STATUS ret;
15074
15075 len = sizeof(*cmd);
15076 buf = wmi_buf_alloc(wmi_handle, len);
15077
15078 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15079
15080 if (!buf) {
15081 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15082 return QDF_STATUS_E_NOMEM;
15083 }
15084
15085 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15086 wmi_buf_data(buf);
15087
15088 WMITLV_SET_HDR(&cmd->tlv_header,
15089 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15090 WMITLV_GET_STRUCT_TLVLEN(
15091 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15092
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015093 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015094 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15095 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15096 if (QDF_IS_STATUS_ERROR(ret)) {
15097 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15098 __func__, ret, pdev_id);
15099 wmi_buf_free(buf);
15100 return QDF_STATUS_E_FAILURE;
15101 }
15102
15103 return QDF_STATUS_SUCCESS;
15104}
15105
15106/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015107 * init_cmd_send_tlv() - send initialization cmd to fw
15108 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015109 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015110 *
15111 * Return: QDF_STATUS_SUCCESS for success or error code
15112 */
15113static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015114 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015115{
15116 wmi_buf_t buf;
15117 wmi_init_cmd_fixed_param *cmd;
15118 wmi_abi_version my_vers;
15119 int num_whitelist;
15120 uint8_t *buf_ptr;
15121 wmi_resource_config *resource_cfg;
15122 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015123 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015124 uint16_t idx;
15125 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015126 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015127
Kiran Venkatappa26117052016-12-23 19:58:54 +053015128 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15129 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015130 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015131
15132 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15133 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15134 WMI_TLV_HDR_SIZE +
15135 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15136
15137 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015138 if (!buf) {
15139 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15140 return QDF_STATUS_E_FAILURE;
15141 }
15142
15143 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15144 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15145 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15146
15147 host_mem_chunks = (wlan_host_memory_chunk *)
15148 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15149 + WMI_TLV_HDR_SIZE);
15150
15151 WMITLV_SET_HDR(&cmd->tlv_header,
15152 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15153 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15154
Kiran Venkatappa26117052016-12-23 19:58:54 +053015155 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015156 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15157 WMITLV_TAG_STRUC_wmi_resource_config,
15158 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15159
Kiran Venkatappa26117052016-12-23 19:58:54 +053015160 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015161 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15162 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15163 WMITLV_GET_STRUCT_TLVLEN
15164 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015165 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15166 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15167 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015168 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15169 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015170 idx, host_mem_chunks[idx].size,
15171 host_mem_chunks[idx].ptr);
15172 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015173 cmd->num_host_mem_chunks = param->num_mem_chunks;
15174 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15175
Govind Singhe7f2f342016-05-23 12:12:52 +053015176 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15177 WMITLV_TAG_ARRAY_STRUC,
15178 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015179 param->num_mem_chunks));
15180
15181 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015182 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015183
15184 num_whitelist = sizeof(version_whitelist) /
15185 sizeof(wmi_whitelist_version_info);
15186 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15187 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15188 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15189 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15190 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15191 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15192
Govind Singh87542482016-06-08 19:40:11 +053015193#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015194 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15195 &my_vers,
15196 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15197 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015198#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015199 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15200 __func__,
15201 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15202 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15203 cmd->host_abi_vers.abi_version_ns_0,
15204 cmd->host_abi_vers.abi_version_ns_1,
15205 cmd->host_abi_vers.abi_version_ns_2,
15206 cmd->host_abi_vers.abi_version_ns_3);
15207
15208 /* Save version sent from host -
15209 * Will be used to check ready event
15210 */
Govind Singh87542482016-06-08 19:40:11 +053015211#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015212 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15213 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015214#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015215 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15216 if (QDF_IS_STATUS_ERROR(ret)) {
15217 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15218 ret);
15219 wmi_buf_free(buf);
15220 }
15221 return ret;
15222
Govind Singhe7f2f342016-05-23 12:12:52 +053015223}
15224
15225/**
15226 * save_service_bitmap_tlv() - save service bitmap
15227 * @wmi_handle: wmi handle
15228 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015229 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015230 *
15231 * Return: None
15232 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015233#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015234static
Rajeev Kumar77901472017-02-12 02:12:17 -080015235void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15236 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015237{
15238 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15239 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15240
15241 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15242 param_buf->wmi_service_bitmap,
15243 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015244
15245 if (bitmap_buf)
15246 qdf_mem_copy(bitmap_buf,
15247 param_buf->wmi_service_bitmap,
15248 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015249}
15250#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015251static
Rajeev Kumar77901472017-02-12 02:12:17 -080015252void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15253 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015254{
Rajeev Kumar77901472017-02-12 02:12:17 -080015255 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15256 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015257
Rajeev Kumar77901472017-02-12 02:12:17 -080015258 if (bitmap_buf)
15259 qdf_mem_copy(bitmap_buf,
15260 param_buf->wmi_service_bitmap,
15261 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15262}
Govind Singhe7f2f342016-05-23 12:12:52 +053015263#endif
15264
15265/**
15266 * is_service_enabled_tlv() - Check if service enabled
15267 * @param wmi_handle: wmi handle
15268 * @param service_id: service identifier
15269 *
15270 * Return: 1 enabled, 0 disabled
15271 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015272#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015273static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15274 uint32_t service_id)
15275{
15276 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15277 service_id);
15278}
15279#else
15280static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15281 uint32_t service_id)
15282{
15283 return false;
15284}
15285#endif
15286
15287/**
15288 * extract_service_ready_tlv() - extract service ready event
15289 * @wmi_handle: wmi handle
15290 * @param evt_buf: pointer to received event buffer
15291 * @param cap: pointer to hold target capability information extracted from even
15292 *
15293 * Return: QDF_STATUS_SUCCESS for success or error code
15294 */
15295static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015296 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015297{
15298 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15299 wmi_service_ready_event_fixed_param *ev;
15300
15301
15302 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15303
15304 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15305 if (!ev) {
15306 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15307 return QDF_STATUS_E_FAILURE;
15308 }
15309
15310 cap->phy_capability = ev->phy_capability;
15311 cap->max_frag_entry = ev->max_frag_entry;
15312 cap->num_rf_chains = ev->num_rf_chains;
15313 cap->ht_cap_info = ev->ht_cap_info;
15314 cap->vht_cap_info = ev->vht_cap_info;
15315 cap->vht_supp_mcs = ev->vht_supp_mcs;
15316 cap->hw_min_tx_power = ev->hw_min_tx_power;
15317 cap->hw_max_tx_power = ev->hw_max_tx_power;
15318 cap->sys_cap_info = ev->sys_cap_info;
15319 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15320 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15321 cap->max_num_scan_channels = ev->max_num_scan_channels;
15322 cap->max_supported_macs = ev->max_supported_macs;
15323 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15324 cap->txrx_chainmask = ev->txrx_chainmask;
15325 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15326 cap->num_msdu_desc = ev->num_msdu_desc;
15327
15328 return QDF_STATUS_SUCCESS;
15329}
15330
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015331/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15332 * to host internal WMI_HOST_REGDMN_MODE values.
15333 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15334 * host currently. Add this in the future if required.
15335 * 11AX (Phase II) : 11ax related values are not currently
15336 * advertised separately by FW. As part of phase II regulatory bring-up,
15337 * finalize the advertisement mechanism.
15338 * @target_wireless_mode: target wireless mode received in message
15339 *
15340 * Return: returns the host internal wireless mode.
15341 */
15342static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15343{
15344
15345 uint32_t wireless_modes = 0;
15346
15347 if (target_wireless_mode & REGDMN_MODE_11A)
15348 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15349
15350 if (target_wireless_mode & REGDMN_MODE_TURBO)
15351 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15352
15353 if (target_wireless_mode & REGDMN_MODE_11B)
15354 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15355
15356 if (target_wireless_mode & REGDMN_MODE_PUREG)
15357 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15358
15359 if (target_wireless_mode & REGDMN_MODE_11G)
15360 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15361
15362 if (target_wireless_mode & REGDMN_MODE_108G)
15363 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15364
15365 if (target_wireless_mode & REGDMN_MODE_108A)
15366 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15367
15368 if (target_wireless_mode & REGDMN_MODE_XR)
15369 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15370
15371 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15372 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15373
15374 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15375 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15376
15377 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15378 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15379
15380 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15381 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15382
15383 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15384 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15385
15386 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15387 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15388
15389 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15390 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15391
15392 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15393 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15394
15395 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15396 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15397
15398 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15399 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15400
15401 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15402 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15403
15404 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15405 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15406
15407 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15408 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15409
15410 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15411 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15412
15413 return wireless_modes;
15414}
15415
Govind Singhe7f2f342016-05-23 12:12:52 +053015416/**
15417 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15418 * @wmi_handle: wmi handle
15419 * @param evt_buf: Pointer to event buffer
15420 * @param cap: pointer to hold HAL reg capabilities
15421 *
15422 * Return: QDF_STATUS_SUCCESS for success or error code
15423 */
15424static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015425 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015426{
15427 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15428
15429 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15430
15431 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15432 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015433 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015434
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015435 cap->wireless_modes = convert_wireless_modes_tlv(
15436 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015437
Govind Singhe7f2f342016-05-23 12:12:52 +053015438 return QDF_STATUS_SUCCESS;
15439}
15440
15441/**
15442 * extract_host_mem_req_tlv() - Extract host memory request event
15443 * @wmi_handle: wmi handle
15444 * @param evt_buf: pointer to event buffer
15445 * @param num_entries: pointer to hold number of entries requested
15446 *
15447 * Return: Number of entries requested
15448 */
15449static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15450 void *evt_buf, uint8_t *num_entries)
15451{
15452 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15453 wmi_service_ready_event_fixed_param *ev;
15454
15455 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15456
15457 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15458 if (!ev) {
15459 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15460 return NULL;
15461 }
15462
15463 *num_entries = ev->num_mem_reqs;
15464
15465 return (host_mem_req *)param_buf->mem_reqs;
15466}
15467
15468/**
15469 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15470 * ready function
15471 * @wmi_handle: wmi handle
15472 * @param evt_buf: pointer to event buffer
15473 *
15474 * Return: QDF_STATUS_SUCCESS for success or error code
15475 */
15476static QDF_STATUS
15477save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15478{
15479 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15480 wmi_service_ready_event_fixed_param *ev;
15481
15482
15483 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15484
15485 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15486 if (!ev) {
15487 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15488 return QDF_STATUS_E_FAILURE;
15489 }
15490
Govind Singh87542482016-06-08 19:40:11 +053015491#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015492 /*Save fw version from service ready message */
15493 /*This will be used while sending INIT message */
15494 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15495 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015496#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015497 return QDF_STATUS_SUCCESS;
15498}
15499
15500/**
15501 * ready_extract_init_status_tlv() - Extract init status from ready event
15502 * @wmi_handle: wmi handle
15503 * @param evt_buf: Pointer to event buffer
15504 *
15505 * Return: ready status
15506 */
15507static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15508 void *evt_buf)
15509{
15510 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15511 wmi_ready_event_fixed_param *ev = NULL;
15512
15513
15514 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15515 ev = param_buf->fixed_param;
15516
15517 qdf_print("%s:%d\n", __func__, ev->status);
15518
15519 return ev->status;
15520}
15521
15522/**
15523 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15524 * @wmi_handle: wmi handle
15525 * @param evt_buf: pointer to event buffer
15526 * @param macaddr: Pointer to hold MAC address
15527 *
15528 * Return: QDF_STATUS_SUCCESS for success or error code
15529 */
15530static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15531 void *evt_buf, uint8_t *macaddr)
15532{
15533 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15534 wmi_ready_event_fixed_param *ev = NULL;
15535
15536
15537 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15538 ev = param_buf->fixed_param;
15539
15540 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15541
15542 return QDF_STATUS_SUCCESS;
15543}
15544
15545/**
15546 * extract_dbglog_data_len_tlv() - extract debuglog data length
15547 * @wmi_handle: wmi handle
15548 * @param evt_buf: pointer to event buffer
15549 *
15550 * Return: length
15551 */
15552static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015553 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015554{
15555 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15556
15557 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15558
15559 *len = param_buf->num_bufp;
15560
15561 return param_buf->bufp;
15562}
15563
15564/**
15565 * extract_vdev_start_resp_tlv() - extract vdev start response
15566 * @wmi_handle: wmi handle
15567 * @param evt_buf: pointer to event buffer
15568 * @param vdev_rsp: Pointer to hold vdev response
15569 *
15570 * Return: QDF_STATUS_SUCCESS for success or error code
15571 */
15572static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15573 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15574{
15575 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15576 wmi_vdev_start_response_event_fixed_param *ev;
15577
15578 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15579 if (!param_buf) {
15580 qdf_print("Invalid start response event buffer\n");
15581 return QDF_STATUS_E_INVAL;
15582 }
15583
15584 ev = param_buf->fixed_param;
15585 if (!ev) {
15586 qdf_print("Invalid start response event buffer\n");
15587 return QDF_STATUS_E_INVAL;
15588 }
15589
15590 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15591
15592 vdev_rsp->vdev_id = ev->vdev_id;
15593 vdev_rsp->requestor_id = ev->requestor_id;
15594 vdev_rsp->resp_type = ev->resp_type;
15595 vdev_rsp->status = ev->status;
15596 vdev_rsp->chain_mask = ev->chain_mask;
15597 vdev_rsp->smps_mode = ev->smps_mode;
15598 vdev_rsp->mac_id = ev->mac_id;
15599 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15600 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15601
15602 return QDF_STATUS_SUCCESS;
15603}
15604
15605/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015606 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053015607 * @wmi_handle: wmi handle
15608 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015609 * @param num_vdevs: Pointer to hold num vdev
15610 *
15611 * Return: QDF_STATUS_SUCCESS for success or error code
15612 */
15613static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15614 void *evt_buf, uint32_t *num_vdevs)
15615{
15616 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15617 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15618 uint32_t vdev_map;
15619
15620 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
15621 if (!param_buf) {
15622 qdf_print("Invalid tbtt update ext event buffer\n");
15623 return QDF_STATUS_E_INVAL;
15624 }
15625 tbtt_offset_event = param_buf->fixed_param;
15626 vdev_map = tbtt_offset_event->vdev_map;
15627 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
15628
15629 return QDF_STATUS_SUCCESS;
15630}
15631
15632/**
15633 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
15634 * @wmi_handle: wmi handle
15635 * @param evt_buf: pointer to event buffer
15636 * @param num_vdevs: Pointer to hold num vdev
15637 *
15638 * Return: QDF_STATUS_SUCCESS for success or error code
15639 */
15640static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15641 void *evt_buf, uint32_t *num_vdevs)
15642{
15643 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15644 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
15645
15646 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15647 if (!param_buf) {
15648 qdf_print("Invalid tbtt update ext event buffer\n");
15649 return QDF_STATUS_E_INVAL;
15650 }
15651 tbtt_offset_ext_event = param_buf->fixed_param;
15652
15653 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
15654
15655 return QDF_STATUS_SUCCESS;
15656}
15657
15658/**
15659 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
15660 * @wmi_handle: wmi handle
15661 * @param evt_buf: pointer to event buffer
15662 * @param idx: Index refering to a vdev
15663 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053015664 *
15665 * Return: QDF_STATUS_SUCCESS for success or error code
15666 */
15667static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015668 void *evt_buf, uint8_t idx,
15669 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015670{
15671 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15672 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015673 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053015674
15675 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15676 if (!param_buf) {
15677 qdf_print("Invalid tbtt update event buffer\n");
15678 return QDF_STATUS_E_INVAL;
15679 }
Govind Singhe7f2f342016-05-23 12:12:52 +053015680
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015681 tbtt_offset_event = param_buf->fixed_param;
15682 vdev_map = tbtt_offset_event->vdev_map;
15683 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
15684 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
15685 return QDF_STATUS_E_INVAL;
15686 tbtt_param->tbttoffset =
15687 param_buf->tbttoffset_list[tbtt_param->vdev_id];
15688
15689 return QDF_STATUS_SUCCESS;
15690}
15691
15692/**
15693 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
15694 * @wmi_handle: wmi handle
15695 * @param evt_buf: pointer to event buffer
15696 * @param idx: Index refering to a vdev
15697 * @param tbtt_param: Pointer to tbttoffset event param
15698 *
15699 * Return: QDF_STATUS_SUCCESS for success or error code
15700 */
15701static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
15702 void *evt_buf, uint8_t idx,
15703 struct tbttoffset_params *tbtt_param)
15704{
15705 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15706 wmi_tbtt_offset_info *tbtt_offset_info;
15707
15708 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15709 if (!param_buf) {
15710 qdf_print("Invalid tbtt update event buffer\n");
15711 return QDF_STATUS_E_INVAL;
15712 }
15713 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
15714
15715 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
15716 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053015717
15718 return QDF_STATUS_SUCCESS;
15719}
15720
15721/**
15722 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15723 * @wmi_handle: wmi handle
15724 * @param evt_buf: pointer to event buffer
15725 * @param hdr: Pointer to hold header
15726 * @param bufp: Pointer to hold pointer to rx param buffer
15727 *
15728 * Return: QDF_STATUS_SUCCESS for success or error code
15729 */
15730static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015731 void *evt_buf, struct mgmt_rx_event_params *hdr,
15732 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015733{
15734 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15735 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15736
15737 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15738 if (!param_tlvs) {
15739 WMI_LOGE("Get NULL point message from FW");
15740 return QDF_STATUS_E_INVAL;
15741 }
15742
15743 ev_hdr = param_tlvs->hdr;
15744 if (!hdr) {
15745 WMI_LOGE("Rx event is NULL");
15746 return QDF_STATUS_E_INVAL;
15747 }
15748
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015749 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15750 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015751
15752 hdr->channel = ev_hdr->channel;
15753 hdr->snr = ev_hdr->snr;
15754 hdr->rate = ev_hdr->rate;
15755 hdr->phy_mode = ev_hdr->phy_mode;
15756 hdr->buf_len = ev_hdr->buf_len;
15757 hdr->status = ev_hdr->status;
15758 hdr->flags = ev_hdr->flags;
15759 hdr->rssi = ev_hdr->rssi;
15760 hdr->tsf_delta = ev_hdr->tsf_delta;
15761 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15762
15763 *bufp = param_tlvs->bufp;
15764
15765 return QDF_STATUS_SUCCESS;
15766}
15767
15768/**
15769 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15770 * @wmi_handle: wmi handle
15771 * @param evt_buf: pointer to event buffer
15772 * @param vdev_id: Pointer to hold vdev identifier
15773 *
15774 * Return: QDF_STATUS_SUCCESS for success or error code
15775 */
15776static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15777 void *evt_buf, uint32_t *vdev_id)
15778{
15779 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15780 wmi_vdev_stopped_event_fixed_param *resp_event;
15781
15782 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15783 if (!param_buf) {
15784 WMI_LOGE("Invalid event buffer");
15785 return QDF_STATUS_E_INVAL;
15786 }
15787 resp_event = param_buf->fixed_param;
15788 *vdev_id = resp_event->vdev_id;
15789
15790 return QDF_STATUS_SUCCESS;
15791}
15792
15793/**
15794 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15795 * @wmi_handle: wmi handle
15796 * @param evt_buf: pointer to event buffer
15797 * @param param: Pointer to hold roam param
15798 *
15799 * Return: QDF_STATUS_SUCCESS for success or error code
15800 */
15801static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15802 void *evt_buf, wmi_host_roam_event *param)
15803{
15804 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15805 wmi_roam_event_fixed_param *evt;
15806
15807 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15808 if (!param_buf) {
15809 WMI_LOGE("Invalid roam event buffer");
15810 return QDF_STATUS_E_INVAL;
15811 }
15812
15813 evt = param_buf->fixed_param;
15814 qdf_mem_zero(param, sizeof(*param));
15815
15816 param->vdev_id = evt->vdev_id;
15817 param->reason = evt->reason;
15818 param->rssi = evt->rssi;
15819
15820 return QDF_STATUS_SUCCESS;
15821}
15822
15823/**
15824 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15825 * @wmi_handle: wmi handle
15826 * @param evt_buf: pointer to event buffer
15827 * @param param: Pointer to hold vdev scan param
15828 *
15829 * Return: QDF_STATUS_SUCCESS for success or error code
15830 */
15831static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015832 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015833{
15834 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15835 wmi_scan_event_fixed_param *evt = NULL;
15836
15837 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15838 evt = param_buf->fixed_param;
15839
15840 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015841
Govind Singhe7f2f342016-05-23 12:12:52 +053015842 switch (evt->event) {
15843 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015844 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015845 break;
15846 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015847 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015848 break;
15849 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015850 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015851 break;
15852 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015853 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015854 break;
15855 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015856 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015857 break;
15858 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015859 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015860 break;
15861 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015862 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015863 break;
15864 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015865 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015866 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053015867 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015868 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015869 break;
15870 case WMI_SCAN_EVENT_MAX:
15871 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015872 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015873 break;
15874 };
15875
15876 switch (evt->reason) {
15877 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015878 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015879 break;
15880 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015881 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015882 break;
15883 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015884 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015885 break;
15886 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015887 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015888 break;
15889 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015890 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015891 break;
15892 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015893 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015894 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015895 case WMI_SCAN_REASON_SUSPENDED:
15896 param->reason = SCAN_REASON_SUSPENDED;
15897 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015898 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015899 param->reason = SCAN_REASON_MAX;
15900 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015901 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015902 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015903 break;
15904 };
15905
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015906 param->chan_freq = evt->channel_freq;
15907 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053015908 param->scan_id = evt->scan_id;
15909 param->vdev_id = evt->vdev_id;
15910
15911 return QDF_STATUS_SUCCESS;
15912}
15913
Frank Liu3d5e9992017-03-15 17:51:43 +080015914#ifdef CONVERGED_TDLS_ENABLE
15915/**
15916 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
15917 * @wmi_handle: wmi handle
15918 * @param evt_buf: pointer to event buffer
15919 * @param param: Pointer to hold vdev tdls param
15920 *
15921 * Return: QDF_STATUS_SUCCESS for success or error code
15922 */
15923static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
15924 void *evt_buf, struct tdls_event_info *param)
15925{
15926 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
15927 wmi_tdls_peer_event_fixed_param *evt;
15928
15929 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
15930 if (!param_buf) {
15931 WMI_LOGE("%s: NULL param_buf", __func__);
15932 return QDF_STATUS_E_NULL_VALUE;
15933 }
15934
15935 evt = param_buf->fixed_param;
15936
15937 qdf_mem_zero(param, sizeof(*param));
15938
15939 param->vdev_id = evt->vdev_id;
15940 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
15941 param->peermac.bytes);
15942 switch (evt->peer_status) {
15943 case WMI_TDLS_SHOULD_DISCOVER:
15944 param->message_type = TDLS_SHOULD_DISCOVER;
15945 break;
15946 case WMI_TDLS_SHOULD_TEARDOWN:
15947 param->message_type = TDLS_SHOULD_TEARDOWN;
15948 break;
15949 case WMI_TDLS_PEER_DISCONNECTED:
15950 param->message_type = TDLS_PEER_DISCONNECTED;
15951 break;
15952 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
15953 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
15954 break;
15955 default:
15956 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
15957 __func__, evt->peer_status);
15958 return QDF_STATUS_E_INVAL;
15959 };
15960
15961 switch (evt->peer_reason) {
15962 case WMI_TDLS_TEARDOWN_REASON_TX:
15963 param->peer_reason = TDLS_TEARDOWN_TX;
15964 break;
15965 case WMI_TDLS_TEARDOWN_REASON_RSSI:
15966 param->peer_reason = TDLS_TEARDOWN_RSSI;
15967 break;
15968 case WMI_TDLS_TEARDOWN_REASON_SCAN:
15969 param->peer_reason = TDLS_TEARDOWN_SCAN;
15970 break;
15971 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
15972 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
15973 break;
15974 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
15975 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
15976 break;
15977 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
15978 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
15979 break;
15980 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
15981 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
15982 break;
15983 case WMI_TDLS_ENTER_BUF_STA:
15984 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
15985 break;
15986 case WMI_TDLS_EXIT_BUF_STA:
15987 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
15988 break;
15989 case WMI_TDLS_ENTER_BT_BUSY_MODE:
15990 param->peer_reason = TDLS_ENTER_BT_BUSY;
15991 break;
15992 case WMI_TDLS_EXIT_BT_BUSY_MODE:
15993 param->peer_reason = TDLS_EXIT_BT_BUSY;
15994 break;
15995 case WMI_TDLS_SCAN_STARTED_EVENT:
15996 param->peer_reason = TDLS_SCAN_STARTED;
15997 break;
15998 case WMI_TDLS_SCAN_COMPLETED_EVENT:
15999 param->peer_reason = TDLS_SCAN_COMPLETED;
16000 break;
16001
16002 default:
16003 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16004 __func__, evt->peer_reason, evt->peer_status);
16005 return QDF_STATUS_E_INVAL;
16006 };
16007
16008 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16009 __func__, param->peermac.bytes, param->message_type,
16010 param->peer_reason, param->vdev_id);
16011
16012 return QDF_STATUS_SUCCESS;
16013}
16014#endif
16015
Govind Singhe7f2f342016-05-23 12:12:52 +053016016/**
16017 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16018 * @wmi_handle: wmi handle
16019 * @param evt_buf: pointer to event buffer
16020 * @param param: Pointer to hold MGMT TX completion params
16021 *
16022 * Return: QDF_STATUS_SUCCESS for success or error code
16023 */
16024static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16025 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16026{
16027 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16028 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16029
16030 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16031 evt_buf;
16032 if (!param_buf) {
16033 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16034 return QDF_STATUS_E_INVAL;
16035 }
16036 cmpl_params = param_buf->fixed_param;
16037
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016038 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16039 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016040 param->desc_id = cmpl_params->desc_id;
16041 param->status = cmpl_params->status;
16042
16043 return QDF_STATUS_SUCCESS;
16044}
16045
16046/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016047 * extract_offchan_data_tx_compl_param_tlv() -
16048 * extract Offchan data tx completion event params
16049 * @wmi_handle: wmi handle
16050 * @param evt_buf: pointer to event buffer
16051 * @param param: Pointer to hold offchan data TX completion params
16052 *
16053 * Return: QDF_STATUS_SUCCESS for success or error code
16054 */
16055static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16056 wmi_unified_t wmi_handle, void *evt_buf,
16057 struct wmi_host_offchan_data_tx_compl_event *param)
16058{
16059 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16060 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16061
16062 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16063 evt_buf;
16064 if (!param_buf) {
16065 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16066 return QDF_STATUS_E_INVAL;
16067 }
16068 cmpl_params = param_buf->fixed_param;
16069
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016070 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16071 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016072 param->desc_id = cmpl_params->desc_id;
16073 param->status = cmpl_params->status;
16074
16075 return QDF_STATUS_SUCCESS;
16076}
16077
16078/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016079 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16080 * status tlv
16081 * @wmi_handle: wmi handle
16082 * @param evt_buf: pointer to event buffer
16083 * @param param: Pointer to hold csa switch count status event param
16084 *
16085 * Return: QDF_STATUS_SUCCESS for success or error code
16086 */
16087static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16088 wmi_unified_t wmi_handle,
16089 void *evt_buf,
16090 struct pdev_csa_switch_count_status *param)
16091{
16092 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16093 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16094
16095 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16096 evt_buf;
16097 if (!param_buf) {
16098 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16099 return QDF_STATUS_E_INVAL;
16100 }
16101
16102 csa_status = param_buf->fixed_param;
16103
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016104 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16105 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016106 param->current_switch_count = csa_status->current_switch_count;
16107 param->num_vdevs = csa_status->num_vdevs;
16108 param->vdev_ids = param_buf->vdev_ids;
16109
16110 return QDF_STATUS_SUCCESS;
16111}
16112
16113/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016114 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016115 * @wmi_handle: wmi handle
16116 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016117 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016118 *
16119 * Return: QDF_STATUS_SUCCESS for success or error code
16120 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016121static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16122 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016123{
16124 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16125 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016126 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016127
16128 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16129 if (!param_buf) {
16130 WMI_LOGE("Invalid swba event buffer");
16131 return QDF_STATUS_E_INVAL;
16132 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016133
Govind Singhe7f2f342016-05-23 12:12:52 +053016134 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016135 *num_vdevs = swba_event->num_vdevs;
16136 if (!(*num_vdevs)) {
16137 vdev_map = swba_event->vdev_map;
16138 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16139 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016140
16141 return QDF_STATUS_SUCCESS;
16142}
16143
16144/**
16145 * extract_swba_tim_info_tlv() - extract swba tim info from event
16146 * @wmi_handle: wmi handle
16147 * @param evt_buf: pointer to event buffer
16148 * @param idx: Index to bcn info
16149 * @param tim_info: Pointer to hold tim info
16150 *
16151 * Return: QDF_STATUS_SUCCESS for success or error code
16152 */
16153static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16154 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16155{
16156 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16157 wmi_tim_info *tim_info_ev;
16158
16159 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16160 if (!param_buf) {
16161 WMI_LOGE("Invalid swba event buffer");
16162 return QDF_STATUS_E_INVAL;
16163 }
16164
16165 tim_info_ev = &param_buf->tim_info[idx];
16166
16167 tim_info->tim_len = tim_info_ev->tim_len;
16168 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16169 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16170 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16171 tim_info->tim_changed = tim_info_ev->tim_changed;
16172 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016173 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016174
16175 return QDF_STATUS_SUCCESS;
16176}
16177
16178/**
16179 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16180 * @wmi_handle: wmi handle
16181 * @param evt_buf: pointer to event buffer
16182 * @param idx: Index to bcn info
16183 * @param p2p_desc: Pointer to hold p2p NoA info
16184 *
16185 * Return: QDF_STATUS_SUCCESS for success or error code
16186 */
16187static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16188 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16189{
16190 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16191 wmi_p2p_noa_info *p2p_noa_info;
16192 uint8_t i = 0;
16193
16194 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16195 if (!param_buf) {
16196 WMI_LOGE("Invalid swba event buffer");
16197 return QDF_STATUS_E_INVAL;
16198 }
16199
16200 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16201
16202 p2p_desc->modified = false;
16203 p2p_desc->num_descriptors = 0;
16204 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16205 p2p_desc->modified = true;
16206 p2p_desc->index =
16207 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16208 p2p_desc->oppPS =
16209 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16210 p2p_desc->ctwindow =
16211 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16212 p2p_desc->num_descriptors =
16213 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16214 (p2p_noa_info);
16215 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16216 p2p_desc->noa_descriptors[i].type_count =
16217 (uint8_t) p2p_noa_info->noa_descriptors[i].
16218 type_count;
16219 p2p_desc->noa_descriptors[i].duration =
16220 p2p_noa_info->noa_descriptors[i].duration;
16221 p2p_desc->noa_descriptors[i].interval =
16222 p2p_noa_info->noa_descriptors[i].interval;
16223 p2p_desc->noa_descriptors[i].start_time =
16224 p2p_noa_info->noa_descriptors[i].start_time;
16225 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016226 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016227 }
16228
16229 return QDF_STATUS_SUCCESS;
16230}
16231
Wu Gaocd3a8512017-03-13 20:17:34 +080016232#ifdef CONVERGED_P2P_ENABLE
16233/**
16234 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16235 * @wmi_handle: wmi handle
16236 * @param evt_buf: pointer to event buffer
16237 * @param param: Pointer to hold p2p noa info
16238 *
16239 * Return: QDF_STATUS_SUCCESS for success or error code
16240 */
16241static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16242 wmi_unified_t wmi_handle, void *evt_buf,
16243 struct p2p_noa_info *param)
16244{
16245 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16246 wmi_p2p_noa_event_fixed_param *fixed_param;
16247 uint8_t i;
16248 wmi_p2p_noa_info *wmi_noa_info;
16249 uint8_t *buf_ptr;
16250 uint32_t descriptors;
16251
16252 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16253 if (!param_tlvs) {
16254 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16255 return QDF_STATUS_E_INVAL;
16256 }
16257
16258 if (!param) {
16259 WMI_LOGE("noa information param is null");
16260 return QDF_STATUS_E_INVAL;
16261 }
16262
16263 fixed_param = param_tlvs->fixed_param;
16264 buf_ptr = (uint8_t *) fixed_param;
16265 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16266 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16267
16268 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16269 WMI_LOGE("%s: noa attr is not modified", __func__);
16270 return QDF_STATUS_E_INVAL;
16271 }
16272
16273 param->vdev_id = fixed_param->vdev_id;
16274 param->index =
16275 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16276 param->opps_ps =
16277 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16278 param->ct_window =
16279 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16280 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16281 param->num_desc = (uint8_t) descriptors;
16282
16283 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16284 param->index, param->opps_ps, param->ct_window,
16285 param->num_desc);
16286 for (i = 0; i < param->num_desc; i++) {
16287 param->noa_desc[i].type_count =
16288 (uint8_t) wmi_noa_info->noa_descriptors[i].
16289 type_count;
16290 param->noa_desc[i].duration =
16291 wmi_noa_info->noa_descriptors[i].duration;
16292 param->noa_desc[i].interval =
16293 wmi_noa_info->noa_descriptors[i].interval;
16294 param->noa_desc[i].start_time =
16295 wmi_noa_info->noa_descriptors[i].start_time;
16296 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16297 __func__, i, param->noa_desc[i].type_count,
16298 param->noa_desc[i].duration,
16299 param->noa_desc[i].interval,
16300 param->noa_desc[i].start_time);
16301 }
16302
16303 return QDF_STATUS_SUCCESS;
16304}
16305
16306/**
16307 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16308 * information from event
16309 * @wmi_handle: wmi handle
16310 * @param evt_buf: pointer to event buffer
16311 * @param param: Pointer to hold p2p lo stop event information
16312 *
16313 * Return: QDF_STATUS_SUCCESS for success or error code
16314 */
16315static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16316 wmi_unified_t wmi_handle, void *evt_buf,
16317 struct p2p_lo_event *param)
16318{
16319 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16320 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16321
16322 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16323 evt_buf;
16324 if (!param_tlvs) {
16325 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16326 return QDF_STATUS_E_INVAL;
16327 }
16328
16329 if (!param) {
16330 WMI_LOGE("lo stop event param is null");
16331 return QDF_STATUS_E_INVAL;
16332 }
16333
16334 lo_param = param_tlvs->fixed_param;
16335 param->vdev_id = lo_param->vdev_id;
16336 param->reason_code = lo_param->reason;
16337 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16338 param->vdev_id, param->reason_code);
16339
16340 return QDF_STATUS_SUCCESS;
16341}
16342#endif /* End of CONVERGED_P2P_ENABLE */
16343
Govind Singhe7f2f342016-05-23 12:12:52 +053016344/**
16345 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16346 * @wmi_handle: wmi handle
16347 * @param evt_buf: pointer to event buffer
16348 * @param ev: Pointer to hold peer param
16349 *
16350 * Return: QDF_STATUS_SUCCESS for success or error code
16351 */
16352static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16353 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16354{
16355 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16356 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16357
16358 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16359 kickout_event = param_buf->fixed_param;
16360
16361 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16362 ev->peer_macaddr);
16363
16364 ev->reason = kickout_event->reason;
16365 ev->rssi = kickout_event->rssi;
16366
16367 return QDF_STATUS_SUCCESS;
16368}
16369
16370/**
16371 * extract_all_stats_counts_tlv() - extract all stats count from event
16372 * @wmi_handle: wmi handle
16373 * @param evt_buf: pointer to event buffer
16374 * @param stats_param: Pointer to hold stats count
16375 *
16376 * Return: QDF_STATUS_SUCCESS for success or error code
16377 */
16378static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16379 void *evt_buf, wmi_host_stats_event *stats_param)
16380{
16381 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16382 wmi_stats_event_fixed_param *ev;
16383
16384 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16385
16386 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16387 if (!ev) {
16388 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16389 return QDF_STATUS_E_FAILURE;
16390 }
16391
16392 switch (ev->stats_id) {
16393 case WMI_REQUEST_PEER_STAT:
16394 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16395 break;
16396
16397 case WMI_REQUEST_AP_STAT:
16398 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16399 break;
16400
16401 case WMI_REQUEST_PDEV_STAT:
16402 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16403 break;
16404
16405 case WMI_REQUEST_VDEV_STAT:
16406 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16407 break;
16408
16409 case WMI_REQUEST_BCNFLT_STAT:
16410 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16411 break;
16412
16413 case WMI_REQUEST_VDEV_RATE_STAT:
16414 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16415 break;
16416
16417 default:
16418 stats_param->stats_id = 0;
16419 break;
16420
16421 }
16422
16423 stats_param->num_pdev_stats = ev->num_pdev_stats;
16424 stats_param->num_pdev_ext_stats = 0;
16425 stats_param->num_vdev_stats = ev->num_vdev_stats;
16426 stats_param->num_peer_stats = ev->num_peer_stats;
16427 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16428 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016429 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016430
16431 return QDF_STATUS_SUCCESS;
16432}
16433
16434/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016435 * extract_pdev_tx_stats() - extract pdev tx stats from event
16436 */
16437static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16438{
16439 /* Tx Stats */
16440 tx->comp_queued = tx_stats->comp_queued;
16441 tx->comp_delivered = tx_stats->comp_delivered;
16442 tx->msdu_enqued = tx_stats->msdu_enqued;
16443 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16444 tx->wmm_drop = tx_stats->wmm_drop;
16445 tx->local_enqued = tx_stats->local_enqued;
16446 tx->local_freed = tx_stats->local_freed;
16447 tx->hw_queued = tx_stats->hw_queued;
16448 tx->hw_reaped = tx_stats->hw_reaped;
16449 tx->underrun = tx_stats->underrun;
16450 tx->tx_abort = tx_stats->tx_abort;
16451 tx->mpdus_requed = tx_stats->mpdus_requed;
16452 tx->data_rc = tx_stats->data_rc;
16453 tx->self_triggers = tx_stats->self_triggers;
16454 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16455 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16456 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16457 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16458 tx->pdev_resets = tx_stats->pdev_resets;
16459 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16460 tx->phy_underrun = tx_stats->phy_underrun;
16461 tx->txop_ovf = tx_stats->txop_ovf;
16462
16463 return;
16464}
16465
16466
16467/**
16468 * extract_pdev_rx_stats() - extract pdev rx stats from event
16469 */
16470static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16471{
16472 /* Rx Stats */
16473 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16474 rx->status_rcvd = rx_stats->status_rcvd;
16475 rx->r0_frags = rx_stats->r0_frags;
16476 rx->r1_frags = rx_stats->r1_frags;
16477 rx->r2_frags = rx_stats->r2_frags;
16478 /* Only TLV */
16479 rx->r3_frags = 0;
16480 rx->htt_msdus = rx_stats->htt_msdus;
16481 rx->htt_mpdus = rx_stats->htt_mpdus;
16482 rx->loc_msdus = rx_stats->loc_msdus;
16483 rx->loc_mpdus = rx_stats->loc_mpdus;
16484 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16485 rx->phy_errs = rx_stats->phy_errs;
16486 rx->phy_err_drop = rx_stats->phy_err_drop;
16487 rx->mpdu_errs = rx_stats->mpdu_errs;
16488
16489 return;
16490}
16491
16492/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016493 * extract_pdev_stats_tlv() - extract pdev stats from event
16494 * @wmi_handle: wmi handle
16495 * @param evt_buf: pointer to event buffer
16496 * @param index: Index into pdev stats
16497 * @param pdev_stats: Pointer to hold pdev stats
16498 *
16499 * Return: QDF_STATUS_SUCCESS for success or error code
16500 */
16501static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16502 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16503{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016504 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16505 wmi_stats_event_fixed_param *ev_param;
16506 uint8_t *data;
16507
16508 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16509 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16510
16511 data = param_buf->data;
16512
16513 if (index < ev_param->num_pdev_stats) {
16514 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
16515 (index * sizeof(wmi_pdev_stats)));
16516
16517 pdev_stats->chan_nf = ev->chan_nf;
16518 pdev_stats->tx_frame_count = ev->tx_frame_count;
16519 pdev_stats->rx_frame_count = ev->rx_frame_count;
16520 pdev_stats->rx_clear_count = ev->rx_clear_count;
16521 pdev_stats->cycle_count = ev->cycle_count;
16522 pdev_stats->phy_err_count = ev->phy_err_count;
16523 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
16524
16525 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
16526 &(ev->pdev_stats.tx));
16527 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
16528 &(ev->pdev_stats.rx));
16529 }
16530
Govind Singhe7f2f342016-05-23 12:12:52 +053016531 return QDF_STATUS_SUCCESS;
16532}
16533
16534/**
16535 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
16536 * @wmi_handle: wmi handle
16537 * @param evt_buf: pointer to event buffer
16538 * @param index: Index into extended pdev stats
16539 * @param pdev_ext_stats: Pointer to hold extended pdev stats
16540 *
16541 * Return: QDF_STATUS_SUCCESS for success or error code
16542 */
16543static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
16544 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
16545{
16546 return QDF_STATUS_SUCCESS;
16547}
16548
16549/**
16550 * extract_vdev_stats_tlv() - extract vdev stats from event
16551 * @wmi_handle: wmi handle
16552 * @param evt_buf: pointer to event buffer
16553 * @param index: Index into vdev stats
16554 * @param vdev_stats: Pointer to hold vdev stats
16555 *
16556 * Return: QDF_STATUS_SUCCESS for success or error code
16557 */
16558static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
16559 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
16560{
16561 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16562 wmi_stats_event_fixed_param *ev_param;
16563 uint8_t *data;
16564
16565 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16566 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16567 data = (uint8_t *) param_buf->data;
16568
16569 if (index < ev_param->num_vdev_stats) {
16570 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
16571 ((ev_param->num_pdev_stats) *
16572 sizeof(wmi_pdev_stats)) +
16573 (index * sizeof(wmi_vdev_stats)));
16574
16575 vdev_stats->vdev_id = ev->vdev_id;
16576 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
16577 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
16578
16579 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
16580 sizeof(ev->tx_frm_cnt));
16581 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
16582 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
16583 ev->multiple_retry_cnt,
16584 sizeof(ev->multiple_retry_cnt));
16585 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
16586 sizeof(ev->fail_cnt));
16587 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
16588 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
16589 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
16590 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
16591 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
16592 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
16593 sizeof(ev->tx_rate_history));
16594 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
16595 sizeof(ev->bcn_rssi_history));
16596
16597 }
16598
16599 return QDF_STATUS_SUCCESS;
16600}
16601
16602/**
16603 * extract_peer_stats_tlv() - extract peer stats from event
16604 * @wmi_handle: wmi handle
16605 * @param evt_buf: pointer to event buffer
16606 * @param index: Index into peer stats
16607 * @param peer_stats: Pointer to hold peer stats
16608 *
16609 * Return: QDF_STATUS_SUCCESS for success or error code
16610 */
16611static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
16612 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
16613{
16614 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16615 wmi_stats_event_fixed_param *ev_param;
16616 uint8_t *data;
16617
16618 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16619 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16620 data = (uint8_t *) param_buf->data;
16621
16622 if (index < ev_param->num_peer_stats) {
16623 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
16624 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16625 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16626 (index * sizeof(wmi_peer_stats)));
16627
16628 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
16629
16630 OS_MEMCPY(&(peer_stats->peer_macaddr),
16631 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
16632
16633 peer_stats->peer_rssi = ev->peer_rssi;
16634 peer_stats->peer_tx_rate = ev->peer_tx_rate;
16635 peer_stats->peer_rx_rate = ev->peer_rx_rate;
16636 }
16637
16638 return QDF_STATUS_SUCCESS;
16639}
16640
16641/**
16642 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
16643 * @wmi_handle: wmi handle
16644 * @param evt_buf: pointer to event buffer
16645 * @param index: Index into bcn fault stats
16646 * @param bcnflt_stats: Pointer to hold bcn fault stats
16647 *
16648 * Return: QDF_STATUS_SUCCESS for success or error code
16649 */
16650static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
16651 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
16652{
16653 return QDF_STATUS_SUCCESS;
16654}
16655
16656/**
16657 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
16658 * @wmi_handle: wmi handle
16659 * @param evt_buf: pointer to event buffer
16660 * @param index: Index into extended peer stats
16661 * @param peer_extd_stats: Pointer to hold extended peer stats
16662 *
16663 * Return: QDF_STATUS_SUCCESS for success or error code
16664 */
16665static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
16666 void *evt_buf, uint32_t index,
16667 wmi_host_peer_extd_stats *peer_extd_stats)
16668{
16669 return QDF_STATUS_SUCCESS;
16670}
16671
16672/**
16673 * extract_chan_stats_tlv() - extract chan stats from event
16674 * @wmi_handle: wmi handle
16675 * @param evt_buf: pointer to event buffer
16676 * @param index: Index into chan stats
16677 * @param vdev_extd_stats: Pointer to hold chan stats
16678 *
16679 * Return: QDF_STATUS_SUCCESS for success or error code
16680 */
16681static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
16682 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
16683{
16684 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16685 wmi_stats_event_fixed_param *ev_param;
16686 uint8_t *data;
16687
16688 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16689 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16690 data = (uint8_t *) param_buf->data;
16691
16692 if (index < ev_param->num_chan_stats) {
16693 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
16694 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16695 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16696 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
16697 (index * sizeof(wmi_chan_stats)));
16698
16699
16700 /* Non-TLV doesnt have num_chan_stats */
16701 chan_stats->chan_mhz = ev->chan_mhz;
16702 chan_stats->sampling_period_us = ev->sampling_period_us;
16703 chan_stats->rx_clear_count = ev->rx_clear_count;
16704 chan_stats->tx_duration_us = ev->tx_duration_us;
16705 chan_stats->rx_duration_us = ev->rx_duration_us;
16706 }
16707
16708 return QDF_STATUS_SUCCESS;
16709}
16710
16711/**
16712 * extract_profile_ctx_tlv() - extract profile context from event
16713 * @wmi_handle: wmi handle
16714 * @param evt_buf: pointer to event buffer
16715 * @idx: profile stats index to extract
16716 * @param profile_ctx: Pointer to hold profile context
16717 *
16718 * Return: QDF_STATUS_SUCCESS for success or error code
16719 */
16720static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
16721 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
16722{
16723 return QDF_STATUS_SUCCESS;
16724}
16725
16726/**
16727 * extract_profile_data_tlv() - extract profile data from event
16728 * @wmi_handle: wmi handle
16729 * @param evt_buf: pointer to event buffer
16730 * @param profile_data: Pointer to hold profile data
16731 *
16732 * Return: QDF_STATUS_SUCCESS for success or error code
16733 */
16734static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
16735 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
16736{
16737
16738 return QDF_STATUS_SUCCESS;
16739}
16740
16741/**
16742 * extract_chan_info_event_tlv() - extract chan information from event
16743 * @wmi_handle: wmi handle
16744 * @param evt_buf: pointer to event buffer
16745 * @param chan_info: Pointer to hold chan information
16746 *
16747 * Return: QDF_STATUS_SUCCESS for success or error code
16748 */
16749static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
16750 void *evt_buf, wmi_host_chan_info_event *chan_info)
16751{
16752 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
16753 wmi_chan_info_event_fixed_param *ev;
16754
16755 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
16756
16757 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
16758 if (!ev) {
16759 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
16760 return QDF_STATUS_E_FAILURE;
16761 }
16762
16763 chan_info->err_code = ev->err_code;
16764 chan_info->freq = ev->freq;
16765 chan_info->cmd_flags = ev->cmd_flags;
16766 chan_info->noise_floor = ev->noise_floor;
16767 chan_info->rx_clear_count = ev->rx_clear_count;
16768 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053016769 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
16770 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
16771 ev->vdev_id, WLAN_SCAN_ID);
Govind Singhe7f2f342016-05-23 12:12:52 +053016772
16773 return QDF_STATUS_SUCCESS;
16774}
16775
16776/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016777 * extract_pdev_utf_event_tlv() - extract UTF data info from event
16778 * @wmi_handle: WMI handle
16779 * @param evt_buf: Pointer to event buffer
16780 * @param param: Pointer to hold data
16781 *
16782 * Return : QDF_STATUS_SUCCESS for success or error code
16783 */
16784static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16785 uint8_t *evt_buf,
16786 struct wmi_host_pdev_utf_event *event)
16787{
16788 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016789 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016790
16791 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
16792 event->data = param_buf->data;
16793 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016794 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053016795 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016796 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053016797 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016798
16799 return QDF_STATUS_SUCCESS;
16800}
Govind Singhe7f2f342016-05-23 12:12:52 +053016801
Kiran Venkatappa06520822016-08-10 23:55:40 +053016802/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016803 * extract_chainmask_tables_tlv() - extract chain mask tables from event
16804 * @wmi_handle: wmi handle
16805 * @param evt_buf: pointer to event buffer
16806 * @param param: Pointer to hold evt buf
16807 *
16808 * Return: QDF_STATUS_SUCCESS for success or error code
16809 */
16810static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
16811 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
16812{
16813 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16814 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
16815 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16816 uint8_t i = 0, j = 0;
16817
16818 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16819 if (!param_buf)
16820 return QDF_STATUS_E_INVAL;
16821
16822 hw_caps = param_buf->soc_hw_mode_caps;
16823 if (!hw_caps)
16824 return QDF_STATUS_E_INVAL;
16825
16826 if (!hw_caps->num_chainmask_tables)
16827 return QDF_STATUS_E_INVAL;
16828
16829 chainmask_caps = param_buf->mac_phy_chainmask_caps;
16830
16831 if (chainmask_caps == NULL)
16832 return QDF_STATUS_E_INVAL;
16833
16834 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16835
16836 qdf_print("Dumping chain mask combo data for table : %d\n", i);
16837 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
16838
16839 chainmask_table[i].cap_list[j].chainmask =
16840 chainmask_caps->chainmask;
16841
16842 chainmask_table[i].cap_list[j].supports_chan_width_20 =
16843 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
16844
16845 chainmask_table[i].cap_list[j].supports_chan_width_40 =
16846 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
16847
16848 chainmask_table[i].cap_list[j].supports_chan_width_80 =
16849 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
16850
16851 chainmask_table[i].cap_list[j].supports_chan_width_160 =
16852 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
16853
16854 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
16855 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
16856
16857 chainmask_table[i].cap_list[j].chain_mask_2G =
16858 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
16859
16860 chainmask_table[i].cap_list[j].chain_mask_5G =
16861 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
16862
16863 chainmask_table[i].cap_list[j].chain_mask_tx =
16864 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
16865
16866 chainmask_table[i].cap_list[j].chain_mask_rx =
16867 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
16868
16869 chainmask_table[i].cap_list[j].supports_aDFS =
16870 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
16871
16872 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
16873 chainmask_caps->supported_flags,
16874 chainmask_caps->chainmask
16875 );
16876 chainmask_caps++;
16877 }
16878 }
16879
16880 return QDF_STATUS_SUCCESS;
16881}
16882
16883/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053016884 * extract_service_ready_ext_tlv() - extract basic extended service ready params
16885 * from event
16886 * @wmi_handle: wmi handle
16887 * @param evt_buf: pointer to event buffer
16888 * @param param: Pointer to hold evt buf
16889 *
16890 * Return: QDF_STATUS_SUCCESS for success or error code
16891 */
16892static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016893 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016894{
16895 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16896 wmi_service_ready_ext_event_fixed_param *ev;
16897 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16898 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016899 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
16900 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016901
16902 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16903 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016904 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016905
16906 ev = param_buf->fixed_param;
16907 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016908 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016909
16910 /* Move this to host based bitmap */
16911 param->default_conc_scan_config_bits =
16912 ev->default_conc_scan_config_bits;
16913 param->default_fw_config_bits = ev->default_fw_config_bits;
16914 param->he_cap_info = ev->he_cap_info;
16915 param->mpdu_density = ev->mpdu_density;
16916 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
16917 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
16918
16919 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016920 if (hw_caps)
16921 param->num_hw_modes = hw_caps->num_hw_modes;
16922 else
16923 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016924
16925 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016926 if (reg_caps)
16927 param->num_phy = reg_caps->num_phy;
16928 else
16929 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016930
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016931 if (hw_caps) {
16932 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
16933 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
16934 } else
16935 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016936
16937 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
16938
16939 if (chain_mask_combo == NULL)
16940 return QDF_STATUS_SUCCESS;
16941
16942 qdf_print("Dumping chain mask combo data\n");
16943
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016944 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016945
16946 qdf_print("table_id : %d Num valid chainmasks: %d\n",
16947 chain_mask_combo->chainmask_table_id,
16948 chain_mask_combo->num_valid_chainmask
16949 );
16950
16951 param->chainmask_table[i].table_id =
16952 chain_mask_combo->chainmask_table_id;
16953 param->chainmask_table[i].num_valid_chainmasks =
16954 chain_mask_combo->num_valid_chainmask;
16955 chain_mask_combo++;
16956 }
16957 qdf_print("chain mask combo end\n");
16958
Kiran Venkatappa06520822016-08-10 23:55:40 +053016959 return QDF_STATUS_SUCCESS;
16960}
16961
16962/**
16963 * extract_hw_mode_cap_service_ready_ext_tlv() -
16964 * extract HW mode cap from service ready event
16965 * @wmi_handle: wmi handle
16966 * @param evt_buf: pointer to event buffer
16967 * @param param: Pointer to hold evt buf
16968 * @param hw_mode_idx: hw mode idx should be less than num_mode
16969 *
16970 * Return: QDF_STATUS_SUCCESS for success or error code
16971 */
16972static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
16973 wmi_unified_t wmi_handle,
16974 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016975 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016976{
16977 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16978 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16979
16980 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16981 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016982 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016983
16984 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016985 if (!hw_caps)
16986 return QDF_STATUS_E_INVAL;
16987
Kiran Venkatappa06520822016-08-10 23:55:40 +053016988 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016989 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016990
16991 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
16992 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
16993
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016994 param->hw_mode_config_type =
16995 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
16996
Kiran Venkatappa06520822016-08-10 23:55:40 +053016997 return QDF_STATUS_SUCCESS;
16998}
16999
17000/**
17001 * extract_mac_phy_cap_service_ready_ext_tlv() -
17002 * extract MAC phy cap from service ready event
17003 * @wmi_handle: wmi handle
17004 * @param evt_buf: pointer to event buffer
17005 * @param param: Pointer to hold evt buf
17006 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017007 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017008 *
17009 * Return: QDF_STATUS_SUCCESS for success or error code
17010 */
17011static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17012 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017013 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017014 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017015{
17016 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017017 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017018 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17019 uint32_t phy_map;
17020 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017021
17022 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17023 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017024 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017025
17026 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017027 if (!hw_caps)
17028 return QDF_STATUS_E_INVAL;
17029
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017030 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17031 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17032 break;
17033
17034 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17035 while (phy_map) {
17036 phy_map >>= 1;
17037 phy_idx++;
17038 }
17039 }
17040
17041 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017042 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017043
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017044 phy_idx += phy_id;
17045 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017046 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017047
17048 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017049
17050 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017051 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17052 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017053 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017054 param->supports_11b =
17055 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17056 param->supports_11g =
17057 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17058 param->supports_11a =
17059 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17060 param->supports_11n =
17061 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17062 param->supports_11ac =
17063 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17064 param->supports_11ax =
17065 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017066
17067 param->supported_bands = mac_phy_caps->supported_bands;
17068 param->ampdu_density = mac_phy_caps->ampdu_density;
17069 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17070 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17071 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17072 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17073 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17074 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17075 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17076 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17077 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17078 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17079 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17080 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17081 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17082 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17083 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17084 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017085 qdf_mem_copy(&param->he_cap_phy_info_2G,
17086 &mac_phy_caps->he_cap_phy_info_2G,
17087 sizeof(param->he_cap_phy_info_2G));
17088 qdf_mem_copy(&param->he_cap_phy_info_5G,
17089 &mac_phy_caps->he_cap_phy_info_5G,
17090 sizeof(param->he_cap_phy_info_5G));
17091 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17092 sizeof(param->he_ppet2G));
17093 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17094 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017095 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017096
17097 return QDF_STATUS_SUCCESS;
17098}
17099
17100/**
17101 * extract_reg_cap_service_ready_ext_tlv() -
17102 * extract REG cap from service ready event
17103 * @wmi_handle: wmi handle
17104 * @param evt_buf: pointer to event buffer
17105 * @param param: Pointer to hold evt buf
17106 * @param phy_idx: phy idx should be less than num_mode
17107 *
17108 * Return: QDF_STATUS_SUCCESS for success or error code
17109 */
17110static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17111 wmi_unified_t wmi_handle,
17112 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017113 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017114{
17115 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17116 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17117 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17118
17119 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17120 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017121 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017122
17123 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017124 if (!reg_caps)
17125 return QDF_STATUS_E_INVAL;
17126
Kiran Venkatappa06520822016-08-10 23:55:40 +053017127 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017128 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017129
17130 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17131
17132 param->phy_id = ext_reg_cap->phy_id;
17133 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17134 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17135 param->regcap1 = ext_reg_cap->regcap1;
17136 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017137 param->wireless_modes = convert_wireless_modes_tlv(
17138 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017139 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17140 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17141 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17142 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17143
17144 return QDF_STATUS_SUCCESS;
17145}
17146
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017147/**
17148 * extract_dcs_interference_type_tlv() - extract dcs interference type
17149 * from event
17150 * @wmi_handle: wmi handle
17151 * @param evt_buf: pointer to event buffer
17152 * @param param: Pointer to hold dcs interference param
17153 *
17154 * Return: 0 for success or error code
17155 */
17156static QDF_STATUS extract_dcs_interference_type_tlv(
17157 wmi_unified_t wmi_handle,
17158 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17159{
17160 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17161
17162 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17163 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017164 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017165
17166 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017167 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17168 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017169
17170 return QDF_STATUS_SUCCESS;
17171}
17172
17173/*
17174 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17175 * @wmi_handle: wmi handle
17176 * @param evt_buf: pointer to event buffer
17177 * @param cw_int: Pointer to hold cw interference
17178 *
17179 * Return: 0 for success or error code
17180 */
17181static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17182 void *evt_buf,
17183 wmi_host_ath_dcs_cw_int *cw_int)
17184{
17185 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17186 wlan_dcs_cw_int *ev;
17187
17188 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17189 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017190 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017191
17192 ev = param_buf->cw_int;
17193
17194 cw_int->channel = ev->channel;
17195
17196 return QDF_STATUS_SUCCESS;
17197}
17198
17199/**
17200 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17201 * @wmi_handle: wmi handle
17202 * @param evt_buf: pointer to event buffer
17203 * @param wlan_stat: Pointer to hold wlan stats
17204 *
17205 * Return: 0 for success or error code
17206 */
17207static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17208 void *evt_buf,
17209 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17210{
17211 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17212 wlan_dcs_im_tgt_stats_t *ev;
17213
17214 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17215 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017216 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017217
17218 ev = param_buf->wlan_stat;
17219 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17220 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17221 wlan_stat->tx_waste_time = ev->tx_waste_time;
17222 wlan_stat->rx_time = ev->rx_time;
17223 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17224 wlan_stat->mib_stats.listen_time = ev->listen_time;
17225 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17226 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17227 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17228 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17229 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17230 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17231 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17232 wlan_stat->chan_nf = ev->chan_nf;
17233 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17234
17235 return QDF_STATUS_SUCCESS;
17236}
17237
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017238/**
17239 * extract_thermal_stats_tlv() - extract thermal stats from event
17240 * @wmi_handle: wmi handle
17241 * @param evt_buf: Pointer to event buffer
17242 * @param temp: Pointer to hold extracted temperature
17243 * @param level: Pointer to hold extracted level
17244 *
17245 * Return: 0 for success or error code
17246 */
17247static QDF_STATUS
17248extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17249 void *evt_buf, uint32_t *temp,
17250 uint32_t *level, uint32_t *pdev_id)
17251{
17252 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17253 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17254
17255 param_buf =
17256 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17257 if (!param_buf)
17258 return QDF_STATUS_E_INVAL;
17259
17260 tt_stats_event = param_buf->fixed_param;
17261
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017262 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17263 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017264 *temp = tt_stats_event->temp;
17265 *level = tt_stats_event->level;
17266
17267 return QDF_STATUS_SUCCESS;
17268}
17269
17270/**
17271 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17272 * @wmi_handle: wmi handle
17273 * @param evt_buf: pointer to event buffer
17274 * @param idx: Index to level stats
17275 * @param levelcount: Pointer to hold levelcount
17276 * @param dccount: Pointer to hold dccount
17277 *
17278 * Return: 0 for success or error code
17279 */
17280static QDF_STATUS
17281extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17282 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17283 uint32_t *dccount)
17284{
17285 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17286 wmi_therm_throt_level_stats_info *tt_level_info;
17287
17288 param_buf =
17289 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17290 if (!param_buf)
17291 return QDF_STATUS_E_INVAL;
17292
17293 tt_level_info = param_buf->therm_throt_level_stats_info;
17294
17295 if (idx < THERMAL_LEVELS) {
17296 *levelcount = tt_level_info[idx].level_count;
17297 *dccount = tt_level_info[idx].dc_count;
17298 return QDF_STATUS_SUCCESS;
17299 }
17300
17301 return QDF_STATUS_E_FAILURE;
17302}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017303#ifdef BIG_ENDIAN_HOST
17304/**
17305 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17306 * @param data_len - data length
17307 * @param data - pointer to data
17308 *
17309 * Return: QDF_STATUS - success or error status
17310 */
17311static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17312{
17313 uint8_t *data_aligned = NULL;
17314 int c;
17315 unsigned char *data_unaligned;
17316
17317 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17318 FIPS_ALIGN));
17319 /* Assigning unaligned space to copy the data */
17320 /* Checking if kmalloc does succesful allocation */
17321 if (data_unaligned == NULL)
17322 return QDF_STATUS_E_FAILURE;
17323
17324 /* Checking if space is alligned */
17325 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17326 /* align the data space */
17327 data_aligned =
17328 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17329 } else {
17330 data_aligned = (u_int8_t *)data_unaligned;
17331 }
17332
17333 /* memset and copy content from data to data aligned */
17334 OS_MEMSET(data_aligned, 0, data_len);
17335 OS_MEMCPY(data_aligned, data, data_len);
17336 /* Endianness to LE */
17337 for (c = 0; c < data_len/4; c++) {
17338 *((u_int32_t *)data_aligned + c) =
17339 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17340 }
17341
17342 /* Copy content to event->data */
17343 OS_MEMCPY(data, data_aligned, data_len);
17344
17345 /* clean up allocated space */
17346 qdf_mem_free(data_unaligned);
17347 data_aligned = NULL;
17348 data_unaligned = NULL;
17349
17350 /*************************************************************/
17351
17352 return QDF_STATUS_SUCCESS;
17353}
17354#else
17355/**
17356 * fips_conv_data_be() - DUMMY for LE platform
17357 *
17358 * Return: QDF_STATUS - success
17359 */
17360static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17361{
17362 return QDF_STATUS_SUCCESS;
17363}
17364#endif
17365
17366/**
17367 * extract_fips_event_data_tlv() - extract fips event data
17368 * @wmi_handle: wmi handle
17369 * @param evt_buf: pointer to event buffer
17370 * @param param: pointer FIPS event params
17371 *
17372 * Return: 0 for success or error code
17373 */
17374static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17375 void *evt_buf, struct wmi_host_fips_event_param *param)
17376{
17377 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17378 wmi_pdev_fips_event_fixed_param *event;
17379
17380 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17381 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17382
17383 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17384 QDF_STATUS_SUCCESS)
17385 return QDF_STATUS_E_FAILURE;
17386
17387 param->data = (uint32_t *)param_buf->data;
17388 param->data_len = event->data_len;
17389 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017390 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17391 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017392
17393 return QDF_STATUS_SUCCESS;
17394}
17395
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017396/*
17397 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17398 * @wmi_handle: wmi handle
17399 * @param evt_buf: pointer to event buffer
17400 * @param vdev_id: Pointer to hold vdev_id
17401 * @param mac_addr: Pointer to hold peer mac address
17402 *
17403 * Return: QDF_STATUS_SUCCESS for success or error code
17404 */
17405static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17406 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17407{
17408 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17409 wmi_peer_delete_resp_event_fixed_param *ev;
17410
17411 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17412
17413 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17414 if (!ev) {
17415 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17416 return QDF_STATUS_E_FAILURE;
17417 }
17418
17419 param->vdev_id = ev->vdev_id;
17420 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17421 &param->mac_address.bytes[0]);
17422
17423 return QDF_STATUS_SUCCESS;
17424}
17425
Govind Singhecf03cd2016-05-12 12:45:51 +053017426static bool is_management_record_tlv(uint32_t cmd_id)
17427{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017428 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017429 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017430
Govind Singhecf03cd2016-05-12 12:45:51 +053017431 return false;
17432}
17433
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017434static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17435{
17436 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17437
17438 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17439
17440 switch (set_cmd->param_id) {
17441 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17442 case WMI_VDEV_PARAM_DTIM_POLICY:
17443 return HTC_TX_PACKET_TAG_AUTO_PM;
17444 default:
17445 break;
17446 }
17447
17448 return 0;
17449}
17450
17451static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17452{
17453 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17454
17455 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17456
17457 switch (ps_cmd->param) {
17458 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17459 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17460 case WMI_STA_PS_ENABLE_QPOWER:
17461 return HTC_TX_PACKET_TAG_AUTO_PM;
17462 default:
17463 break;
17464 }
17465
17466 return 0;
17467}
17468
17469static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17470 uint32_t cmd_id)
17471{
17472 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17473 return 0;
17474
17475 switch (cmd_id) {
17476 case WMI_VDEV_SET_PARAM_CMDID:
17477 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17478 case WMI_STA_POWERSAVE_PARAM_CMDID:
17479 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17480 default:
17481 break;
17482 }
17483
17484 return 0;
17485}
17486
17487static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17488{
17489 uint16_t tag = 0;
17490
17491 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17492 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17493 __func__);
17494 return tag;
17495 }
17496
17497 if (wmi_handle->tag_crash_inject)
17498 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17499
17500 wmi_handle->tag_crash_inject = false;
17501 return tag;
17502}
17503
17504/**
17505 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17506 * @wmi_handle: WMI handle
17507 * @buf: WMI buffer
17508 * @cmd_id: WMI command Id
17509 *
17510 * Return htc_tx_tag
17511 */
17512static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17513 wmi_buf_t buf,
17514 uint32_t cmd_id)
17515{
17516 uint16_t htc_tx_tag = 0;
17517
17518 switch (cmd_id) {
17519 case WMI_WOW_ENABLE_CMDID:
17520 case WMI_PDEV_SUSPEND_CMDID:
17521 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
17522 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
17523 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
17524 case WMI_PDEV_RESUME_CMDID:
17525 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
17526 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
17527#ifdef FEATURE_WLAN_D0WOW
17528 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
17529#endif
17530 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
17531 break;
17532 case WMI_FORCE_FW_HANG_CMDID:
17533 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
17534 break;
17535 case WMI_VDEV_SET_PARAM_CMDID:
17536 case WMI_STA_POWERSAVE_PARAM_CMDID:
17537 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
17538 default:
17539 break;
17540 }
17541
17542 return htc_tx_tag;
17543}
17544
Sathish Kumard3ab1002017-02-07 17:10:59 +053017545/**
17546 * extract_channel_hopping_event_tlv() - extract channel hopping param
17547 * from event
17548 * @wmi_handle: wmi handle
17549 * @param evt_buf: pointer to event buffer
17550 * @param ch_hopping: Pointer to hold channel hopping param
17551 *
17552 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17553 */
17554static QDF_STATUS extract_channel_hopping_event_tlv(
17555 wmi_unified_t wmi_handle, void *evt_buf,
17556 wmi_host_pdev_channel_hopping_event *ch_hopping)
17557{
17558 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
17559 wmi_pdev_channel_hopping_event_fixed_param *event;
17560
17561 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
17562 event = (wmi_pdev_channel_hopping_event_fixed_param *)
17563 param_buf->fixed_param;
17564
17565 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
17566 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017567 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17568 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017569
17570 return QDF_STATUS_SUCCESS;
17571}
17572
17573/**
17574 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
17575 * @wmi_handle: wmi handle
17576 * @param evt_buf: pointer to event buffer
17577 * @param param: Pointer to hold tpc param
17578 *
17579 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17580 */
17581static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
17582 void *evt_buf,
17583 wmi_host_pdev_tpc_event *param)
17584{
17585 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
17586 wmi_pdev_tpc_event_fixed_param *event;
17587
17588 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
17589 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
17590
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017591 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17592 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017593 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
17594
17595 return QDF_STATUS_SUCCESS;
17596}
17597
17598
17599#ifdef BIG_ENDIAN_HOST
17600/**
17601 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
17602 * @param data_len - data length
17603 * @param data - pointer to data
17604 *
17605 * Return: QDF_STATUS - success or error status
17606 */
17607static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
17608{
17609 uint8_t *datap = (uint8_t *)ev;
17610 /* Skip swapping the first word */
17611 datap += sizeof(uint32_t);
17612 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
17613 i++, datap += sizeof(uint32_t)) {
17614 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
17615 }
17616
17617 return QDF_STATUS_SUCCESS;
17618}
17619#else
17620/**
17621 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
17622 * @param data_len - data length
17623 * @param data - pointer to data
17624 *
17625 * Return: QDF_STATUS - success or error status
17626 */
17627static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
17628{
17629 return QDF_STATUS_SUCCESS;
17630}
17631#endif
17632
17633/**
17634 * extract_wds_addr_event_tlv() - extract wds address from event
17635 * @wmi_handle: wmi handle
17636 * @param evt_buf: pointer to event buffer
17637 * @param wds_ev: Pointer to hold wds address
17638 *
17639 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17640 */
17641static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
17642 void *evt_buf,
17643 uint16_t len, wds_addr_event_t *wds_ev)
17644{
17645 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
17646 wmi_wds_addr_event_fixed_param *ev;
17647 int i;
17648
17649 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
17650 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
17651
17652 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
17653 return QDF_STATUS_E_FAILURE;
17654
17655 qdf_mem_copy(wds_ev->event_type, ev->event_type,
17656 sizeof(wds_ev->event_type));
17657 for (i = 0; i < 4; i++) {
17658 wds_ev->peer_mac[i] =
17659 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
17660 wds_ev->dest_mac[i] =
17661 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
17662 }
17663 for (i = 0; i < 2; i++) {
17664 wds_ev->peer_mac[4+i] =
17665 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
17666 wds_ev->dest_mac[4+i] =
17667 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
17668 }
17669 return QDF_STATUS_SUCCESS;
17670}
17671
17672/**
17673 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
17674 * from event
17675 * @wmi_handle: wmi handle
17676 * @param evt_buf: pointer to event buffer
17677 * @param ev: Pointer to hold peer param and ps state
17678 *
17679 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17680 */
17681static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
17682 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
17683{
17684 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
17685 wmi_peer_sta_ps_statechange_event_fixed_param *event;
17686
17687 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
17688 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
17689 param_buf->fixed_param;
17690
17691 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
17692 ev->peer_ps_state = event->peer_ps_state;
17693
17694 return QDF_STATUS_SUCCESS;
17695}
17696
17697/**
17698 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
17699 * @wmi_handle: wmi handle
17700 * @param evt_buf: pointer to event buffer
17701 * @param inst_rssi_resp: Pointer to hold inst rssi response
17702 *
17703 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17704 */
17705static QDF_STATUS extract_inst_rssi_stats_event_tlv(
17706 wmi_unified_t wmi_handle, void *evt_buf,
17707 wmi_host_inst_stats_resp *inst_rssi_resp)
17708{
17709 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
17710 wmi_inst_rssi_stats_resp_fixed_param *event;
17711
17712 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
17713 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
17714
17715 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
17716 &(event->peer_macaddr), sizeof(wmi_mac_addr));
17717 inst_rssi_resp->iRSSI = event->iRSSI;
17718
17719 return QDF_STATUS_SUCCESS;
17720}
17721
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017722static struct cur_reg_rule
17723*create_reg_rules_from_wmi(uint32_t num_reg_rules,
17724 wmi_regulatory_rule_struct *wmi_reg_rule)
17725{
17726 struct cur_reg_rule *reg_rule_ptr;
17727 uint32_t count;
17728
17729 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
17730
17731 if (NULL == reg_rule_ptr) {
17732 WMI_LOGE("memory allocation failure");
17733 return NULL;
17734 }
17735
17736 for (count = 0; count < num_reg_rules; count++) {
17737 reg_rule_ptr[count].start_freq =
17738 WMI_REG_RULE_START_FREQ_GET(
17739 wmi_reg_rule[count].freq_info);
17740 reg_rule_ptr[count].end_freq =
17741 WMI_REG_RULE_END_FREQ_GET(
17742 wmi_reg_rule[count].freq_info);
17743 reg_rule_ptr[count].max_bw =
17744 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017745 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017746 reg_rule_ptr[count].reg_power =
17747 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017748 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053017749 reg_rule_ptr[count].ant_gain =
17750 WMI_REG_RULE_ANTENNA_GAIN_GET(
17751 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017752 reg_rule_ptr[count].flags =
17753 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017754 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017755 }
17756
17757 return reg_rule_ptr;
17758}
17759
17760static QDF_STATUS extract_reg_chan_list_update_event_tlv(
17761 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17762 struct cur_regulatory_info *reg_info, uint32_t len)
17763{
17764 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
17765 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
17766 wmi_regulatory_rule_struct *wmi_reg_rule;
17767 uint32_t num_2g_reg_rules, num_5g_reg_rules;
17768
17769 WMI_LOGD("processing regulatory channel list");
17770
17771 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
17772 if (!param_buf) {
17773 WMI_LOGE("invalid channel list event buf");
17774 return QDF_STATUS_E_FAILURE;
17775 }
17776
17777 chan_list_event_hdr = param_buf->fixed_param;
17778
17779 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
17780 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
17781 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
17782 REG_ALPHA2_LEN);
17783 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
17784 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070017785 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070017786 reg_info->num_phy = chan_list_event_hdr->num_phy;
17787 reg_info->ctry_code = chan_list_event_hdr->country_id;
17788 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
17789 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
17790 reg_info->status_code = REG_SET_CC_STATUS_PASS;
17791 else if (chan_list_event_hdr->status_code ==
17792 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
17793 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
17794 else if (chan_list_event_hdr->status_code ==
17795 WMI_REG_INIT_ALPHA2_NOT_FOUND)
17796 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
17797 else if (chan_list_event_hdr->status_code ==
17798 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
17799 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
17800 else if (chan_list_event_hdr->status_code ==
17801 WMI_REG_SET_CC_STATUS_NO_MEMORY)
17802 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
17803 else if (chan_list_event_hdr->status_code ==
17804 WMI_REG_SET_CC_STATUS_FAIL)
17805 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
17806
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017807 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
17808 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
17809 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
17810 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
17811
17812 num_2g_reg_rules = reg_info->num_2g_reg_rules;
17813 num_5g_reg_rules = reg_info->num_5g_reg_rules;
17814
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017815 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
17816 __func__, reg_info->alpha2, reg_info->dfs_region,
17817 reg_info->min_bw_2g, reg_info->max_bw_2g,
17818 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017819
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017820 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
17821 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070017822 wmi_reg_rule =
17823 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
17824 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
17825 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017826 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
17827 wmi_reg_rule);
17828 wmi_reg_rule += num_2g_reg_rules;
17829
17830 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
17831 wmi_reg_rule);
17832
17833 WMI_LOGD("processed regulatory channel list");
17834
17835 return QDF_STATUS_SUCCESS;
17836}
17837
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070017838static QDF_STATUS extract_reg_11d_new_country_event_tlv(
17839 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17840 struct reg_11d_new_country *reg_11d_country, uint32_t len)
17841{
17842 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
17843 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
17844
17845 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
17846 if (!param_buf) {
17847 WMI_LOGE("invalid 11d country event buf");
17848 return QDF_STATUS_E_FAILURE;
17849 }
17850
17851 reg_11d_country_event = param_buf->fixed_param;
17852
17853 qdf_mem_copy(reg_11d_country->alpha2,
17854 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
17855
17856 WMI_LOGD("processed 11d country event, new cc %s",
17857 reg_11d_country->alpha2);
17858
17859 return QDF_STATUS_SUCCESS;
17860}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017861#ifdef DFS_COMPONENT_ENABLE
17862/**
17863 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
17864 * @wmi_handle: wma handle
17865 * @evt_buf: event buffer
17866 * @vdev_id: vdev id
17867 * @len: length of buffer
17868 *
17869 * Return: 0 for success or error code
17870 */
17871static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
17872 uint8_t *evt_buf,
17873 uint32_t *vdev_id,
17874 uint32_t len)
17875{
17876 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
17877 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
17878
17879 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
17880 if (!param_tlvs) {
17881 WMI_LOGE("invalid cac complete event buf");
17882 return QDF_STATUS_E_FAILURE;
17883 }
17884
17885 cac_event = param_tlvs->fixed_param;
17886 *vdev_id = cac_event->vdev_id;
17887 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
17888
17889 return QDF_STATUS_SUCCESS;
17890}
17891
17892/**
17893 * extract_dfs_radar_detection_event_tlv() - extract radar found event
17894 * @wmi_handle: wma handle
17895 * @evt_buf: event buffer
17896 * @radar_found: radar found event info
17897 * @len: length of buffer
17898 *
17899 * Return: 0 for success or error code
17900 */
17901static QDF_STATUS extract_dfs_radar_detection_event_tlv(
17902 wmi_unified_t wmi_handle,
17903 uint8_t *evt_buf,
17904 struct radar_found_info *radar_found,
17905 uint32_t len)
17906{
17907 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
17908 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
17909
17910 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
17911 if (!param_tlv) {
17912 WMI_LOGE("invalid radar detection event buf");
17913 return QDF_STATUS_E_FAILURE;
17914 }
17915
17916 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017917 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17918 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017919 radar_found->detection_mode = radar_event->detection_mode;
17920 radar_found->freq_offset = radar_event->chan_freq;
17921 radar_found->chan_width = radar_event->chan_width;
17922 radar_found->detector_id = radar_event->detector_id;
17923 radar_found->segment_id = radar_event->segment_id;
17924 radar_found->timestamp = radar_event->timestamp;
17925 radar_found->is_chirp = radar_event->is_chirp;
17926
17927 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
17928
17929 return QDF_STATUS_SUCCESS;
17930}
17931#endif
17932
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017933/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017934 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
17935 * host to target defines. For legacy there is not conversion
17936 * required. Just return pdev_id as it is.
17937 * @param pdev_id: host pdev_id to be converted.
17938 * Return: target pdev_id after conversion.
17939 */
17940static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
17941 uint32_t pdev_id)
17942{
17943 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
17944 return WMI_PDEV_ID_SOC;
17945
17946 /*No conversion required*/
17947 return pdev_id;
17948}
17949
17950/**
17951 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
17952 * target to host defines. For legacy there is not conversion
17953 * required. Just return pdev_id as it is.
17954 * @param pdev_id: target pdev_id to be converted.
17955 * Return: host pdev_id after conversion.
17956 */
17957static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
17958 uint32_t pdev_id)
17959{
17960 /*No conversion required*/
17961 return pdev_id;
17962}
17963
17964/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017965 * send_set_country_cmd_tlv() - WMI scan channel list function
17966 * @param wmi_handle : handle to WMI.
17967 * @param param : pointer to hold scan channel list parameter
17968 *
17969 * Return: 0 on success and -ve on failure.
17970 */
17971static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
17972 struct set_country *params)
17973{
17974 wmi_buf_t buf;
17975 QDF_STATUS qdf_status;
17976 wmi_set_current_country_cmd_fixed_param *cmd;
17977 uint16_t len = sizeof(*cmd);
17978
17979 buf = wmi_buf_alloc(wmi_handle, len);
17980 if (!buf) {
17981 WMI_LOGE("Failed to allocate memory");
17982 qdf_status = QDF_STATUS_E_NOMEM;
17983 goto end;
17984 }
17985
17986 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
17987 WMITLV_SET_HDR(&cmd->tlv_header,
17988 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
17989 WMITLV_GET_STRUCT_TLVLEN
17990 (wmi_set_current_country_cmd_fixed_param));
17991
17992 WMI_LOGD("setting cuurnet country to %s", params->country);
17993
17994 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
17995
17996 cmd->pdev_id = params->pdev_id;
17997
17998 qdf_status = wmi_unified_cmd_send(wmi_handle,
17999 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18000
18001 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18002 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18003 wmi_buf_free(buf);
18004 }
18005
18006end:
18007 return qdf_status;
18008}
18009
Govind Singh5eb51532016-03-09 11:34:12 +053018010struct wmi_ops tlv_ops = {
18011 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18012 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18013 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018014 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18015 .send_hidden_ssid_vdev_restart_cmd =
18016 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018017 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18018 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18019 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018020 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018021 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018022 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018023 .send_peer_rx_reorder_queue_setup_cmd =
18024 send_peer_rx_reorder_queue_setup_cmd_tlv,
18025 .send_peer_rx_reorder_queue_remove_cmd =
18026 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018027 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18028 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18029 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018030 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18031 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18032 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18033 .send_suspend_cmd = send_suspend_cmd_tlv,
18034 .send_resume_cmd = send_resume_cmd_tlv,
18035 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18036 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18037 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18038 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18039 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18040 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18041 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18042 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
18043 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018044 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018045 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18046 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18047 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18048 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018049 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018050 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018051 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18052 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018053 .send_set_sta_uapsd_auto_trig_cmd =
18054 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018055 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18056 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18057 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018058#ifdef CONVERGED_P2P_ENABLE
18059 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18060 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18061#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018062 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18063 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018064 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18065 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18066 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18067 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18068 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18069 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18070 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018071 .send_ocb_start_timing_advert_cmd =
18072 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018073 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18074 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18075 .send_set_mcc_channel_time_latency_cmd =
18076 send_set_mcc_channel_time_latency_cmd_tlv,
18077 .send_set_mcc_channel_time_quota_cmd =
18078 send_set_mcc_channel_time_quota_cmd_tlv,
18079 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18080 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018081 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018082 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18083 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18084 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018085 .send_probe_rsp_tmpl_send_cmd =
18086 send_probe_rsp_tmpl_send_cmd_tlv,
18087 .send_p2p_go_set_beacon_ie_cmd =
18088 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018089 .send_setup_install_key_cmd =
18090 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018091 .send_set_gateway_params_cmd =
18092 send_set_gateway_params_cmd_tlv,
18093 .send_set_rssi_monitoring_cmd =
18094 send_set_rssi_monitoring_cmd_tlv,
18095 .send_scan_probe_setoui_cmd =
18096 send_scan_probe_setoui_cmd_tlv,
18097 .send_reset_passpoint_network_list_cmd =
18098 send_reset_passpoint_network_list_cmd_tlv,
18099 .send_set_passpoint_network_list_cmd =
18100 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018101 .send_roam_scan_offload_rssi_thresh_cmd =
18102 send_roam_scan_offload_rssi_thresh_cmd_tlv,
18103 .send_roam_scan_filter_cmd =
18104 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018105 .send_set_epno_network_list_cmd =
18106 send_set_epno_network_list_cmd_tlv,
18107 .send_ipa_offload_control_cmd =
18108 send_ipa_offload_control_cmd_tlv,
18109 .send_extscan_get_capabilities_cmd =
18110 send_extscan_get_capabilities_cmd_tlv,
18111 .send_extscan_get_cached_results_cmd =
18112 send_extscan_get_cached_results_cmd_tlv,
18113 .send_extscan_stop_change_monitor_cmd =
18114 send_extscan_stop_change_monitor_cmd_tlv,
18115 .send_extscan_start_change_monitor_cmd =
18116 send_extscan_start_change_monitor_cmd_tlv,
18117 .send_extscan_stop_hotlist_monitor_cmd =
18118 send_extscan_stop_hotlist_monitor_cmd_tlv,
18119 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18120 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18121 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18122 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18123 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18124 .send_pno_start_cmd = send_pno_start_cmd_tlv,
18125 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18126 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18127 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18128 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18129 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018130 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018131 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18132 .send_snr_cmd = send_snr_cmd_tlv,
18133 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018134#ifdef WLAN_PMO_ENABLE
18135 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18136 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18137 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18138 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018139 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018140 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18141 .send_process_gtk_offload_getinfo_cmd =
18142 send_process_gtk_offload_getinfo_cmd_tlv,
18143 .send_enable_enhance_multicast_offload_cmd =
18144 send_enable_enhance_multicast_offload_tlv,
18145 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18146#ifdef FEATURE_WLAN_RA_FILTERING
18147 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18148#endif
18149 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018150 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18151 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018152 .send_lphb_config_tcp_pkt_filter_cmd =
18153 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018154 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18155 .send_lphb_config_udp_pkt_filter_cmd =
18156 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018157 .send_enable_disable_packet_filter_cmd =
18158 send_enable_disable_packet_filter_cmd_tlv,
18159 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018160#endif /* End of WLAN_PMO_ENABLE */
18161#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018162 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18163 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18164 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018165 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
18166 .send_process_update_edca_param_cmd =
18167 send_process_update_edca_param_cmd_tlv,
18168 .send_roam_scan_offload_mode_cmd =
18169 send_roam_scan_offload_mode_cmd_tlv,
18170 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18171 .send_roam_scan_offload_ap_profile_cmd =
18172 send_roam_scan_offload_ap_profile_cmd_tlv,
18173#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018174 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18175 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018176 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18177 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018178#ifdef WLAN_FEATURE_CIF_CFR
18179 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18180#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018181 .send_dfs_phyerr_filter_offload_en_cmd =
18182 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018183 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18184 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18185 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18186 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18187 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018188 .send_process_add_periodic_tx_ptrn_cmd =
18189 send_process_add_periodic_tx_ptrn_cmd_tlv,
18190 .send_process_del_periodic_tx_ptrn_cmd =
18191 send_process_del_periodic_tx_ptrn_cmd_tlv,
18192 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18193 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18194 .send_set_app_type2_params_in_fw_cmd =
18195 send_set_app_type2_params_in_fw_cmd_tlv,
18196 .send_set_auto_shutdown_timer_cmd =
18197 send_set_auto_shutdown_timer_cmd_tlv,
18198 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18199 .send_process_dhcpserver_offload_cmd =
18200 send_process_dhcpserver_offload_cmd_tlv,
18201 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18202 .send_process_ch_avoid_update_cmd =
18203 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018204 .send_pdev_set_regdomain_cmd =
18205 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018206 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18207 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18208 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18209 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18210 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18211 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018212#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018213 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018214#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018215 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018216 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018217 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018218 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018219 .send_set_base_macaddr_indicate_cmd =
18220 send_set_base_macaddr_indicate_cmd_tlv,
18221 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18222 .send_enable_specific_fw_logs_cmd =
18223 send_enable_specific_fw_logs_cmd_tlv,
18224 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018225 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018226 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018227 .send_pdev_set_dual_mac_config_cmd =
18228 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018229 .send_app_type1_params_in_fw_cmd =
18230 send_app_type1_params_in_fw_cmd_tlv,
18231 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18232 .send_process_roam_synch_complete_cmd =
18233 send_process_roam_synch_complete_cmd_tlv,
18234 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18235 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18236 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018237 .send_roam_scan_offload_scan_period_cmd =
18238 send_roam_scan_offload_scan_period_cmd_tlv,
18239 .send_roam_scan_offload_chan_list_cmd =
18240 send_roam_scan_offload_chan_list_cmd_tlv,
18241 .send_roam_scan_offload_rssi_change_cmd =
18242 send_roam_scan_offload_rssi_change_cmd_tlv,
18243 .send_get_buf_extscan_hotlist_cmd =
18244 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018245 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018246 .send_adapt_dwelltime_params_cmd =
18247 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018248 .send_dbs_scan_sel_params_cmd =
18249 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018250 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018251 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18252 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18253 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18254 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18255 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18256 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18257 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18258 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18259 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018260 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18261 .send_smart_ant_set_training_info_cmd =
18262 send_smart_ant_set_training_info_cmd_tlv,
18263 .send_smart_ant_set_node_config_cmd =
18264 send_smart_ant_set_node_config_cmd_tlv,
18265 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18266 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18267 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018268 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18269 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18270 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18271 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18272 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18273 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18274 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018275 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18276 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18277 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18278 .send_vdev_spectral_configure_cmd =
18279 send_vdev_spectral_configure_cmd_tlv,
18280 .send_vdev_spectral_enable_cmd =
18281 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018282 .send_thermal_mitigation_param_cmd =
18283 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018284 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18285 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018286 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018287 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018288 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18289 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18290 .extract_host_mem_req = extract_host_mem_req_tlv,
18291 .save_service_bitmap = save_service_bitmap_tlv,
18292 .is_service_enabled = is_service_enabled_tlv,
18293 .save_fw_version = save_fw_version_in_service_ready_tlv,
18294 .ready_extract_init_status = ready_extract_init_status_tlv,
18295 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
18296 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18297 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18298 .extract_tbttoffset_update_params =
18299 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018300 .extract_ext_tbttoffset_update_params =
18301 extract_ext_tbttoffset_update_params_tlv,
18302 .extract_tbttoffset_num_vdevs =
18303 extract_tbttoffset_num_vdevs_tlv,
18304 .extract_ext_tbttoffset_num_vdevs =
18305 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018306 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18307 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18308 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18309 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018310#ifdef CONVERGED_TDLS_ENABLE
18311 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18312#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018313 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018314 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018315 .extract_swba_tim_info = extract_swba_tim_info_tlv,
18316 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018317#ifdef CONVERGED_P2P_ENABLE
18318 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
18319 .extract_p2p_lo_stop_ev_param =
18320 extract_p2p_lo_stop_ev_param_tlv,
18321#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018322 .extract_offchan_data_tx_compl_param =
18323 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018324 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
18325 .extract_all_stats_count = extract_all_stats_counts_tlv,
18326 .extract_pdev_stats = extract_pdev_stats_tlv,
18327 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
18328 .extract_vdev_stats = extract_vdev_stats_tlv,
18329 .extract_peer_stats = extract_peer_stats_tlv,
18330 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
18331 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
18332 .extract_chan_stats = extract_chan_stats_tlv,
18333 .extract_profile_ctx = extract_profile_ctx_tlv,
18334 .extract_profile_data = extract_profile_data_tlv,
18335 .extract_chan_info_event = extract_chan_info_event_tlv,
18336 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053018337 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053018338 .send_encrypt_decrypt_send_cmd =
18339 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080018340 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053018341 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018342 .send_multiple_vdev_restart_req_cmd =
18343 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053018344 .extract_service_ready_ext = extract_service_ready_ext_tlv,
18345 .extract_hw_mode_cap_service_ready_ext =
18346 extract_hw_mode_cap_service_ready_ext_tlv,
18347 .extract_mac_phy_cap_service_ready_ext =
18348 extract_mac_phy_cap_service_ready_ext_tlv,
18349 .extract_reg_cap_service_ready_ext =
18350 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018351 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053018352 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018353 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
18354 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
18355 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053018356 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018357 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018358 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018359 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018360 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018361 .extract_pdev_csa_switch_count_status =
18362 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053018363 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
18364 .extract_wds_addr_event = extract_wds_addr_event_tlv,
18365 .extract_peer_sta_ps_statechange_ev =
18366 extract_peer_sta_ps_statechange_ev_tlv,
18367 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053018368 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080018369 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
18370 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018371 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018372 extract_reg_chan_list_update_event_tlv,
18373 .extract_chainmask_tables =
18374 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018375 .extract_thermal_stats = extract_thermal_stats_tlv,
18376 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018377#ifdef DFS_COMPONENT_ENABLE
18378 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
18379 .extract_dfs_radar_detection_event =
18380 extract_dfs_radar_detection_event_tlv,
18381#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018382 .convert_pdev_id_host_to_target =
18383 convert_host_pdev_id_to_target_pdev_id_legacy,
18384 .convert_pdev_id_target_to_host =
18385 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018386
18387 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
18388 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
18389 .extract_reg_11d_new_country_event =
18390 extract_reg_11d_new_country_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018391};
18392
Govind Singhe7f2f342016-05-23 12:12:52 +053018393/**
18394 * populate_tlv_event_id() - populates wmi event ids
18395 *
18396 * @param event_ids: Pointer to hold event ids
18397 * Return: None
18398 */
18399static void populate_tlv_events_id(uint32_t *event_ids)
18400{
18401 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
18402 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
18403 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
18404 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18405 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
18406 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
18407 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
18408 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
18409 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
18410 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
18411 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
18412 event_ids[wmi_service_ready_ext_event_id] =
18413 WMI_SERVICE_READY_EXT_EVENTID;
18414 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
18415 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
18416 event_ids[wmi_vdev_install_key_complete_event_id] =
18417 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
18418 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
18419 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
18420
18421 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
18422 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
18423 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
18424 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
18425 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
18426 event_ids[wmi_peer_estimated_linkspeed_event_id] =
18427 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
18428 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018429 event_ids[wmi_peer_delete_response_event_id] =
18430 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018431 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
18432 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
18433 event_ids[wmi_tbttoffset_update_event_id] =
18434 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018435 event_ids[wmi_ext_tbttoffset_update_event_id] =
18436 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018437 event_ids[wmi_offload_bcn_tx_status_event_id] =
18438 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
18439 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
18440 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
18441 event_ids[wmi_mgmt_tx_completion_event_id] =
18442 WMI_MGMT_TX_COMPLETION_EVENTID;
18443
18444 event_ids[wmi_tx_delba_complete_event_id] =
18445 WMI_TX_DELBA_COMPLETE_EVENTID;
18446 event_ids[wmi_tx_addba_complete_event_id] =
18447 WMI_TX_ADDBA_COMPLETE_EVENTID;
18448 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
18449
18450 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
18451
18452 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
18453 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
18454
18455 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
18456
18457 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
18458
18459 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080018460 event_ids[wmi_p2p_lo_stop_event_id] =
18461 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018462 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
18463 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
18464 event_ids[wmi_do_wow_disable_ack_event_id] =
18465 WMI_D0_WOW_DISABLE_ACK_EVENTID;
18466 event_ids[wmi_wow_initial_wakeup_event_id] =
18467 WMI_WOW_INITIAL_WAKEUP_EVENTID;
18468
18469 event_ids[wmi_rtt_meas_report_event_id] =
18470 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
18471 event_ids[wmi_tsf_meas_report_event_id] =
18472 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
18473 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
18474 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
18475 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
18476 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
18477 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
18478 event_ids[wmi_update_fw_mem_dump_event_id] =
18479 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
18480 event_ids[wmi_diag_event_id_log_supported_event_id] =
18481 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
18482 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
18483 event_ids[wmi_nlo_scan_complete_event_id] =
18484 WMI_NLO_SCAN_COMPLETE_EVENTID;
18485 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
18486 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
18487
18488 event_ids[wmi_gtk_offload_status_event_id] =
18489 WMI_GTK_OFFLOAD_STATUS_EVENTID;
18490 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
18491 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
18492 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
18493
18494 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
18495
18496 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
18497
18498 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
18499 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
18500 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
18501 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
18502 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
18503 event_ids[wmi_wlan_profile_data_event_id] =
18504 WMI_WLAN_PROFILE_DATA_EVENTID;
18505 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
18506 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
18507 event_ids[wmi_vdev_get_keepalive_event_id] =
18508 WMI_VDEV_GET_KEEPALIVE_EVENTID;
18509 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
18510
18511 event_ids[wmi_diag_container_event_id] =
18512 WMI_DIAG_DATA_CONTAINER_EVENTID;
18513
18514 event_ids[wmi_host_auto_shutdown_event_id] =
18515 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
18516
18517 event_ids[wmi_update_whal_mib_stats_event_id] =
18518 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
18519
18520 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
18521 event_ids[wmi_update_vdev_rate_stats_event_id] =
18522 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
18523
18524 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
18525
18526 /** Set OCB Sched Response, deprecated */
18527 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
18528
18529 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
18530 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
18531 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
18532
18533 /* GPIO Event */
18534 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
18535 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
18536
18537 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
18538 event_ids[wmi_rfkill_state_change_event_id] =
18539 WMI_RFKILL_STATE_CHANGE_EVENTID;
18540
18541 /* TDLS Event */
18542 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
18543
18544 event_ids[wmi_batch_scan_enabled_event_id] =
18545 WMI_BATCH_SCAN_ENABLED_EVENTID;
18546 event_ids[wmi_batch_scan_result_event_id] =
18547 WMI_BATCH_SCAN_RESULT_EVENTID;
18548 /* OEM Event */
18549 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
18550 event_ids[wmi_oem_meas_report_event_id] =
18551 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
18552 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
18553
18554 /* NAN Event */
18555 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
18556
18557 /* LPI Event */
18558 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
18559 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
18560 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
18561
18562 /* ExtScan events */
18563 event_ids[wmi_extscan_start_stop_event_id] =
18564 WMI_EXTSCAN_START_STOP_EVENTID;
18565 event_ids[wmi_extscan_operation_event_id] =
18566 WMI_EXTSCAN_OPERATION_EVENTID;
18567 event_ids[wmi_extscan_table_usage_event_id] =
18568 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
18569 event_ids[wmi_extscan_cached_results_event_id] =
18570 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
18571 event_ids[wmi_extscan_wlan_change_results_event_id] =
18572 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
18573 event_ids[wmi_extscan_hotlist_match_event_id] =
18574 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
18575 event_ids[wmi_extscan_capabilities_event_id] =
18576 WMI_EXTSCAN_CAPABILITIES_EVENTID;
18577 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
18578 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
18579
18580 /* mDNS offload events */
18581 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
18582
18583 /* SAP Authentication offload events */
18584 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
18585 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
18586
18587 /** Out-of-context-of-bss (OCB) events */
18588 event_ids[wmi_ocb_set_config_resp_event_id] =
18589 WMI_OCB_SET_CONFIG_RESP_EVENTID;
18590 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
18591 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
18592 event_ids[wmi_dcc_get_stats_resp_event_id] =
18593 WMI_DCC_GET_STATS_RESP_EVENTID;
18594 event_ids[wmi_dcc_update_ndl_resp_event_id] =
18595 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
18596 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
18597 /* System-On-Chip events */
18598 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
18599 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
18600 event_ids[wmi_soc_hw_mode_transition_event_id] =
18601 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
18602 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
18603 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018604 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053018605 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
18606 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018607 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053018608 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
18609 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18610 event_ids[wmi_peer_sta_ps_statechg_event_id] =
18611 WMI_PEER_STA_PS_STATECHG_EVENTID;
18612 event_ids[wmi_pdev_channel_hopping_event_id] =
18613 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018614 event_ids[wmi_offchan_data_tx_completion_event] =
18615 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018616 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
18617 event_ids[wmi_dfs_radar_detection_event_id] =
18618 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018619 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070018620 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018621}
18622
Soumya Bhat488092d2017-03-22 14:41:01 +053018623#ifndef CONFIG_MCL
18624/**
18625 * populate_tlv_service() - populates wmi services
18626 *
18627 * @param wmi_service: Pointer to hold wmi_service
18628 * Return: None
18629 */
18630static void populate_tlv_service(uint32_t *wmi_service)
18631{
18632 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
18633 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
18634 wmi_service[wmi_service_roam_scan_offload] =
18635 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
18636 wmi_service[wmi_service_bcn_miss_offload] =
18637 WMI_SERVICE_BCN_MISS_OFFLOAD;
18638 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
18639 wmi_service[wmi_service_sta_advanced_pwrsave] =
18640 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
18641 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
18642 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
18643 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
18644 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
18645 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
18646 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
18647 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
18648 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
18649 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
18650 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
18651 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
18652 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
18653 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
18654 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
18655 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
18656 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
18657 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
18658 wmi_service[wmi_service_packet_power_save] =
18659 WMI_SERVICE_PACKET_POWER_SAVE;
18660 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
18661 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
18662 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
18663 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
18664 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
18665 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
18666 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
18667 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
18668 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
18669 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
18670 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
18671 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
18672 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
18673 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
18674 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
18675 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
18676 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
18677 wmi_service[wmi_service_mcc_bcn_interval_change] =
18678 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
18679 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
18680 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
18681 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
18682 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
18683 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
18684 wmi_service[wmi_service_lte_ant_share_support] =
18685 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
18686 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
18687 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
18688 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
18689 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
18690 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
18691 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
18692 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
18693 wmi_service[wmi_service_bcn_txrate_override] =
18694 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
18695 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
18696 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
18697 wmi_service[wmi_service_estimate_linkspeed] =
18698 WMI_SERVICE_ESTIMATE_LINKSPEED;
18699 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
18700 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
18701 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
18702 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
18703 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
18704 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
18705 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
18706 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
18707 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
18708 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
18709 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
18710 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
18711 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
18712 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
18713 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
18714 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
18715 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
18716 wmi_service[wmi_service_sap_auth_offload] =
18717 WMI_SERVICE_SAP_AUTH_OFFLOAD;
18718 wmi_service[wmi_service_dual_band_simultaneous_support] =
18719 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
18720 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
18721 wmi_service[wmi_service_ap_arpns_offload] =
18722 WMI_SERVICE_AP_ARPNS_OFFLOAD;
18723 wmi_service[wmi_service_per_band_chainmask_support] =
18724 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
18725 wmi_service[wmi_service_packet_filter_offload] =
18726 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
18727 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
18728 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
18729 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
18730 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
18731 wmi_service[wmi_service_multiple_vdev_restart] =
18732 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
18733
18734 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
18735 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
18736 wmi_service[wmi_service_smart_antenna_sw_support] =
18737 WMI_SERVICE_UNAVAILABLE;
18738 wmi_service[wmi_service_smart_antenna_hw_support] =
18739 WMI_SERVICE_UNAVAILABLE;
18740 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
18741 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018742 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053018743 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
18744 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
18745 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
18746 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
18747 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
18748 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
18749 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
18750 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053018751 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
18752 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
18753 wmi_service[wmi_service_periodic_chan_stat_support] =
18754 WMI_SERVICE_UNAVAILABLE;
18755 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
18756 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
18757 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
18758 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
18759 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
18760 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053018761 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
18762 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
18763 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
18764 wmi_service[wmi_service_unified_wow_capability] =
18765 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
18766 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
18767 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
18768 wmi_service[wmi_service_sync_delete_cmds] =
18769 WMI_SERVICE_SYNC_DELETE_CMDS;
18770 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
18771 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
18772 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
18773 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
18774 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
18775 wmi_service[wmi_service_deprecated_replace] =
18776 WMI_SERVICE_DEPRECATED_REPLACE;
18777 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
18778 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
18779 wmi_service[wmi_service_enhanced_mcast_filter] =
18780 WMI_SERVICE_ENHANCED_MCAST_FILTER;
18781 wmi_service[wmi_service_half_rate_quarter_rate_support] =
18782 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
18783 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
18784 wmi_service[wmi_service_p2p_listen_offload_support] =
18785 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
18786 wmi_service[wmi_service_mark_first_wakeup_packet] =
18787 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
18788 wmi_service[wmi_service_multiple_mcast_filter_set] =
18789 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
18790 wmi_service[wmi_service_host_managed_rx_reorder] =
18791 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
18792 wmi_service[wmi_service_flash_rdwr_support] =
18793 WMI_SERVICE_FLASH_RDWR_SUPPORT;
18794 wmi_service[wmi_service_wlan_stats_report] =
18795 WMI_SERVICE_WLAN_STATS_REPORT;
18796 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
18797 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
18798 wmi_service[wmi_service_dfs_phyerr_offload] =
18799 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
18800 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
18801 wmi_service[wmi_service_fw_mem_dump_support] =
18802 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
18803 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
18804 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
18805 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
18806 wmi_service[wmi_service_hw_data_filtering] =
18807 WMI_SERVICE_HW_DATA_FILTERING;
18808 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
18809 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053018810 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat488092d2017-03-22 14:41:01 +053018811}
18812
Govind Singhe7f2f342016-05-23 12:12:52 +053018813/**
18814 * populate_pdev_param_tlv() - populates pdev params
18815 *
18816 * @param pdev_param: Pointer to hold pdev params
18817 * Return: None
18818 */
18819static void populate_pdev_param_tlv(uint32_t *pdev_param)
18820{
18821 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
18822 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
18823 pdev_param[wmi_pdev_param_txpower_limit2g] =
18824 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
18825 pdev_param[wmi_pdev_param_txpower_limit5g] =
18826 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
18827 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
18828 pdev_param[wmi_pdev_param_beacon_gen_mode] =
18829 WMI_PDEV_PARAM_BEACON_GEN_MODE;
18830 pdev_param[wmi_pdev_param_beacon_tx_mode] =
18831 WMI_PDEV_PARAM_BEACON_TX_MODE;
18832 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
18833 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
18834 pdev_param[wmi_pdev_param_protection_mode] =
18835 WMI_PDEV_PARAM_PROTECTION_MODE;
18836 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
18837 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
18838 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
18839 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
18840 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
18841 pdev_param[wmi_pdev_param_sta_kickout_th] =
18842 WMI_PDEV_PARAM_STA_KICKOUT_TH;
18843 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
18844 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
18845 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
18846 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
18847 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
18848 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
18849 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
18850 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
18851 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
18852 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
18853 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
18854 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
18855 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
18856 pdev_param[wmi_pdev_param_ltr_sleep_override] =
18857 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
18858 pdev_param[wmi_pdev_param_ltr_rx_override] =
18859 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
18860 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
18861 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
18862 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
18863 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
18864 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
18865 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
18866 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
18867 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
18868 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
18869 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
18870 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
18871 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
18872 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
18873 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
18874 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
18875 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
18876 pdev_param[wmi_pdev_param_peer_stats_update_period] =
18877 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
18878 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
18879 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
18880 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
18881 pdev_param[wmi_pdev_param_arp_ac_override] =
18882 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
18883 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
18884 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
18885 pdev_param[wmi_pdev_param_ani_poll_period] =
18886 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
18887 pdev_param[wmi_pdev_param_ani_listen_period] =
18888 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
18889 pdev_param[wmi_pdev_param_ani_ofdm_level] =
18890 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
18891 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
18892 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
18893 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
18894 pdev_param[wmi_pdev_param_idle_ps_config] =
18895 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
18896 pdev_param[wmi_pdev_param_power_gating_sleep] =
18897 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
18898 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
18899 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
18900 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
18901 pdev_param[wmi_pdev_param_hw_rfkill_config] =
18902 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
18903 pdev_param[wmi_pdev_param_low_power_rf_enable] =
18904 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
18905 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
18906 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
18907 pdev_param[wmi_pdev_param_power_collapse_enable] =
18908 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
18909 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
18910 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
18911 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
18912 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
18913 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
18914 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
18915 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
18916 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
18917 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
18918 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
18919 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
18920 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
18921 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
18922 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
18923 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
18924 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
18925 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
18926 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
18927 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
18928 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
18929 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
18930 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
18931 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
18932 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
18933 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
18934 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
18935 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
18936 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
18937 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
18938 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
18939 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
18940 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
18941 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
18942 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
18943 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
18944 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
18945 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
18946 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
18947 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
18948 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
18949 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
18950 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
18951 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
18952 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
18953 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
18954 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
18955 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
18956 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
18957 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
18958 WMI_UNAVAILABLE_PARAM;
18959 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
18960 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
18961 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
18962 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
18963 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
18964 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018965 pdev_param[wmi_pdev_param_atf_strict_sch] =
18966 WMI_PDEV_PARAM_ATF_STRICT_SCH;
18967 pdev_param[wmi_pdev_param_atf_sched_duration] =
18968 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053018969 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
18970 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
18971 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
18972 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
18973 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
18974 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
18975 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
18976 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
18977 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
18978 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
18979 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
18980 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
18981 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
18982 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
18983 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
18984 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018985 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
18986 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053018987 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018988 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053018989 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018990 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
18991 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018992 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
18993 WMI_UNAVAILABLE_PARAM;
18994 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
18995 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
18996 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
18997 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
18998 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
18999 WMI_UNAVAILABLE_PARAM;
19000 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
19001 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
19002 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019003 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19004 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019005 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019006 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19007 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019008 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19009 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19010 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19011 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19012 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19013 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19014 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19015 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19016 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19017 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19018 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19019 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19020 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19021 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19022 pdev_param[wmi_pdev_param_fast_channel_reset] =
19023 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19024 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019025}
19026
19027/**
19028 * populate_vdev_param_tlv() - populates vdev params
19029 *
19030 * @param vdev_param: Pointer to hold vdev params
19031 * Return: None
19032 */
19033static void populate_vdev_param_tlv(uint32_t *vdev_param)
19034{
19035 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19036 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19037 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19038 vdev_param[wmi_vdev_param_beacon_interval] =
19039 WMI_VDEV_PARAM_BEACON_INTERVAL;
19040 vdev_param[wmi_vdev_param_listen_interval] =
19041 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19042 vdev_param[wmi_vdev_param_multicast_rate] =
19043 WMI_VDEV_PARAM_MULTICAST_RATE;
19044 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19045 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19046 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19047 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19048 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19049 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19050 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19051 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19052 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19053 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19054 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19055 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19056 vdev_param[wmi_vdev_param_bmiss_count_max] =
19057 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19058 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19059 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19060 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19061 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19062 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19063 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19064 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19065 vdev_param[wmi_vdev_param_disable_htprotection] =
19066 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19067 vdev_param[wmi_vdev_param_sta_quickkickout] =
19068 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19069 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19070 vdev_param[wmi_vdev_param_protection_mode] =
19071 WMI_VDEV_PARAM_PROTECTION_MODE;
19072 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19073 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19074 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19075 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19076 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19077 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19078 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19079 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19080 vdev_param[wmi_vdev_param_bcast_data_rate] =
19081 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19082 vdev_param[wmi_vdev_param_mcast_data_rate] =
19083 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19084 vdev_param[wmi_vdev_param_mcast_indicate] =
19085 WMI_VDEV_PARAM_MCAST_INDICATE;
19086 vdev_param[wmi_vdev_param_dhcp_indicate] =
19087 WMI_VDEV_PARAM_DHCP_INDICATE;
19088 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19089 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19090 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19091 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19092 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19093 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19094 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19095 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19096 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19097 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19098 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19099 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19100 vdev_param[wmi_vdev_param_packet_powersave] =
19101 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19102 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19103 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19104 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19105 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19106 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19107 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19108 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19109 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19110 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19111 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19112 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19113 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19114 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19115 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19116 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19117 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19118 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19119 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19120 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19121 vdev_param[wmi_vdev_param_roam_fw_offload] =
19122 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19123 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19124 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19125 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19126 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19127 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19128 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19129 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19130 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19131 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19132 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19133 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19134 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19135 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19136 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19137 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19138 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19139 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19140 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19141 vdev_param[wmi_vdev_param_inactivity_cnt] =
19142 WMI_VDEV_PARAM_INACTIVITY_CNT;
19143 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19144 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19145 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19146 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19147 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19148 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19149 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19150 vdev_param[wmi_vdev_param_rx_leak_window] =
19151 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19152 vdev_param[wmi_vdev_param_stats_avg_factor] =
19153 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19154 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19155 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19156 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19157 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19158 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19159 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019160 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19161 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019162 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019163 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19164 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19165 WMI_VDEV_PARAM_HE_RANGE_EXT;
19166 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19167 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019168 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19169 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19170 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19171 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19172 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19173 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19174 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019175 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19176 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19177 vdev_param[wmi_vdev_param_rc_num_retries] =
19178 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19179 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19180 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19181 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19182 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19183 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19184 vdev_param[wmi_vdev_param_vht80_ratemask] =
19185 WMI_VDEV_PARAM_VHT80_RATEMASK;
19186 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19187 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19188 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019189}
19190#endif
19191
Govind Singh5eb51532016-03-09 11:34:12 +053019192/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019193 * populate_target_defines_tlv() - Populate target defines and params
19194 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019195 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019196 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019197 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019198#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019199static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019200{
Govind Singhe7f2f342016-05-23 12:12:52 +053019201 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019202 populate_pdev_param_tlv(wmi_handle->pdev_param);
19203 populate_vdev_param_tlv(wmi_handle->vdev_param);
19204}
19205#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019206static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19207{ }
19208#endif
19209
19210/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019211 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19212 * host to target defines.
19213 * @param pdev_id: host pdev_id to be converted.
19214 * Return: target pdev_id after conversion.
19215 */
19216static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19217{
19218 switch (pdev_id) {
19219 case WMI_HOST_PDEV_ID_SOC:
19220 return WMI_PDEV_ID_SOC;
19221 case WMI_HOST_PDEV_ID_0:
19222 return WMI_PDEV_ID_1ST;
19223 case WMI_HOST_PDEV_ID_1:
19224 return WMI_PDEV_ID_2ND;
19225 case WMI_HOST_PDEV_ID_2:
19226 return WMI_PDEV_ID_3RD;
19227 }
19228
19229 QDF_ASSERT(0);
19230
19231 return WMI_PDEV_ID_SOC;
19232}
19233
19234/**
19235 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19236 * target to host defines.
19237 * @param pdev_id: target pdev_id to be converted.
19238 * Return: host pdev_id after conversion.
19239 */
19240static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19241{
19242 switch (pdev_id) {
19243 case WMI_PDEV_ID_SOC:
19244 return WMI_HOST_PDEV_ID_SOC;
19245 case WMI_PDEV_ID_1ST:
19246 return WMI_HOST_PDEV_ID_0;
19247 case WMI_PDEV_ID_2ND:
19248 return WMI_HOST_PDEV_ID_1;
19249 case WMI_PDEV_ID_3RD:
19250 return WMI_HOST_PDEV_ID_2;
19251 }
19252
19253 QDF_ASSERT(0);
19254
19255 return WMI_HOST_PDEV_ID_SOC;
19256}
19257
19258/**
19259 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19260 *
19261 * Return None.
19262 */
19263void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19264{
19265 wmi_handle->ops->convert_pdev_id_host_to_target =
19266 convert_host_pdev_id_to_target_pdev_id;
19267 wmi_handle->ops->convert_pdev_id_target_to_host =
19268 convert_target_pdev_id_to_host_pdev_id;
19269}
19270/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019271 * wmi_tlv_attach() - Attach TLV APIs
19272 *
19273 * Return: None
19274 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019275void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019276{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019277 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019278#ifdef WMI_INTERFACE_EVENT_LOGGING
19279 wmi_handle->log_info.buf_offset_command = 2;
19280 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019281#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019282 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019283 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019284}