blob: d33856f30f2fa5f814b31240a83d6c0b0117f0e3 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -08002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080033#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053034#include <wlan_defs.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053035#include <htc_services.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053036
Wu Gaocd3a8512017-03-13 20:17:34 +080037#ifdef CONVERGED_P2P_ENABLE
38#include "wlan_p2p_public_struct.h"
39#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070040#ifdef WLAN_PMO_ENABLE
41#include "wlan_pmo_hw_filter_public_struct.h"
42#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053043#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053044#ifdef WLAN_SUPPORT_GREEN_AP
45#include "wlan_green_ap_api.h"
46#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053047
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080048#ifdef WLAN_FEATURE_NAN_CONVERGENCE
49#include "nan_public_structs.h"
50#endif
51
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080052#ifdef WLAN_POLICY_MGR_ENABLE
53#include "wlan_policy_mgr_public_struct.h"
54#endif
55
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053056/* HTC service ids for WMI for multi-radio */
57static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
58 WMI_CONTROL_SVC_WMAC1,
59 WMI_CONTROL_SVC_WMAC2};
60
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053061/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
62 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053063 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053064 * @cmd: pointer target vdev create command buffer
65 * @param: pointer host params for vdev create
66 *
67 * Return: None
68 */
69#ifdef CONFIG_MCL
70static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053071 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053072 wmi_vdev_create_cmd_fixed_param * cmd,
73 struct vdev_create_params *param)
74{
75 cmd->pdev_id = WMI_PDEV_ID_SOC;
76}
77#else
78static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053079 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053080 wmi_vdev_create_cmd_fixed_param * cmd,
81 struct vdev_create_params *param)
82{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053083 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
84 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053085}
86#endif
87
Govind Singh5eb51532016-03-09 11:34:12 +053088/**
89 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
90 * @wmi_handle: wmi handle
91 * @param: pointer to hold vdev create parameter
92 * @macaddr: vdev mac address
93 *
Govind Singhe7f2f342016-05-23 12:12:52 +053094 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053095 */
Sathish Kumarfd347372017-02-13 12:29:09 +053096static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053097 uint8_t macaddr[IEEE80211_ADDR_LEN],
98 struct vdev_create_params *param)
99{
100 wmi_vdev_create_cmd_fixed_param *cmd;
101 wmi_buf_t buf;
102 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530103 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700104 int num_bands = 2;
105 uint8_t *buf_ptr;
106 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530107
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700108 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530109 buf = wmi_buf_alloc(wmi_handle, len);
110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530111 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530112 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530113 }
114 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
115 WMITLV_SET_HDR(&cmd->tlv_header,
116 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
117 WMITLV_GET_STRUCT_TLVLEN
118 (wmi_vdev_create_cmd_fixed_param));
119 cmd->vdev_id = param->if_id;
120 cmd->vdev_type = param->type;
121 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700122 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530123 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530124 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700125 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
126 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530127 macaddr[0], macaddr[1], macaddr[2],
128 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700129 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
130 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
131 (num_bands * sizeof(wmi_vdev_txrx_streams)));
132 buf_ptr += WMI_TLV_HDR_SIZE;
133
Govind Singh224a7312016-06-21 14:33:26 +0530134 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700135 param->type, param->subtype,
136 param->nss_2g, param->nss_5g);
137 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
138 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
139 txrx_streams->supported_tx_streams = param->nss_2g;
140 txrx_streams->supported_rx_streams = param->nss_2g;
141 WMITLV_SET_HDR(&txrx_streams->tlv_header,
142 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
143 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
144
145 txrx_streams++;
146 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
147 txrx_streams->supported_tx_streams = param->nss_5g;
148 txrx_streams->supported_rx_streams = param->nss_5g;
149 WMITLV_SET_HDR(&txrx_streams->tlv_header,
150 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
151 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530152 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530153 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530154 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530155 wmi_buf_free(buf);
156 }
157
158 return ret;
159}
160
161/**
162 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
163 * @wmi_handle: wmi handle
164 * @if_id: vdev id
165 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530166 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530167 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530168static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530169 uint8_t if_id)
170{
171 wmi_vdev_delete_cmd_fixed_param *cmd;
172 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530173 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530174
175 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
176 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530177 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530178 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530179 }
180
181 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
182 WMITLV_SET_HDR(&cmd->tlv_header,
183 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
184 WMITLV_GET_STRUCT_TLVLEN
185 (wmi_vdev_delete_cmd_fixed_param));
186 cmd->vdev_id = if_id;
187 ret = wmi_unified_cmd_send(wmi_handle, buf,
188 sizeof(wmi_vdev_delete_cmd_fixed_param),
189 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530190 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530191 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530192 wmi_buf_free(buf);
193 }
Govind Singhb53420c2016-03-09 14:32:57 +0530194 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530195
196 return ret;
197}
198
199/**
200 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
201 * @wmi: wmi handle
202 * @vdev_id: vdev id
203 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530204 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530205 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530206static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530207 uint8_t vdev_id)
208{
209 wmi_vdev_stop_cmd_fixed_param *cmd;
210 wmi_buf_t buf;
211 int32_t len = sizeof(*cmd);
212
213 buf = wmi_buf_alloc(wmi, len);
214 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530215 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530216 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530217 }
218 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
219 WMITLV_SET_HDR(&cmd->tlv_header,
220 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
221 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
222 cmd->vdev_id = vdev_id;
223 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530224 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530225 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530226 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530227 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530228 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530229
230 return 0;
231}
232
233/**
234 * send_vdev_down_cmd_tlv() - send vdev down command to fw
235 * @wmi: wmi handle
236 * @vdev_id: vdev id
237 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530238 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530239 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530240static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530241{
242 wmi_vdev_down_cmd_fixed_param *cmd;
243 wmi_buf_t buf;
244 int32_t len = sizeof(*cmd);
245
246 buf = wmi_buf_alloc(wmi, len);
247 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530248 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530249 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530250 }
251 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
252 WMITLV_SET_HDR(&cmd->tlv_header,
253 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
254 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
255 cmd->vdev_id = vdev_id;
256 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530257 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530258 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530259 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530260 }
Govind Singhb53420c2016-03-09 14:32:57 +0530261 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530262
263 return 0;
264}
265
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530266#ifdef CONFIG_MCL
267static inline void copy_channel_info(
268 wmi_vdev_start_request_cmd_fixed_param * cmd,
269 wmi_channel *chan,
270 struct vdev_start_params *req)
271{
272 chan->mhz = req->chan_freq;
273
274 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
275
276 chan->band_center_freq1 = req->band_center_freq1;
277 chan->band_center_freq2 = req->band_center_freq2;
278
279 if (req->is_half_rate)
280 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
281 else if (req->is_quarter_rate)
282 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
283
Naveen Rawat44f2f432016-12-01 12:58:57 -0800284 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530285 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
286 cmd->disable_hw_ack = req->dis_hw_ack;
287 }
288
289 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
290 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
291
292}
293#else
294static inline void copy_channel_info(
295 wmi_vdev_start_request_cmd_fixed_param * cmd,
296 wmi_channel *chan,
297 struct vdev_start_params *req)
298{
299 chan->mhz = req->channel.mhz;
300
301 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
302
303 chan->band_center_freq1 = req->channel.cfreq1;
304 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800305 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530306
307 if (req->channel.half_rate)
308 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
309 else if (req->channel.quarter_rate)
310 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
311
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800312 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
313
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530314 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530315 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530316 cmd->disable_hw_ack = req->disable_hw_ack;
317 }
318
Krishna Rao0b952ea2017-03-20 13:30:10 +0530319 if (req->channel.dfs_set_cfreq2)
320 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
321
Kai Chen4710d462017-12-15 14:06:06 -0800322 /* According to firmware both reg power and max tx power
323 * on set channel power is used and set it to max reg
324 * power from regulatory.
325 */
326 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
327 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530328 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800329 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
330 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
331 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530332
333}
334#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530335/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530336 * send_vdev_start_cmd_tlv() - send vdev start request to fw
337 * @wmi_handle: wmi handle
338 * @req: vdev start params
339 *
340 * Return: QDF status
341 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530342static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530343 struct vdev_start_params *req)
344{
345 wmi_vdev_start_request_cmd_fixed_param *cmd;
346 wmi_buf_t buf;
347 wmi_channel *chan;
348 int32_t len, ret;
349 uint8_t *buf_ptr;
350
351 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
352 buf = wmi_buf_alloc(wmi_handle, len);
353 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530354 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530355 return QDF_STATUS_E_NOMEM;
356 }
357 buf_ptr = (uint8_t *) wmi_buf_data(buf);
358 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
359 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
360 WMITLV_SET_HDR(&cmd->tlv_header,
361 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
362 WMITLV_GET_STRUCT_TLVLEN
363 (wmi_vdev_start_request_cmd_fixed_param));
364 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
365 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
366 cmd->vdev_id = req->vdev_id;
367
368 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530369 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530370
371 cmd->beacon_interval = req->beacon_intval;
372 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530373
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800374 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
375 if (req->bcn_tx_rate_code)
376 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
377
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530379 cmd->beacon_interval = req->beacon_intval;
380 cmd->dtim_period = req->dtim_period;
381
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530382 /* Copy the SSID */
383 if (req->ssid.length) {
384 if (req->ssid.length < sizeof(cmd->ssid.ssid))
385 cmd->ssid.ssid_len = req->ssid.length;
386 else
387 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
388 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
389 cmd->ssid.ssid_len);
390 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530391
392 if (req->hidden_ssid)
393 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
394
395 if (req->pmf_enabled)
396 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530397 }
398
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700399 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530400 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401 cmd->preferred_rx_streams = req->preferred_rx_streams;
402 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700403 cmd->cac_duration_ms = req->cac_duration_ms;
404 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700405 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530406
407 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
408 sizeof(wmi_channel));
409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
410 cmd->num_noa_descriptors *
411 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800412 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
414 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800415 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
416 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
417 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530418 req->is_dfs, req->beacon_intval, cmd->dtim_period,
419 chan->band_center_freq1, chan->band_center_freq2,
420 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700421 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700422 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800423 req->regdomain, req->he_ops,
424 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530425
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 if (req->is_restart)
427 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
428 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530429 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530430 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
431 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530432 if (ret) {
433 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530434 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530435 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530436 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530437
438 return QDF_STATUS_SUCCESS;
439}
440
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530441/**
442 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
443 * @wmi_handle: wmi handle
444 * @restart_params: vdev restart params
445 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530446 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530447 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530448static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530449 struct hidden_ssid_vdev_restart_params *restart_params)
450{
451 wmi_vdev_start_request_cmd_fixed_param *cmd;
452 wmi_buf_t buf;
453 wmi_channel *chan;
454 int32_t len;
455 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530456 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530457
458 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
459 buf = wmi_buf_alloc(wmi_handle, len);
460 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530461 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530462 return QDF_STATUS_E_NOMEM;
463 }
464 buf_ptr = (uint8_t *) wmi_buf_data(buf);
465 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
466 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
467
468 WMITLV_SET_HDR(&cmd->tlv_header,
469 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
470 WMITLV_GET_STRUCT_TLVLEN
471 (wmi_vdev_start_request_cmd_fixed_param));
472
473 WMITLV_SET_HDR(&chan->tlv_header,
474 WMITLV_TAG_STRUC_wmi_channel,
475 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
476
477 cmd->vdev_id = restart_params->session_id;
478 cmd->ssid.ssid_len = restart_params->ssid_len;
479 qdf_mem_copy(cmd->ssid.ssid,
480 restart_params->ssid,
481 cmd->ssid.ssid_len);
482 cmd->flags = restart_params->flags;
483 cmd->requestor_id = restart_params->requestor_id;
484 cmd->disable_hw_ack = restart_params->disable_hw_ack;
485
486 chan->mhz = restart_params->mhz;
487 chan->band_center_freq1 =
488 restart_params->band_center_freq1;
489 chan->band_center_freq2 =
490 restart_params->band_center_freq2;
491 chan->info = restart_params->info;
492 chan->reg_info_1 = restart_params->reg_info_1;
493 chan->reg_info_2 = restart_params->reg_info_2;
494
495 cmd->num_noa_descriptors = 0;
496 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
497 sizeof(wmi_channel));
498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
499 cmd->num_noa_descriptors *
500 sizeof(wmi_p2p_noa_descriptor));
501
502 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
503 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530504 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530505 wmi_buf_free(buf);
506 return QDF_STATUS_E_FAILURE;
507 }
508 return QDF_STATUS_SUCCESS;
509}
510
511
512/**
Govind Singh5eb51532016-03-09 11:34:12 +0530513 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
514 * @wmi: wmi handle
515 * @peer_addr: peer mac address
516 * @param: pointer to hold peer flush tid parameter
517 *
518 * Return: 0 for sucess or error code
519 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530520static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530521 uint8_t peer_addr[IEEE80211_ADDR_LEN],
522 struct peer_flush_params *param)
523{
524 wmi_peer_flush_tids_cmd_fixed_param *cmd;
525 wmi_buf_t buf;
526 int32_t len = sizeof(*cmd);
527
528 buf = wmi_buf_alloc(wmi, len);
529 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530530 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530531 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530532 }
533 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
534 WMITLV_SET_HDR(&cmd->tlv_header,
535 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
536 WMITLV_GET_STRUCT_TLVLEN
537 (wmi_peer_flush_tids_cmd_fixed_param));
538 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
539 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
540 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530541 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530542 peer_addr, param->vdev_id,
543 param->peer_tid_bitmap);
544 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530545 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530546 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530547 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530548 }
549
550 return 0;
551}
552
553/**
554 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
555 * @wmi: wmi handle
556 * @peer_addr: peer mac addr
557 * @vdev_id: vdev id
558 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530559 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530560 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530561static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530562 uint8_t peer_addr[IEEE80211_ADDR_LEN],
563 uint8_t vdev_id)
564{
565 wmi_peer_delete_cmd_fixed_param *cmd;
566 wmi_buf_t buf;
567 int32_t len = sizeof(*cmd);
568 buf = wmi_buf_alloc(wmi, len);
569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530570 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530571 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530572 }
573 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
574 WMITLV_SET_HDR(&cmd->tlv_header,
575 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
576 WMITLV_GET_STRUCT_TLVLEN
577 (wmi_peer_delete_cmd_fixed_param));
578 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
579 cmd->vdev_id = vdev_id;
580
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800581 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530582 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530583 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530584 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530585 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530586 }
Govind Singh5eb51532016-03-09 11:34:12 +0530587
588 return 0;
589}
590
591/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530592 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
593 * to target id.
594 * @targ_paramid: Target parameter id to hold the result.
595 * @peer_param_id: host param id.
596 *
597 * Return: QDF_STATUS_SUCCESS for success
598 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
599 */
600#ifdef CONFIG_MCL
601static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
602 uint32_t *targ_paramid,
603 uint32_t peer_param_id)
604{
605 *targ_paramid = peer_param_id;
606 return QDF_STATUS_SUCCESS;
607}
608#else
609static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
610 uint32_t *targ_paramid,
611 uint32_t peer_param_id)
612{
613 switch (peer_param_id) {
614 case WMI_HOST_PEER_MIMO_PS_STATE:
615 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
616 break;
617 case WMI_HOST_PEER_AMPDU:
618 *targ_paramid = WMI_PEER_AMPDU;
619 break;
620 case WMI_HOST_PEER_AUTHORIZE:
621 *targ_paramid = WMI_PEER_AUTHORIZE;
622 break;
623 case WMI_HOST_PEER_CHWIDTH:
624 *targ_paramid = WMI_PEER_CHWIDTH;
625 break;
626 case WMI_HOST_PEER_NSS:
627 *targ_paramid = WMI_PEER_NSS;
628 break;
629 case WMI_HOST_PEER_USE_4ADDR:
630 *targ_paramid = WMI_PEER_USE_4ADDR;
631 break;
632 case WMI_HOST_PEER_MEMBERSHIP:
633 *targ_paramid = WMI_PEER_MEMBERSHIP;
634 break;
635 case WMI_HOST_PEER_USERPOS:
636 *targ_paramid = WMI_PEER_USERPOS;
637 break;
638 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
639 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
640 break;
641 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
642 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
643 break;
644 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
645 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
646 break;
647 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
648 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
649 break;
650 case WMI_HOST_PEER_PHYMODE:
651 *targ_paramid = WMI_PEER_PHYMODE;
652 break;
653 case WMI_HOST_PEER_USE_FIXED_PWR:
654 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
655 break;
656 case WMI_HOST_PEER_PARAM_FIXED_RATE:
657 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
658 break;
659 case WMI_HOST_PEER_SET_MU_WHITELIST:
660 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
661 break;
662 case WMI_HOST_PEER_SET_MAC_TX_RATE:
663 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
664 break;
665 case WMI_HOST_PEER_SET_MIN_TX_RATE:
666 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
667 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530668 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
669 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
670 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530671 case WMI_HOST_PEER_NSS_VHT160:
672 *targ_paramid = WMI_PEER_NSS_VHT160;
673 break;
674 case WMI_HOST_PEER_NSS_VHT80_80:
675 *targ_paramid = WMI_PEER_NSS_VHT80_80;
676 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530677 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
678 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
679 break;
680 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
681 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
682 break;
683 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
684 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
685 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530686 case WMI_HOST_PEER_PARAM_MU_ENABLE:
687 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
688 break;
689 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
690 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
691 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530692 default:
693 return QDF_STATUS_E_NOSUPPORT;
694 }
695
696 return QDF_STATUS_SUCCESS;
697}
698#endif
699/**
Govind Singh5eb51532016-03-09 11:34:12 +0530700 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530701 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530702 * @peer_addr: peer mac address
703 * @param : pointer to hold peer set parameter
704 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530705 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530706 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530707static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530708 uint8_t peer_addr[IEEE80211_ADDR_LEN],
709 struct peer_set_params *param)
710{
711 wmi_peer_set_param_cmd_fixed_param *cmd;
712 wmi_buf_t buf;
713 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530714 uint32_t param_id;
715
716 if (convert_host_peer_id_to_target_id_tlv(&param_id,
717 param->param_id) != QDF_STATUS_SUCCESS)
718 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530719
720 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530722 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530723 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530724 }
725 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
726 WMITLV_SET_HDR(&cmd->tlv_header,
727 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
728 WMITLV_GET_STRUCT_TLVLEN
729 (wmi_peer_set_param_cmd_fixed_param));
730 cmd->vdev_id = param->vdev_id;
731 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530732 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530733 cmd->param_value = param->param_value;
734 err = wmi_unified_cmd_send(wmi, buf,
735 sizeof(wmi_peer_set_param_cmd_fixed_param),
736 WMI_PEER_SET_PARAM_CMDID);
737 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530738 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530739 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530740 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530741 }
742
743 return 0;
744}
745
746/**
747 * send_vdev_up_cmd_tlv() - send vdev up command in fw
748 * @wmi: wmi handle
749 * @bssid: bssid
750 * @vdev_up_params: pointer to hold vdev up parameter
751 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530752 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530753 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530754static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530755 uint8_t bssid[IEEE80211_ADDR_LEN],
756 struct vdev_up_params *params)
757{
758 wmi_vdev_up_cmd_fixed_param *cmd;
759 wmi_buf_t buf;
760 int32_t len = sizeof(*cmd);
761
Govind Singhb53420c2016-03-09 14:32:57 +0530762 WMI_LOGD("%s: VDEV_UP", __func__);
763 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530764 params->vdev_id, params->assoc_id, bssid);
765 buf = wmi_buf_alloc(wmi, len);
766 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530767 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530768 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530769 }
770 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
771 WMITLV_SET_HDR(&cmd->tlv_header,
772 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
773 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
774 cmd->vdev_id = params->vdev_id;
775 cmd->vdev_assoc_id = params->assoc_id;
776 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
777 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530778 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530779 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530780 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530781 }
782
783 return 0;
784}
785
786/**
787 * send_peer_create_cmd_tlv() - send peer create command to fw
788 * @wmi: wmi handle
789 * @peer_addr: peer mac address
790 * @peer_type: peer type
791 * @vdev_id: vdev id
792 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530793 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530794 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530795static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530796 struct peer_create_params *param)
797{
798 wmi_peer_create_cmd_fixed_param *cmd;
799 wmi_buf_t buf;
800 int32_t len = sizeof(*cmd);
801
802 buf = wmi_buf_alloc(wmi, len);
803 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530804 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530805 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530806 }
807 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
808 WMITLV_SET_HDR(&cmd->tlv_header,
809 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
810 WMITLV_GET_STRUCT_TLVLEN
811 (wmi_peer_create_cmd_fixed_param));
812 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
813 cmd->peer_type = param->peer_type;
814 cmd->vdev_id = param->vdev_id;
815
816 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530817 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530818 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530819 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530820 }
Govind Singhb53420c2016-03-09 14:32:57 +0530821 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530822 param->vdev_id);
823
824 return 0;
825}
826
827/**
Leo Changeee40872016-09-28 13:43:36 -0700828 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
829 * command to fw
830 * @wmi: wmi handle
831 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
832 *
833 * Return: 0 for success or error code
834 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700835static
Leo Changeee40872016-09-28 13:43:36 -0700836QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
837 struct rx_reorder_queue_setup_params *param)
838{
839 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
840 wmi_buf_t buf;
841 int32_t len = sizeof(*cmd);
842
843 buf = wmi_buf_alloc(wmi, len);
844 if (!buf) {
845 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
846 return QDF_STATUS_E_NOMEM;
847 }
848 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
849 WMITLV_SET_HDR(&cmd->tlv_header,
850 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
851 WMITLV_GET_STRUCT_TLVLEN
852 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
853 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
854 cmd->vdev_id = param->vdev_id;
855 cmd->tid = param->tid;
856 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
857 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
858 cmd->queue_no = param->queue_no;
859
860 if (wmi_unified_cmd_send(wmi, buf, len,
861 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
862 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
863 __func__);
864 qdf_nbuf_free(buf);
865 return QDF_STATUS_E_FAILURE;
866 }
867 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
868 param->peer_macaddr, param->vdev_id, param->tid);
869
870 return QDF_STATUS_SUCCESS;
871}
872
873/**
874 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
875 * command to fw
876 * @wmi: wmi handle
877 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
878 *
879 * Return: 0 for success or error code
880 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700881static
Leo Changeee40872016-09-28 13:43:36 -0700882QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
883 struct rx_reorder_queue_remove_params *param)
884{
885 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
886 wmi_buf_t buf;
887 int32_t len = sizeof(*cmd);
888
889 buf = wmi_buf_alloc(wmi, len);
890 if (!buf) {
891 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
892 return QDF_STATUS_E_NOMEM;
893 }
894 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
895 wmi_buf_data(buf);
896 WMITLV_SET_HDR(&cmd->tlv_header,
897 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
898 WMITLV_GET_STRUCT_TLVLEN
899 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
900 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
901 cmd->vdev_id = param->vdev_id;
902 cmd->tid_mask = param->peer_tid_bitmap;
903
904 if (wmi_unified_cmd_send(wmi, buf, len,
905 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
906 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
907 __func__);
908 qdf_nbuf_free(buf);
909 return QDF_STATUS_E_FAILURE;
910 }
911 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
912 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
913
914 return QDF_STATUS_SUCCESS;
915}
916
917/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530918 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
919 * @wmi_handle: wmi handle
920 * @param: pointer holding peer details
921 *
922 * Return: 0 for success or error code
923 */
924static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
925 struct peer_add_wds_entry_params *param)
926{
927 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
928 wmi_buf_t buf;
929 int len = sizeof(*cmd);
930
931 buf = wmi_buf_alloc(wmi_handle, len);
932 if (!buf) {
933 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
934 return QDF_STATUS_E_FAILURE;
935 }
936 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
937 WMITLV_SET_HDR(&cmd->tlv_header,
938 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
939 WMITLV_GET_STRUCT_TLVLEN
940 (wmi_peer_add_wds_entry_cmd_fixed_param));
941 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
942 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800943 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
944 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530945
946 return wmi_unified_cmd_send(wmi_handle, buf, len,
947 WMI_PEER_ADD_WDS_ENTRY_CMDID);
948}
949
950/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530951 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530952 * @wmi_handle: wmi handle
953 * @param: pointer holding peer details
954 *
955 * Return: 0 for success or error code
956 */
957static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
958 struct peer_del_wds_entry_params *param)
959{
960 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
961 wmi_buf_t buf;
962 int len = sizeof(*cmd);
963
964 buf = wmi_buf_alloc(wmi_handle, len);
965 if (!buf) {
966 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
967 return QDF_STATUS_E_NOMEM;
968 }
969 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
970 WMITLV_SET_HDR(&cmd->tlv_header,
971 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
972 WMITLV_GET_STRUCT_TLVLEN
973 (wmi_peer_remove_wds_entry_cmd_fixed_param));
974 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800975 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530976 return wmi_unified_cmd_send(wmi_handle, buf, len,
977 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
978}
979
980/**
981 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
982 * @wmi_handle: wmi handle
983 * @param: pointer holding peer details
984 *
985 * Return: 0 for success or error code
986 */
987static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
988 struct peer_update_wds_entry_params *param)
989{
990 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
991 wmi_buf_t buf;
992 int len = sizeof(*cmd);
993
994 buf = wmi_buf_alloc(wmi_handle, len);
995 if (!buf) {
996 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
997 return QDF_STATUS_E_NOMEM;
998 }
999
1000 /* wmi_buf_alloc returns zeroed command buffer */
1001 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1002 WMITLV_SET_HDR(&cmd->tlv_header,
1003 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1004 WMITLV_GET_STRUCT_TLVLEN
1005 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001006 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1007 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301008 if (param->wds_macaddr)
1009 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1010 &cmd->wds_macaddr);
1011 if (param->peer_macaddr)
1012 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1013 &cmd->peer_macaddr);
1014 return wmi_unified_cmd_send(wmi_handle, buf, len,
1015 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1016}
1017
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001018/**
1019 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1020 * @wmi_handle: wmi handle
1021 * @param: pointer to get tpc config params
1022 *
1023 * Return: 0 for success or error code
1024 */
1025static QDF_STATUS
1026send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1027 uint32_t param)
1028{
1029 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1030 wmi_buf_t buf;
1031 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1032
1033 buf = wmi_buf_alloc(wmi_handle, len);
1034 if (!buf) {
1035 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1036 return QDF_STATUS_E_NOMEM;
1037 }
1038 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1039 WMITLV_SET_HDR(&cmd->tlv_header,
1040 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1041 WMITLV_GET_STRUCT_TLVLEN
1042 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1043
1044 cmd->param = param;
1045 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1046 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1047 WMI_LOGE("Send pdev get tpc config cmd failed");
1048 wmi_buf_free(buf);
1049 return QDF_STATUS_E_FAILURE;
1050
1051 }
1052 WMI_LOGD("%s:send success", __func__);
1053
1054 return QDF_STATUS_SUCCESS;
1055}
1056
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301057#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301058/**
Govind Singh5eb51532016-03-09 11:34:12 +05301059 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1060 * @wmi_handle: wmi handle
1061 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301062 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301063 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301064 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301065 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301066static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301067 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301068{
1069 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1070 wmi_buf_t buf;
1071 int32_t len = sizeof(*cmd);
1072
Govind Singhb53420c2016-03-09 14:32:57 +05301073 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301074
1075 buf = wmi_buf_alloc(wmi_handle, len);
1076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301077 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301078 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301079 }
1080
1081 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1082 WMITLV_SET_HDR(&cmd->tlv_header,
1083 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1084 WMITLV_GET_STRUCT_TLVLEN
1085 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301086 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301087 cmd->enable = value;
1088
1089 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1090 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301091 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301092 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301093 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301094 }
1095
1096 return 0;
1097}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301098#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301099
1100/**
1101 * send_pdev_utf_cmd_tlv() - send utf command to fw
1102 * @wmi_handle: wmi handle
1103 * @param: pointer to pdev_utf_params
1104 * @mac_id: mac id to have radio context
1105 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301106 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301108static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301109send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1110 struct pdev_utf_params *param,
1111 uint8_t mac_id)
1112{
1113 wmi_buf_t buf;
1114 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001115 /* if param->len is 0 no data is sent, return error */
1116 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301117 static uint8_t msgref = 1;
1118 uint8_t segNumber = 0, segInfo, numSegments;
1119 uint16_t chunk_len, total_bytes;
1120 uint8_t *bufpos;
1121 struct seg_hdr_info segHdrInfo;
1122
1123 bufpos = param->utf_payload;
1124 total_bytes = param->len;
1125 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1126 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1127 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1128
1129 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1130 numSegments++;
1131
1132 while (param->len) {
1133 if (param->len > MAX_WMI_UTF_LEN)
1134 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1135 else
1136 chunk_len = param->len;
1137
1138 buf = wmi_buf_alloc(wmi_handle,
1139 (chunk_len + sizeof(segHdrInfo) +
1140 WMI_TLV_HDR_SIZE));
1141 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301142 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301143 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301144 }
1145
1146 cmd = (uint8_t *) wmi_buf_data(buf);
1147
1148 segHdrInfo.len = total_bytes;
1149 segHdrInfo.msgref = msgref;
1150 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1151 segHdrInfo.segmentInfo = segInfo;
1152 segHdrInfo.pad = 0;
1153
Govind Singhb53420c2016-03-09 14:32:57 +05301154 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301155 " segHdrInfo.segmentInfo = %d",
1156 __func__, segHdrInfo.len, segHdrInfo.msgref,
1157 segHdrInfo.segmentInfo);
1158
Govind Singhb53420c2016-03-09 14:32:57 +05301159 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301160 "chunk len %d", __func__, total_bytes, segNumber,
1161 numSegments, chunk_len);
1162
1163 segNumber++;
1164
1165 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1166 (chunk_len + sizeof(segHdrInfo)));
1167 cmd += WMI_TLV_HDR_SIZE;
1168 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1169 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1170
1171 ret = wmi_unified_cmd_send(wmi_handle, buf,
1172 (chunk_len + sizeof(segHdrInfo) +
1173 WMI_TLV_HDR_SIZE),
1174 WMI_PDEV_UTF_CMDID);
1175
Govind Singh67922e82016-04-01 16:48:57 +05301176 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301177 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301178 wmi_buf_free(buf);
1179 break;
1180 }
1181
1182 param->len -= chunk_len;
1183 bufpos += chunk_len;
1184 }
1185
1186 msgref++;
1187
1188 return ret;
1189}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301190#ifdef CONFIG_MCL
1191static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1192 uint32_t host_param)
1193{
1194 return host_param;
1195}
1196#else
1197static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1198 uint32_t host_param)
1199{
1200 if (host_param < wmi_pdev_param_max)
1201 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301202
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301203 return WMI_UNAVAILABLE_PARAM;
1204}
1205#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301206/**
1207 * send_pdev_param_cmd_tlv() - set pdev parameters
1208 * @wmi_handle: wmi handle
1209 * @param: pointer to pdev parameter
1210 * @mac_id: radio context
1211 *
1212 * Return: 0 on success, errno on failure
1213 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301214static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301215send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1216 struct pdev_params *param,
1217 uint8_t mac_id)
1218{
Govind Singh67922e82016-04-01 16:48:57 +05301219 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301220 wmi_pdev_set_param_cmd_fixed_param *cmd;
1221 wmi_buf_t buf;
1222 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301223 uint32_t pdev_param;
1224
1225 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1226 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1227 WMI_LOGW("%s: Unavailable param %d\n",
1228 __func__, param->param_id);
1229 return QDF_STATUS_E_INVAL;
1230 }
Govind Singh5eb51532016-03-09 11:34:12 +05301231
1232 buf = wmi_buf_alloc(wmi_handle, len);
1233 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301234 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301235 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301236 }
1237 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1238 WMITLV_SET_HDR(&cmd->tlv_header,
1239 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1240 WMITLV_GET_STRUCT_TLVLEN
1241 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301242 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301243 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301244 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301245 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301246 param->param_value);
1247 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1248 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301249 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301250 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301251 wmi_buf_free(buf);
1252 }
1253 return ret;
1254}
1255
1256/**
1257 * send_suspend_cmd_tlv() - WMI suspend function
1258 * @param wmi_handle : handle to WMI.
1259 * @param param : pointer to hold suspend parameter
1260 * @mac_id: radio context
1261 *
1262 * Return 0 on success and -ve on failure.
1263 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301264static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301265 struct suspend_params *param,
1266 uint8_t mac_id)
1267{
1268 wmi_pdev_suspend_cmd_fixed_param *cmd;
1269 wmi_buf_t wmibuf;
1270 uint32_t len = sizeof(*cmd);
1271 int32_t ret;
1272
1273 /*
1274 * send the comand to Target to ignore the
1275 * PCIE reset so as to ensure that Host and target
1276 * states are in sync
1277 */
1278 wmibuf = wmi_buf_alloc(wmi_handle, len);
1279 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301280 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301281
1282 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1283 WMITLV_SET_HDR(&cmd->tlv_header,
1284 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1285 WMITLV_GET_STRUCT_TLVLEN
1286 (wmi_pdev_suspend_cmd_fixed_param));
1287 if (param->disable_target_intr)
1288 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1289 else
1290 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301291
1292 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1293
Govind Singh5eb51532016-03-09 11:34:12 +05301294 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1295 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301296 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301297 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301298 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301299 }
1300
1301 return ret;
1302}
1303
1304/**
1305 * send_resume_cmd_tlv() - WMI resume function
1306 * @param wmi_handle : handle to WMI.
1307 * @mac_id: radio context
1308 *
1309 * Return: 0 on success and -ve on failure.
1310 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301311static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301312 uint8_t mac_id)
1313{
1314 wmi_buf_t wmibuf;
1315 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301316 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301317
1318 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1319 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301320 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301321 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1322 WMITLV_SET_HDR(&cmd->tlv_header,
1323 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1324 WMITLV_GET_STRUCT_TLVLEN
1325 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301326 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301327 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1328 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301329 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301330 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301331 wmi_buf_free(wmibuf);
1332 }
1333
1334 return ret;
1335}
1336
Will Huang422ac9a2017-11-17 13:19:16 +08001337#ifdef FEATURE_WLAN_D0WOW
1338/**
1339 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1340 * @param wmi_handle: handle to WMI.
1341 * @mac_id: radio context
1342 *
1343 * Return: 0 on success and error code on failure.
1344 */
1345static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1346 uint8_t mac_id)
1347{
1348 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1349 wmi_buf_t buf;
1350 int32_t len;
1351 QDF_STATUS status;
1352
1353 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1354
1355 buf = wmi_buf_alloc(wmi_handle, len);
1356 if (!buf) {
1357 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1358 return QDF_STATUS_E_NOMEM;
1359 }
1360 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1361 WMITLV_SET_HDR(&cmd->tlv_header,
1362 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1363 WMITLV_GET_STRUCT_TLVLEN
1364 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1365
1366 cmd->enable = true;
1367
1368 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1369 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1370 if (QDF_IS_STATUS_ERROR(status))
1371 wmi_buf_free(buf);
1372
1373 return status;
1374}
1375
1376/**
1377 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1378 * @param wmi_handle: handle to WMI.
1379 * @mac_id: radio context
1380 *
1381 * Return: 0 on success and error code on failure.
1382 */
1383static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1384 uint8_t mac_id)
1385{
1386 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1387 wmi_buf_t buf;
1388 int32_t len;
1389 QDF_STATUS status;
1390
1391 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1392
1393 buf = wmi_buf_alloc(wmi_handle, len);
1394 if (!buf) {
1395 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1396 return QDF_STATUS_E_NOMEM;
1397 }
1398 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1399 WMITLV_SET_HDR(&cmd->tlv_header,
1400 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1401 WMITLV_GET_STRUCT_TLVLEN
1402 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1403
1404 cmd->enable = false;
1405
1406 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1407 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1408 if (QDF_IS_STATUS_ERROR(status))
1409 wmi_buf_free(buf);
1410
1411 return status;
1412}
1413#endif
1414
Govind Singh5eb51532016-03-09 11:34:12 +05301415/**
1416 * send_wow_enable_cmd_tlv() - WMI wow enable function
1417 * @param wmi_handle : handle to WMI.
1418 * @param param : pointer to hold wow enable parameter
1419 * @mac_id: radio context
1420 *
1421 * Return: 0 on success and -ve on failure.
1422 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301423static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301424 struct wow_cmd_params *param,
1425 uint8_t mac_id)
1426{
1427 wmi_wow_enable_cmd_fixed_param *cmd;
1428 wmi_buf_t buf;
1429 int32_t len;
1430 int32_t ret;
1431
1432 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1433
1434 buf = wmi_buf_alloc(wmi_handle, len);
1435 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301436 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1437 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301438 }
1439 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1440 WMITLV_SET_HDR(&cmd->tlv_header,
1441 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1442 WMITLV_GET_STRUCT_TLVLEN
1443 (wmi_wow_enable_cmd_fixed_param));
1444 cmd->enable = param->enable;
1445 if (param->can_suspend_link)
1446 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1447 else
1448 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001449 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301450
Govind Singhb53420c2016-03-09 14:32:57 +05301451 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301452 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1453 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1454
1455 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1456 WMI_WOW_ENABLE_CMDID);
1457 if (ret)
1458 wmi_buf_free(buf);
1459
1460 return ret;
1461}
1462
1463/**
1464 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301465 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301466 * @peer_addr: peer mac address
1467 * @param: pointer to ap_ps parameter structure
1468 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301469 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301470 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301471static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301472 uint8_t *peer_addr,
1473 struct ap_ps_params *param)
1474{
1475 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1476 wmi_buf_t buf;
1477 int32_t err;
1478
1479 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301481 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301482 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301483 }
1484 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1485 WMITLV_SET_HDR(&cmd->tlv_header,
1486 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1487 WMITLV_GET_STRUCT_TLVLEN
1488 (wmi_ap_ps_peer_cmd_fixed_param));
1489 cmd->vdev_id = param->vdev_id;
1490 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1491 cmd->param = param->param;
1492 cmd->value = param->value;
1493 err = wmi_unified_cmd_send(wmi_handle, buf,
1494 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1495 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301496 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301497 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301498 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301499 }
1500
1501 return 0;
1502}
1503
1504/**
1505 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301506 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301507 * @peer_addr: peer mac address
1508 * @param: pointer to sta_ps parameter structure
1509 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301510 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301511 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301512static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301513 struct sta_ps_params *param)
1514{
1515 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1516 wmi_buf_t buf;
1517 int32_t len = sizeof(*cmd);
1518
1519 buf = wmi_buf_alloc(wmi_handle, len);
1520 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301521 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301522 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301523 }
1524
1525 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1526 WMITLV_SET_HDR(&cmd->tlv_header,
1527 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1528 WMITLV_GET_STRUCT_TLVLEN
1529 (wmi_sta_powersave_param_cmd_fixed_param));
1530 cmd->vdev_id = param->vdev_id;
1531 cmd->param = param->param;
1532 cmd->value = param->value;
1533
1534 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1535 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301536 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301537 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301538 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301539 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301540 }
1541
1542 return 0;
1543}
1544
1545/**
1546 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301547 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301548 * @param: ponirt to crash inject paramter structure
1549 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301550 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301551 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301552static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301553 struct crash_inject *param)
1554{
1555 int32_t ret = 0;
1556 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1557 uint16_t len = sizeof(*cmd);
1558 wmi_buf_t buf;
1559
1560 buf = wmi_buf_alloc(wmi_handle, len);
1561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301562 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301563 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301564 }
1565
1566 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1567 WMITLV_SET_HDR(&cmd->tlv_header,
1568 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1569 WMITLV_GET_STRUCT_TLVLEN
1570 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1571 cmd->type = param->type;
1572 cmd->delay_time_ms = param->delay_time_ms;
1573
1574 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1575 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301576 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301577 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301578 __func__, ret);
1579 wmi_buf_free(buf);
1580 }
1581
1582 return ret;
1583}
1584
1585/**
1586 * send_dbglog_cmd_tlv() - set debug log level
1587 * @param wmi_handle : handle to WMI.
1588 * @param param : pointer to hold dbglog level parameter
1589 *
1590 * Return: 0 on success and -ve on failure.
1591 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301592 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301593send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1594 struct dbglog_params *dbglog_param)
1595{
1596 wmi_buf_t buf;
1597 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001598 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301599 int32_t i;
1600 int32_t len;
1601 int8_t *buf_ptr;
1602 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1603
Alok Kumar240afea2017-08-30 14:45:34 +05301604 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301605
1606 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1607 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1608 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1609 buf = wmi_buf_alloc(wmi_handle, len);
1610 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001611 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301612
1613 configmsg =
1614 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1615 buf_ptr = (int8_t *) configmsg;
1616 WMITLV_SET_HDR(&configmsg->tlv_header,
1617 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1618 WMITLV_GET_STRUCT_TLVLEN
1619 (wmi_debug_log_config_cmd_fixed_param));
1620 configmsg->dbg_log_param = dbglog_param->param;
1621 configmsg->value = dbglog_param->val;
1622 /* Filling in the data part of second tlv -- should
1623 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301624 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301625 sizeof
1626 (wmi_debug_log_config_cmd_fixed_param)
1627 + WMI_TLV_HDR_SIZE);
1628 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1629 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301630 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301631 if (dbglog_param->module_id_bitmap) {
1632 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1633 module_id_bitmap_array[i] =
1634 dbglog_param->module_id_bitmap[i];
1635 }
1636 }
1637
1638 status = wmi_unified_cmd_send(wmi_handle, buf,
1639 len, WMI_DBGLOG_CFG_CMDID);
1640
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001641 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301642 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301643
1644 return status;
1645}
1646
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301647#ifdef CONFIG_MCL
1648static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1649 uint32_t host_param)
1650{
1651 return host_param;
1652}
1653#else
1654static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1655 uint32_t host_param)
1656{
1657 if (host_param < wmi_vdev_param_max)
1658 return wmi_handle->vdev_param[host_param];
1659
1660 return WMI_UNAVAILABLE_PARAM;
1661}
1662#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301663/**
1664 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1665 * @param wmi_handle : handle to WMI.
1666 * @param macaddr : MAC address
1667 * @param param : pointer to hold vdev set parameter
1668 *
1669 * Return: 0 on success and -ve on failure.
1670 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301671static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301672 struct vdev_set_params *param)
1673{
Govind Singh67922e82016-04-01 16:48:57 +05301674 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301675 wmi_vdev_set_param_cmd_fixed_param *cmd;
1676 wmi_buf_t buf;
1677 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301678 uint32_t vdev_param;
1679
1680 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1681 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1682 WMI_LOGW("%s:Vdev param %d not available", __func__,
1683 param->param_id);
1684 return QDF_STATUS_E_INVAL;
1685
1686 }
Govind Singh5eb51532016-03-09 11:34:12 +05301687
1688 buf = wmi_buf_alloc(wmi_handle, len);
1689 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301690 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301691 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301692 }
1693 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1694 WMITLV_SET_HDR(&cmd->tlv_header,
1695 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1696 WMITLV_GET_STRUCT_TLVLEN
1697 (wmi_vdev_set_param_cmd_fixed_param));
1698 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301699 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301700 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301701 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001702 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301703 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1704 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301705 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301706 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301707 wmi_buf_free(buf);
1708 }
1709
1710 return ret;
1711}
1712
1713/**
1714 * send_stats_request_cmd_tlv() - WMI request stats function
1715 * @param wmi_handle : handle to WMI.
1716 * @param macaddr : MAC address
1717 * @param param : pointer to hold stats request parameter
1718 *
1719 * Return: 0 on success and -ve on failure.
1720 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301721static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301722 uint8_t macaddr[IEEE80211_ADDR_LEN],
1723 struct stats_request_params *param)
1724{
Govind Singhd3156eb2016-02-26 17:50:39 +05301725 int32_t ret;
1726 wmi_request_stats_cmd_fixed_param *cmd;
1727 wmi_buf_t buf;
1728 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1729
1730 buf = wmi_buf_alloc(wmi_handle, len);
1731 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301732 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1733 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301734 }
1735
1736 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1737 WMITLV_SET_HDR(&cmd->tlv_header,
1738 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1739 WMITLV_GET_STRUCT_TLVLEN
1740 (wmi_request_stats_cmd_fixed_param));
1741 cmd->stats_id = param->stats_id;
1742 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301743 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1744 param->pdev_id);
1745 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001746
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301747 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1748 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001749
1750 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1751 WMI_REQUEST_STATS_CMDID);
1752
Govind Singhd3156eb2016-02-26 17:50:39 +05301753 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301754 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301755 wmi_buf_free(buf);
1756 }
1757
1758 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301759}
1760
Govind Singh87542482016-06-08 19:40:11 +05301761#ifdef CONFIG_WIN
1762/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001763 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301764 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001765 * @param PKTLOG_EVENT : packet log event
1766 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301767 *
1768 * Return: 0 on success and -ve on failure.
1769 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301770static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001771 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301772{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001773 int32_t ret;
1774 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1775 wmi_buf_t buf;
1776 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1777
1778 buf = wmi_buf_alloc(wmi_handle, len);
1779 if (!buf) {
1780 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1781 return -QDF_STATUS_E_NOMEM;
1782 }
1783
1784 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1785 WMITLV_SET_HDR(&cmd->tlv_header,
1786 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1787 WMITLV_GET_STRUCT_TLVLEN
1788 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1789 cmd->evlist = PKTLOG_EVENT;
1790 cmd->pdev_id = mac_id;
1791 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1792 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1793 if (ret) {
1794 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1795 wmi_buf_free(buf);
1796 }
1797
1798 return ret;
1799}
1800
1801/**
1802 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1803 * @param wmi_handle : handle to WMI.
1804 * @mac_id: mac id to have radio context
1805 *
1806 * Return: 0 on success and -ve on failure.
1807 */
1808static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001809 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001810{
1811 int32_t ret;
1812 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1813 wmi_buf_t buf;
1814 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1815
1816 buf = wmi_buf_alloc(wmi_handle, len);
1817 if (!buf) {
1818 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1819 return -QDF_STATUS_E_NOMEM;
1820 }
1821
1822 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1823 WMITLV_SET_HDR(&cmd->tlv_header,
1824 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1825 WMITLV_GET_STRUCT_TLVLEN
1826 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1827 cmd->pdev_id = mac_id;
1828 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1829 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1830 if (ret) {
1831 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1832 wmi_buf_free(buf);
1833 }
1834
1835 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301836}
1837#else
Govind Singh5eb51532016-03-09 11:34:12 +05301838/**
Keyur Parekhde522342017-08-18 14:01:05 -07001839 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1840 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301841 * @param wmi_handle : handle to WMI.
1842 * @param macaddr : MAC address
1843 * @param param : pointer to hold stats request parameter
1844 *
1845 * Return: 0 on success and -ve on failure.
1846 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301847static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301848 uint8_t macaddr[IEEE80211_ADDR_LEN],
1849 struct packet_enable_params *param)
1850{
1851 return 0;
1852}
Keyur Parekhde522342017-08-18 14:01:05 -07001853/**
1854 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1855 * packet-log
1856 * @param wmi_handle : handle to WMI.
1857 * @mac_id: mac id to have radio context
1858 *
1859 * Return: 0 on success and -ve on failure.
1860 */
1861static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1862 uint8_t mac_id)
1863{
1864 return 0;
1865}
Govind Singh87542482016-06-08 19:40:11 +05301866#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301867
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301868#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1869/**
1870 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1871 * sync time between bwtween host and firmware
1872 * @param wmi_handle : handle to WMI.
1873 *
1874 * Return: None
1875 */
1876static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1877{
1878 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001879 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301880 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1881 int32_t len;
1882 qdf_time_t time_ms;
1883
1884 len = sizeof(*time_stamp);
1885 buf = wmi_buf_alloc(wmi_handle, len);
1886
1887 if (!buf) {
1888 WMI_LOGP(FL("wmi_buf_alloc failed"));
1889 return;
1890 }
1891 time_stamp =
1892 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1893 (wmi_buf_data(buf));
1894 WMITLV_SET_HDR(&time_stamp->tlv_header,
1895 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1896 WMITLV_GET_STRUCT_TLVLEN(
1897 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1898
1899 time_ms = qdf_get_time_of_the_day_ms();
1900 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1901 time_stamp->time_stamp_low = time_ms &
1902 WMI_FW_TIME_STAMP_LOW_MASK;
1903 /*
1904 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1905 * wont exceed 27 bit
1906 */
1907 time_stamp->time_stamp_high = 0;
1908 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1909 time_stamp->mode, time_stamp->time_stamp_low,
1910 time_stamp->time_stamp_high);
1911
1912 status = wmi_unified_cmd_send(wmi_handle, buf,
1913 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1914 if (status) {
1915 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1916 wmi_buf_free(buf);
1917 }
1918
1919}
1920
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301921#ifdef WLAN_SUPPORT_FILS
1922/**
1923 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1924 * @wmi_handle: wmi handle
1925 * @evt_buf: pointer to event buffer
1926 * @vdev_id: pointer to hold vdev id
1927 *
1928 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1929 */
1930static QDF_STATUS
1931extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1932 void *evt_buf, uint32_t *vdev_id)
1933{
1934 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1935 wmi_host_swfda_event_fixed_param *swfda_event;
1936
1937 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1938 if (!param_buf) {
1939 WMI_LOGE("Invalid swfda event buffer");
1940 return QDF_STATUS_E_INVAL;
1941 }
1942 swfda_event = param_buf->fixed_param;
1943 *vdev_id = swfda_event->vdev_id;
1944
1945 return QDF_STATUS_SUCCESS;
1946}
1947
1948/**
1949 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1950 * @wmi_handle: wmi handle
1951 * @param: pointer to hold FILS discovery enable param
1952 *
1953 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1954 */
1955static QDF_STATUS
1956send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1957 struct config_fils_params *param)
1958{
1959 wmi_enable_fils_cmd_fixed_param *cmd;
1960 wmi_buf_t buf;
1961 QDF_STATUS status;
1962 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1963
1964 buf = wmi_buf_alloc(wmi_handle, len);
1965 if (!buf) {
1966 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1967 return QDF_STATUS_E_NOMEM;
1968 }
1969 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1970 WMITLV_SET_HDR(&cmd->tlv_header,
1971 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1972 WMITLV_GET_STRUCT_TLVLEN(
1973 wmi_enable_fils_cmd_fixed_param));
1974 cmd->vdev_id = param->vdev_id;
1975 cmd->fd_period = param->fd_period;
1976 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1977 param->fd_period, param->vdev_id);
1978
1979 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1980 WMI_ENABLE_FILS_CMDID);
1981 if (status != QDF_STATUS_SUCCESS) {
1982 wmi_buf_free(buf);
1983 return QDF_STATUS_E_FAILURE;
1984 }
1985
1986 return QDF_STATUS_SUCCESS;
1987}
1988
1989/**
1990 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1991 * @wmi_handle: wmi handle
1992 * @param: pointer to hold FD send cmd parameter
1993 *
1994 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1995 */
1996static QDF_STATUS
1997send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1998 struct fd_params *param)
1999{
2000 QDF_STATUS ret;
2001 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2002 wmi_buf_t wmi_buf;
2003 qdf_dma_addr_t dma_addr;
2004
2005 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2006 if (!wmi_buf) {
2007 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2008 return QDF_STATUS_E_NOMEM;
2009 }
2010 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2011 WMITLV_SET_HDR(&cmd->tlv_header,
2012 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2013 WMITLV_GET_STRUCT_TLVLEN(
2014 wmi_fd_send_from_host_cmd_fixed_param));
2015 cmd->vdev_id = param->vdev_id;
2016 cmd->data_len = qdf_nbuf_len(param->wbuf);
2017 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2018 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2019 cmd->frame_ctrl = param->frame_ctrl;
2020
2021 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2022 WMI_PDEV_SEND_FD_CMDID);
2023 if (ret != QDF_STATUS_SUCCESS) {
2024 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2025 __func__, ret);
2026 wmi_buf_free(wmi_buf);
2027 }
2028
2029 return ret;
2030}
2031#endif /* WLAN_SUPPORT_FILS */
2032
Sathish Kumarfd347372017-02-13 12:29:09 +05302033static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302034 struct beacon_params *param)
2035{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302036 QDF_STATUS ret;
2037 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2038 wmi_buf_t wmi_buf;
2039 qdf_dma_addr_t dma_addr;
2040 uint32_t dtim_flag = 0;
2041
2042 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2043 if (!wmi_buf) {
2044 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2045 return QDF_STATUS_E_NOMEM;
2046 }
2047 if (param->is_dtim_count_zero) {
2048 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2049 if (param->is_bitctl_reqd) {
2050 /* deliver CAB traffic in next DTIM beacon */
2051 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2052 }
2053 }
2054 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2055 WMITLV_SET_HDR(&cmd->tlv_header,
2056 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2057 WMITLV_GET_STRUCT_TLVLEN
2058 (wmi_bcn_send_from_host_cmd_fixed_param));
2059 cmd->vdev_id = param->vdev_id;
2060 cmd->data_len = qdf_nbuf_len(param->wbuf);
2061 cmd->frame_ctrl = param->frame_ctrl;
2062 cmd->dtim_flag = dtim_flag;
2063 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2064 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2065#if defined(HTT_PADDR64)
2066 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2067#endif
2068 cmd->bcn_antenna = param->bcn_txant;
2069
2070 ret = wmi_unified_cmd_send(wmi_handle,
2071 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2072 if (ret != QDF_STATUS_SUCCESS) {
2073 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2074 wmi_buf_free(wmi_buf);
2075 }
2076
2077 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302078}
2079
2080/**
2081 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2082 * @param wmi_handle : handle to WMI.
2083 * @param param : pointer to hold beacon send cmd parameter
2084 *
2085 * Return: 0 on success and -ve on failure.
2086 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302087static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302088 struct beacon_tmpl_params *param)
2089{
2090 int32_t ret;
2091 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2092 wmi_bcn_prb_info *bcn_prb_info;
2093 wmi_buf_t wmi_buf;
2094 uint8_t *buf_ptr;
2095 uint32_t wmi_buf_len;
2096
2097 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2098 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2099 param->tmpl_len_aligned;
2100 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2101 if (!wmi_buf) {
2102 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2103 return QDF_STATUS_E_NOMEM;
2104 }
2105 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2106 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2107 WMITLV_SET_HDR(&cmd->tlv_header,
2108 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2109 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2110 cmd->vdev_id = param->vdev_id;
2111 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302112 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2113 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302114 cmd->buf_len = param->tmpl_len;
2115 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2116
2117 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2118 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2119 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2120 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2121 bcn_prb_info->caps = 0;
2122 bcn_prb_info->erp = 0;
2123 buf_ptr += sizeof(wmi_bcn_prb_info);
2124
2125 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2126 buf_ptr += WMI_TLV_HDR_SIZE;
2127 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2128
2129 ret = wmi_unified_cmd_send(wmi_handle,
2130 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2131 if (ret) {
2132 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2133 wmi_buf_free(wmi_buf);
2134 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302135
Govind Singh87542482016-06-08 19:40:11 +05302136 return 0;
2137}
Govind Singh5eb51532016-03-09 11:34:12 +05302138
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302139#ifdef CONFIG_MCL
2140static inline void copy_peer_flags_tlv(
2141 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2142 struct peer_assoc_params *param)
2143{
2144 cmd->peer_flags = param->peer_flags;
2145}
2146#else
2147static inline void copy_peer_flags_tlv(
2148 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2149 struct peer_assoc_params *param)
2150{
2151 /*
2152 * The target only needs a subset of the flags maintained in the host.
2153 * Just populate those flags and send it down
2154 */
2155 cmd->peer_flags = 0;
2156
2157 /*
2158 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2159 */
2160 if (param->is_wme_set) {
2161
2162 if (param->qos_flag)
2163 cmd->peer_flags |= WMI_PEER_QOS;
2164 if (param->apsd_flag)
2165 cmd->peer_flags |= WMI_PEER_APSD;
2166 if (param->ht_flag)
2167 cmd->peer_flags |= WMI_PEER_HT;
2168 if (param->bw_40)
2169 cmd->peer_flags |= WMI_PEER_40MHZ;
2170 if (param->bw_80)
2171 cmd->peer_flags |= WMI_PEER_80MHZ;
2172 if (param->bw_160)
2173 cmd->peer_flags |= WMI_PEER_160MHZ;
2174
2175 /* Typically if STBC is enabled for VHT it should be enabled
2176 * for HT as well
2177 **/
2178 if (param->stbc_flag)
2179 cmd->peer_flags |= WMI_PEER_STBC;
2180
2181 /* Typically if LDPC is enabled for VHT it should be enabled
2182 * for HT as well
2183 **/
2184 if (param->ldpc_flag)
2185 cmd->peer_flags |= WMI_PEER_LDPC;
2186
2187 if (param->static_mimops_flag)
2188 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2189 if (param->dynamic_mimops_flag)
2190 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2191 if (param->spatial_mux_flag)
2192 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2193 if (param->vht_flag)
2194 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002195 if (param->he_flag)
2196 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302197 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002198
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302199 if (param->is_pmf_enabled)
2200 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302201 /*
2202 * Suppress authorization for all AUTH modes that need 4-way handshake
2203 * (during re-association).
2204 * Authorization will be done for these modes on key installation.
2205 */
2206 if (param->auth_flag)
2207 cmd->peer_flags |= WMI_PEER_AUTH;
2208 if (param->need_ptk_4_way)
2209 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2210 else
2211 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2212 if (param->need_gtk_2_way)
2213 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2214 /* safe mode bypass the 4-way handshake */
2215 if (param->safe_mode_enabled)
2216 cmd->peer_flags &=
2217 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2218 /* Disable AMSDU for station transmit, if user configures it */
2219 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2220 * it
2221 * if (param->amsdu_disable) Add after FW support
2222 **/
2223
2224 /* Target asserts if node is marked HT and all MCS is set to 0.
2225 * Mark the node as non-HT if all the mcs rates are disabled through
2226 * iwpriv
2227 **/
2228 if (param->peer_ht_rates.num_rates == 0)
2229 cmd->peer_flags &= ~WMI_PEER_HT;
2230}
2231#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302232
2233#ifdef CONFIG_MCL
2234static inline void copy_peer_mac_addr_tlv(
2235 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2236 struct peer_assoc_params *param)
2237{
2238 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2239 sizeof(param->peer_macaddr));
2240}
2241#else
2242static inline void copy_peer_mac_addr_tlv(
2243 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2244 struct peer_assoc_params *param)
2245{
2246 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2247}
2248#endif
2249
Govind Singh5eb51532016-03-09 11:34:12 +05302250/**
2251 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2252 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302253 * @param param : pointer to peer assoc parameter
2254 *
2255 * Return: 0 on success and -ve on failure.
2256 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302257static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302258 struct peer_assoc_params *param)
2259{
Govind Singhd3156eb2016-02-26 17:50:39 +05302260 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2261 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002262 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302263 wmi_buf_t buf;
2264 int32_t len;
2265 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302266 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302267 uint32_t peer_legacy_rates_align;
2268 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002269 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302270
2271
2272 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2273 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302274
2275 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002276 (peer_legacy_rates_align * sizeof(uint8_t)) +
2277 WMI_TLV_HDR_SIZE +
2278 (peer_ht_rates_align * sizeof(uint8_t)) +
2279 sizeof(wmi_vht_rate_set) +
2280 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2281 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302282
2283 buf = wmi_buf_alloc(wmi_handle, len);
2284 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302285 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302286 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302287 }
2288
2289 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2290 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2291 WMITLV_SET_HDR(&cmd->tlv_header,
2292 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2293 WMITLV_GET_STRUCT_TLVLEN
2294 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302295
Govind Singhd3156eb2016-02-26 17:50:39 +05302296 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302297
Govind Singhd3156eb2016-02-26 17:50:39 +05302298 cmd->peer_new_assoc = param->peer_new_assoc;
2299 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302300
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302301 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302302 copy_peer_mac_addr_tlv(cmd, param);
2303
Govind Singhd3156eb2016-02-26 17:50:39 +05302304 cmd->peer_rate_caps = param->peer_rate_caps;
2305 cmd->peer_caps = param->peer_caps;
2306 cmd->peer_listen_intval = param->peer_listen_intval;
2307 cmd->peer_ht_caps = param->peer_ht_caps;
2308 cmd->peer_max_mpdu = param->peer_max_mpdu;
2309 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302310 cmd->peer_vht_caps = param->peer_vht_caps;
2311 cmd->peer_phymode = param->peer_phymode;
2312
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002313 /* Update 11ax capabilities */
2314 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2315 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002316 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2317 sizeof(param->peer_he_cap_phyinfo));
2318 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2319 sizeof(param->peer_ppet));
2320
Govind Singhd3156eb2016-02-26 17:50:39 +05302321 /* Update peer legacy rate information */
2322 buf_ptr += sizeof(*cmd);
2323 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302324 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302325 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302326 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302327 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302328 param->peer_legacy_rates.num_rates);
2329
2330 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002331 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302333 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302334 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302335 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302336 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302337 param->peer_ht_rates.num_rates);
2338
2339 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002340 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302341 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2342 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2343
2344 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302345
2346 /* Update bandwidth-NSS mapping */
2347 cmd->peer_bw_rxnss_override = 0;
2348 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2349
Govind Singhd3156eb2016-02-26 17:50:39 +05302350 mcs = (wmi_vht_rate_set *) buf_ptr;
2351 if (param->vht_capable) {
2352 mcs->rx_max_rate = param->rx_max_rate;
2353 mcs->rx_mcs_set = param->rx_mcs_set;
2354 mcs->tx_max_rate = param->tx_max_rate;
2355 mcs->tx_mcs_set = param->tx_mcs_set;
2356 }
2357
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002358 /* HE Rates */
2359 cmd->peer_he_mcs = param->peer_he_mcs_count;
2360 buf_ptr += sizeof(wmi_vht_rate_set);
2361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2362 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2363 buf_ptr += WMI_TLV_HDR_SIZE;
2364
2365 /* Loop through the HE rate set */
2366 for (i = 0; i < param->peer_he_mcs_count; i++) {
2367 he_mcs = (wmi_he_rate_set *) buf_ptr;
2368 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2369 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2370
2371 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2372 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2373 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2374 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2375 buf_ptr += sizeof(wmi_he_rate_set);
2376 }
2377
2378
Govind Singhb53420c2016-03-09 14:32:57 +05302379 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2381 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002382 "cmd->peer_vht_caps %x "
2383 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302384 "HE phy %x %x %x "
2385 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302386 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2387 cmd->peer_rate_caps, cmd->peer_caps,
2388 cmd->peer_listen_intval, cmd->peer_ht_caps,
2389 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2390 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002391 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2392 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302393 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2394 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302395
2396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2397 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302398 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302399 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302400 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302401 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302402 }
2403
2404 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302405}
2406
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302407/* copy_scan_notify_events() - Helper routine to copy scan notify events
2408 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302409static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302410 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302411 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302412{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302413
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302414 /* Scan events subscription */
2415 if (param->scan_ev_started)
2416 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2417 if (param->scan_ev_completed)
2418 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2419 if (param->scan_ev_bss_chan)
2420 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2421 if (param->scan_ev_foreign_chan)
2422 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2423 if (param->scan_ev_dequeued)
2424 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2425 if (param->scan_ev_preempted)
2426 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2427 if (param->scan_ev_start_failed)
2428 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2429 if (param->scan_ev_restarted)
2430 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2431 if (param->scan_ev_foreign_chn_exit)
2432 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2433 if (param->scan_ev_suspended)
2434 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2435 if (param->scan_ev_resumed)
2436 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302437
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302438 /** Set scan control flags */
2439 cmd->scan_ctrl_flags = 0;
2440 if (param->scan_f_passive)
2441 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2442 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302443 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302444 if (param->scan_f_promisc_mode)
2445 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2446 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302447 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302448 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302449 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302450 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302451 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302452 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302453 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302454 if (param->scan_f_ofdm_rates)
2455 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2456 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302457 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302458 if (param->scan_f_filter_prb_req)
2459 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2460 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302461 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302462 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302463 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302464 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302465 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302466 if (param->scan_f_force_active_dfs_chn)
2467 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2468 if (param->scan_f_add_tpc_ie_in_probe)
2469 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2470 if (param->scan_f_add_ds_ie_in_probe)
2471 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2472 if (param->scan_f_add_spoofed_mac_in_probe)
2473 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2474 if (param->scan_f_add_rand_seq_in_probe)
2475 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2476 if (param->scan_f_en_ie_whitelist_in_probe)
2477 cmd->scan_ctrl_flags |=
2478 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302479
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302480 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2481 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2482 param->adaptive_dwell_time_mode);
2483}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302484
2485/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302486static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302487 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302488{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302489 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302490}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302491
Govind Singh5eb51532016-03-09 11:34:12 +05302492/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302493 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2494 * @mac: random mac addr
2495 * @mask: random mac mask
2496 * @mac_addr: wmi random mac
2497 * @mac_mask: wmi random mac mask
2498 *
2499 * Return None.
2500 */
2501static inline
2502void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2503 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2504{
2505 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2506 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2507}
2508
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302509/*
2510 * wmi_fill_vendor_oui() - fill vendor OUIs
2511 * @buf_ptr: pointer to wmi tlv buffer
2512 * @num_vendor_oui: number of vendor OUIs to be filled
2513 * @param_voui: pointer to OUI buffer
2514 *
2515 * This function populates the wmi tlv buffer when vendor specific OUIs are
2516 * present.
2517 *
2518 * Return: None
2519 */
2520static inline
2521void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2522 uint32_t *pvoui)
2523{
2524 wmi_vendor_oui *voui = NULL;
2525 uint32_t i;
2526
2527 voui = (wmi_vendor_oui *)buf_ptr;
2528
2529 for (i = 0; i < num_vendor_oui; i++) {
2530 WMITLV_SET_HDR(&voui[i].tlv_header,
2531 WMITLV_TAG_STRUC_wmi_vendor_oui,
2532 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2533 voui[i].oui_type_subtype = pvoui[i];
2534 }
2535}
2536
2537/*
2538 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2539 * @ie_bitmap: output pointer to ie bit map in cmd
2540 * @num_vendor_oui: output pointer to num vendor OUIs
2541 * @ie_whitelist: input parameter
2542 *
2543 * This function populates the IE whitelist attrs of scan, pno and
2544 * scan oui commands for ie_whitelist parameter.
2545 *
2546 * Return: None
2547 */
2548static inline
2549void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2550 uint32_t *num_vendor_oui,
2551 struct probe_req_whitelist_attr *ie_whitelist)
2552{
2553 uint32_t i = 0;
2554
2555 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2556 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2557
2558 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2559}
2560
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302561/**
Govind Singh5eb51532016-03-09 11:34:12 +05302562 * send_scan_start_cmd_tlv() - WMI scan start function
2563 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302564 * @param param : pointer to hold scan start cmd parameter
2565 *
2566 * Return: 0 on success and -ve on failure.
2567 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302568static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302569 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302570{
Govind Singhd3156eb2016-02-26 17:50:39 +05302571 int32_t ret = 0;
2572 int32_t i;
2573 wmi_buf_t wmi_buf;
2574 wmi_start_scan_cmd_fixed_param *cmd;
2575 uint8_t *buf_ptr;
2576 uint32_t *tmp_ptr;
2577 wmi_ssid *ssid = NULL;
2578 wmi_mac_addr *bssid;
2579 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302580 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302581 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302582 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302583
2584 /* Length TLV placeholder for array of uint32_t */
2585 len += WMI_TLV_HDR_SIZE;
2586 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302587 if (params->chan_list.num_chan)
2588 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302589
2590 /* Length TLV placeholder for array of wmi_ssid structures */
2591 len += WMI_TLV_HDR_SIZE;
2592 if (params->num_ssids)
2593 len += params->num_ssids * sizeof(wmi_ssid);
2594
2595 /* Length TLV placeholder for array of wmi_mac_addr structures */
2596 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302597 if (params->num_bssid)
2598 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302599
2600 /* Length TLV placeholder for array of bytes */
2601 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302602 if (params->extraie.len)
2603 extraie_len_with_pad =
2604 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002605 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302606
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302607 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2608 if (ie_whitelist->num_vendor_oui)
2609 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2610
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302611 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2612 if (params->scan_f_wide_band)
2613 phymode_roundup =
2614 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2615 sizeof(uint32_t));
2616 len += phymode_roundup;
2617
Govind Singhd3156eb2016-02-26 17:50:39 +05302618 /* Allocate the memory */
2619 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2620 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302621 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302622 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302623 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302624 }
2625 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2626 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2627 WMITLV_SET_HDR(&cmd->tlv_header,
2628 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2629 WMITLV_GET_STRUCT_TLVLEN
2630 (wmi_start_scan_cmd_fixed_param));
2631
2632 cmd->scan_id = params->scan_id;
2633 cmd->scan_req_id = params->scan_req_id;
2634 cmd->vdev_id = params->vdev_id;
2635 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302636
2637 copy_scan_event_cntrl_flags(cmd, params);
2638
Govind Singhd3156eb2016-02-26 17:50:39 +05302639 cmd->dwell_time_active = params->dwell_time_active;
2640 cmd->dwell_time_passive = params->dwell_time_passive;
2641 cmd->min_rest_time = params->min_rest_time;
2642 cmd->max_rest_time = params->max_rest_time;
2643 cmd->repeat_probe_time = params->repeat_probe_time;
2644 cmd->probe_spacing_time = params->probe_spacing_time;
2645 cmd->idle_time = params->idle_time;
2646 cmd->max_scan_time = params->max_scan_time;
2647 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302648 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302649 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302650 cmd->num_bssid = params->num_bssid;
2651 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302652 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302653 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302654 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2655
2656 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2657
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302658 if (params->scan_random.randomize)
2659 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2660 params->scan_random.mac_mask,
2661 &cmd->mac_addr,
2662 &cmd->mac_mask);
2663
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302664 if (ie_whitelist->white_list)
2665 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2666 &cmd->num_vendor_oui,
2667 ie_whitelist);
2668
Govind Singhd3156eb2016-02-26 17:50:39 +05302669 buf_ptr += sizeof(*cmd);
2670 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302671 for (i = 0; i < params->chan_list.num_chan; ++i)
2672 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302673
2674 WMITLV_SET_HDR(buf_ptr,
2675 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302676 (params->chan_list.num_chan * sizeof(uint32_t)));
2677 buf_ptr += WMI_TLV_HDR_SIZE +
2678 (params->chan_list.num_chan * sizeof(uint32_t));
2679
Govind Singh4eacd2b2016-03-07 14:24:22 +05302680 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302681 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302682 goto error;
2683 }
2684
2685 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2686 (params->num_ssids * sizeof(wmi_ssid)));
2687
2688 if (params->num_ssids) {
2689 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2690 for (i = 0; i < params->num_ssids; ++i) {
2691 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302692 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302693 params->ssid[i].length);
2694 ssid++;
2695 }
2696 }
2697 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2698
2699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2700 (params->num_bssid * sizeof(wmi_mac_addr)));
2701 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302702
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302703 if (params->num_bssid) {
2704 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302705 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2706 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302707 bssid++;
2708 }
2709 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302710
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302711 buf_ptr += WMI_TLV_HDR_SIZE +
2712 (params->num_bssid * sizeof(wmi_mac_addr));
2713
2714 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2715 if (params->extraie.len)
2716 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2717 params);
2718
2719 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302720
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302721 /* probe req ie whitelisting */
2722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2723 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2724
2725 buf_ptr += WMI_TLV_HDR_SIZE;
2726
2727 if (cmd->num_vendor_oui) {
2728 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2729 ie_whitelist->voui);
2730 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2731 }
2732
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302733 /* Add phy mode TLV if it's a wide band scan */
2734 if (params->scan_f_wide_band) {
2735 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2736 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2737 for (i = 0; i < params->chan_list.num_chan; ++i)
2738 buf_ptr[i] =
2739 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2740 buf_ptr += phymode_roundup;
2741 } else {
2742 /* Add ZERO legth phy mode TLV */
2743 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2744 }
2745
Santosh Anbu1e11b472018-03-07 15:33:27 +05302746 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002747 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302748 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302749 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302750 wmi_buf_free(wmi_buf);
2751 }
2752 return ret;
2753error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302754 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302755 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302756}
2757
2758/**
2759 * send_scan_stop_cmd_tlv() - WMI scan start function
2760 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302761 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302762 *
2763 * Return: 0 on success and -ve on failure.
2764 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302765static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302766 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302767{
Govind Singhd3156eb2016-02-26 17:50:39 +05302768 wmi_stop_scan_cmd_fixed_param *cmd;
2769 int ret;
2770 int len = sizeof(*cmd);
2771 wmi_buf_t wmi_buf;
2772
2773 /* Allocate the memory */
2774 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2775 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302776 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302777 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302778 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302779 goto error;
2780 }
2781
2782 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2783 WMITLV_SET_HDR(&cmd->tlv_header,
2784 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2785 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2786 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302787 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302788 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302789 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2790 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302791 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302792 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2793 /* Cancelling all scans */
2794 cmd->req_type = WMI_SCAN_STOP_ALL;
2795 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2796 /* Cancelling VAP scans */
2797 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2798 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2799 /* Cancelling specific scan */
2800 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302801 } else {
2802 WMI_LOGE("%s: Invalid Command : ", __func__);
2803 wmi_buf_free(wmi_buf);
2804 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302805 }
2806
Santosh Anbu1e11b472018-03-07 15:33:27 +05302807 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002808 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302809 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302810 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302811 wmi_buf_free(wmi_buf);
2812 }
2813
2814error:
2815 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302816}
2817
Govind Singh87542482016-06-08 19:40:11 +05302818#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302819/**
2820 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2821 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302822 * @param param : pointer to hold scan channel list parameter
2823 *
2824 * Return: 0 on success and -ve on failure.
2825 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302826static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302827 struct scan_chan_list_params *chan_list)
2828{
2829 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302830 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302831 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302832 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302833 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302834 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302835 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2836
2837 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2838 buf = wmi_buf_alloc(wmi_handle, len);
2839 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302840 WMI_LOGE("Failed to allocate memory");
2841 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302842 goto end;
2843 }
2844
2845 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2846 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2847 WMITLV_SET_HDR(&cmd->tlv_header,
2848 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2849 WMITLV_GET_STRUCT_TLVLEN
2850 (wmi_scan_chan_list_cmd_fixed_param));
2851
Govind Singhb53420c2016-03-09 14:32:57 +05302852 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302853
2854 cmd->num_scan_chans = chan_list->num_scan_chans;
2855 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2856 WMITLV_TAG_ARRAY_STRUC,
2857 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302858 chan_info = (wmi_channel_param *)
2859 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302860 tchan_info = chan_list->chan_info;
2861
2862 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2863 WMITLV_SET_HDR(&chan_info->tlv_header,
2864 WMITLV_TAG_STRUC_wmi_channel,
2865 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2866 chan_info->mhz = tchan_info->mhz;
2867 chan_info->band_center_freq1 =
2868 tchan_info->band_center_freq1;
2869 chan_info->band_center_freq2 =
2870 tchan_info->band_center_freq2;
2871 chan_info->info = tchan_info->info;
2872 chan_info->reg_info_1 = tchan_info->reg_info_1;
2873 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302874 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302875
2876 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2877 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2878 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2879 tchan_info++;
2880 chan_info++;
2881 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302882 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2883 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302884
Anish Natarajdd855152017-03-20 12:49:08 +05302885 qdf_status = wmi_unified_cmd_send(wmi_handle,
2886 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302887
Govind Singh67922e82016-04-01 16:48:57 +05302888 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302889 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302890 wmi_buf_free(buf);
2891 }
Govind Singh67922e82016-04-01 16:48:57 +05302892
Govind Singhd3156eb2016-02-26 17:50:39 +05302893end:
Govind Singhb53420c2016-03-09 14:32:57 +05302894 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302895}
Govind Singh87542482016-06-08 19:40:11 +05302896#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302897static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302898 struct scan_chan_list_params *chan_list)
2899{
2900 wmi_buf_t buf;
2901 QDF_STATUS qdf_status;
2902 wmi_scan_chan_list_cmd_fixed_param *cmd;
2903 int i;
2904 uint8_t *buf_ptr;
2905 wmi_channel *chan_info;
2906 struct channel_param *tchan_info;
2907 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302908
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302909 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302910 buf = wmi_buf_alloc(wmi_handle, len);
2911 if (!buf) {
2912 WMI_LOGE("Failed to allocate memory");
2913 qdf_status = QDF_STATUS_E_NOMEM;
2914 goto end;
2915 }
2916
2917 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2918 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2919 WMITLV_SET_HDR(&cmd->tlv_header,
2920 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2921 WMITLV_GET_STRUCT_TLVLEN
2922 (wmi_scan_chan_list_cmd_fixed_param));
2923
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302924 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302925
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302926 if (chan_list->append)
2927 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2928
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302929 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2930 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302931 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302932 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2933 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302934 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302935 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2936 tchan_info = &(chan_list->ch_param[0]);
2937
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302938 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302939 WMITLV_SET_HDR(&chan_info->tlv_header,
2940 WMITLV_TAG_STRUC_wmi_channel,
2941 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2942 chan_info->mhz = tchan_info->mhz;
2943 chan_info->band_center_freq1 =
2944 tchan_info->cfreq1;
2945 chan_info->band_center_freq2 =
2946 tchan_info->cfreq2;
2947
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302948 if (tchan_info->is_chan_passive)
2949 WMI_SET_CHANNEL_FLAG(chan_info,
2950 WMI_CHAN_FLAG_PASSIVE);
2951
2952 if (tchan_info->allow_vht)
2953 WMI_SET_CHANNEL_FLAG(chan_info,
2954 WMI_CHAN_FLAG_ALLOW_VHT);
2955 else if (tchan_info->allow_ht)
2956 WMI_SET_CHANNEL_FLAG(chan_info,
2957 WMI_CHAN_FLAG_ALLOW_HT);
2958 WMI_SET_CHANNEL_MODE(chan_info,
2959 tchan_info->phy_mode);
2960
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302961 if (tchan_info->half_rate)
2962 WMI_SET_CHANNEL_FLAG(chan_info,
2963 WMI_CHAN_FLAG_HALF_RATE);
2964
2965 if (tchan_info->quarter_rate)
2966 WMI_SET_CHANNEL_FLAG(chan_info,
2967 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302968
2969 /* also fill in power information */
2970 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2971 tchan_info->minpower);
2972 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2973 tchan_info->maxpower);
2974 WMI_SET_CHANNEL_REG_POWER(chan_info,
2975 tchan_info->maxregpower);
2976 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2977 tchan_info->antennamax);
2978 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2979 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002980 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2981 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302982
Govind Singh87542482016-06-08 19:40:11 +05302983 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2984
Govind Singh87542482016-06-08 19:40:11 +05302985 tchan_info++;
2986 chan_info++;
2987 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302988 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2989 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302990
Anish Natarajdd855152017-03-20 12:49:08 +05302991 qdf_status = wmi_unified_cmd_send(
2992 wmi_handle,
2993 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302994
2995 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2996 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2997 wmi_buf_free(buf);
2998 }
2999
3000end:
3001 return qdf_status;
3002}
3003#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303004
3005/**
3006 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3007 *
3008 * @bufp: Pointer to buffer
3009 * @param: Pointer to tx param
3010 *
3011 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3012 */
3013static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3014 struct tx_send_params param)
3015{
3016 wmi_tx_send_params *tx_param;
3017 QDF_STATUS status = QDF_STATUS_SUCCESS;
3018
3019 if (!bufp) {
3020 status = QDF_STATUS_E_FAILURE;
3021 return status;
3022 }
3023 tx_param = (wmi_tx_send_params *)bufp;
3024 WMITLV_SET_HDR(&tx_param->tlv_header,
3025 WMITLV_TAG_STRUC_wmi_tx_send_params,
3026 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3027 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3028 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3029 param.mcs_mask);
3030 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3031 param.nss_mask);
3032 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3033 param.retry_limit);
3034 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3035 param.chain_mask);
3036 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3037 param.bw_mask);
3038 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3039 param.preamble_type);
3040 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3041 param.frame_type);
3042
3043 return status;
3044}
3045
Govind Singhd3156eb2016-02-26 17:50:39 +05303046/**
3047 * send_mgmt_cmd_tlv() - WMI scan start function
3048 * @wmi_handle : handle to WMI.
3049 * @param : pointer to hold mgmt cmd parameter
3050 *
3051 * Return: 0 on success and -ve on failure.
3052 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303053static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303054 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303055{
Govind Singh427ee5a2016-02-26 18:09:36 +05303056 wmi_buf_t buf;
3057 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3058 int32_t cmd_len;
3059 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303060 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303061 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303062 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303063 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3064 mgmt_tx_dl_frm_len;
3065
3066 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303067 WMI_TLV_HDR_SIZE +
3068 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303069
Sathish Kumar5b636932017-06-28 14:40:32 +05303070 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303071 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303072 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3073 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303074 }
3075
3076 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3077 bufp = (uint8_t *) cmd;
3078 WMITLV_SET_HDR(&cmd->tlv_header,
3079 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3080 WMITLV_GET_STRUCT_TLVLEN
3081 (wmi_mgmt_tx_send_cmd_fixed_param));
3082
3083 cmd->vdev_id = param->vdev_id;
3084
Govind Singh224a7312016-06-21 14:33:26 +05303085 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303086 cmd->chanfreq = param->chanfreq;
3087 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3088 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3089 sizeof(uint32_t)));
3090 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303091 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303092
3093 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3094 QDF_DMA_TO_DEVICE);
3095 if (status != QDF_STATUS_SUCCESS) {
3096 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303097 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303098 }
3099
Govind Singhb53420c2016-03-09 14:32:57 +05303100 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303101 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003102#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303103 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3104#endif
3105 cmd->frame_len = param->frm_len;
3106 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303107 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303108
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003109 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003110 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003111
Sathish Kumar5b636932017-06-28 14:40:32 +05303112 bufp += roundup(bufp_len, sizeof(uint32_t));
3113 if (param->tx_params_valid) {
3114 status = populate_tx_send_params(bufp, param->tx_param);
3115 if (status != QDF_STATUS_SUCCESS) {
3116 WMI_LOGE("%s: Populate TX send params failed",
3117 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303118 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303119 }
3120 cmd_len += sizeof(wmi_tx_send_params);
3121 }
3122
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3124 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303125 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303126 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303127 }
Govind Singhb53420c2016-03-09 14:32:57 +05303128 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303129
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303130unmap_tx_frame:
3131 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3132 QDF_DMA_TO_DEVICE);
3133free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303134 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303135 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303136}
3137
3138/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303139 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3140 * @wmi_handle : handle to WMI.
3141 * @param : pointer to offchan data tx cmd parameter
3142 *
3143 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3144 */
3145static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3146 struct wmi_offchan_data_tx_params *param)
3147{
3148 wmi_buf_t buf;
3149 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3150 int32_t cmd_len;
3151 uint64_t dma_addr;
3152 void *qdf_ctx = param->qdf_ctx;
3153 uint8_t *bufp;
3154 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3155 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303156 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303157
3158 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303159 WMI_TLV_HDR_SIZE +
3160 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303161
Sathish Kumar5b636932017-06-28 14:40:32 +05303162 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303163 if (!buf) {
3164 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3165 return QDF_STATUS_E_NOMEM;
3166 }
3167
3168 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3169 bufp = (uint8_t *) cmd;
3170 WMITLV_SET_HDR(&cmd->tlv_header,
3171 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3172 WMITLV_GET_STRUCT_TLVLEN
3173 (wmi_offchan_data_tx_send_cmd_fixed_param));
3174
3175 cmd->vdev_id = param->vdev_id;
3176
3177 cmd->desc_id = param->desc_id;
3178 cmd->chanfreq = param->chanfreq;
3179 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3180 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3181 sizeof(uint32_t)));
3182 bufp += WMI_TLV_HDR_SIZE;
3183 qdf_mem_copy(bufp, param->pdata, bufp_len);
3184 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3185 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3186 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3187#if defined(HTT_PADDR64)
3188 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3189#endif
3190 cmd->frame_len = param->frm_len;
3191 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303192 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303193
3194 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3195 bufp, cmd->vdev_id, cmd->chanfreq);
3196
Sathish Kumar5b636932017-06-28 14:40:32 +05303197 bufp += roundup(bufp_len, sizeof(uint32_t));
3198 if (param->tx_params_valid) {
3199 status = populate_tx_send_params(bufp, param->tx_param);
3200 if (status != QDF_STATUS_SUCCESS) {
3201 WMI_LOGE("%s: Populate TX send params failed",
3202 __func__);
3203 goto err1;
3204 }
3205 cmd_len += sizeof(wmi_tx_send_params);
3206 }
3207
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303208 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3209 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3210 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303211 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303212 }
3213
3214 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303215
3216err1:
3217 wmi_buf_free(buf);
3218 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303219}
3220
3221/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303222 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3223 * @wmi_handle: wmi handle
3224 * @param_value: parameter value
3225 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303226 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303227 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303228static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303229 uint32_t param_value)
3230{
Govind Singh67922e82016-04-01 16:48:57 +05303231 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 wmi_modem_power_state_cmd_param *cmd;
3233 wmi_buf_t buf;
3234 uint16_t len = sizeof(*cmd);
3235
3236 buf = wmi_buf_alloc(wmi_handle, len);
3237 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303238 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303239 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303240 }
3241 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3242 WMITLV_SET_HDR(&cmd->tlv_header,
3243 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3244 WMITLV_GET_STRUCT_TLVLEN
3245 (wmi_modem_power_state_cmd_param));
3246 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303248 param_value);
3249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3250 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303251 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303252 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303253 wmi_buf_free(buf);
3254 }
Govind Singh67922e82016-04-01 16:48:57 +05303255
Govind Singh427ee5a2016-02-26 18:09:36 +05303256 return ret;
3257}
3258
3259/**
3260 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3261 * @wmi_handle: wmi handle
3262 * @vdev_id: vdev id
3263 * @val: value
3264 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303265 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303266 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303267static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303268 uint32_t vdev_id, uint8_t val)
3269{
3270 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3271 wmi_buf_t buf;
3272 int32_t len = sizeof(*cmd);
3273
Govind Singhb53420c2016-03-09 14:32:57 +05303274 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303275
3276 buf = wmi_buf_alloc(wmi_handle, len);
3277 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303278 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303279 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303280 }
3281 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3282 WMITLV_SET_HDR(&cmd->tlv_header,
3283 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3284 WMITLV_GET_STRUCT_TLVLEN
3285 (wmi_sta_powersave_mode_cmd_fixed_param));
3286 cmd->vdev_id = vdev_id;
3287 if (val)
3288 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3289 else
3290 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3291
3292 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3293 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303294 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303295 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303296 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303297 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303298 }
Govind Singh5eb51532016-03-09 11:34:12 +05303299 return 0;
3300}
3301
Govind Singh427ee5a2016-02-26 18:09:36 +05303302/**
3303 * send_set_mimops_cmd_tlv() - set MIMO powersave
3304 * @wmi_handle: wmi handle
3305 * @vdev_id: vdev id
3306 * @value: value
3307 *
Govind Singhb53420c2016-03-09 14:32:57 +05303308 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303309 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303310static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303311 uint8_t vdev_id, int value)
3312{
Govind Singh67922e82016-04-01 16:48:57 +05303313 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303314 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3315 wmi_buf_t buf;
3316 uint16_t len = sizeof(*cmd);
3317
3318 buf = wmi_buf_alloc(wmi_handle, len);
3319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303320 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303321 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303322 }
3323 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3324 WMITLV_SET_HDR(&cmd->tlv_header,
3325 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3326 WMITLV_GET_STRUCT_TLVLEN
3327 (wmi_sta_smps_force_mode_cmd_fixed_param));
3328
3329 cmd->vdev_id = vdev_id;
3330
Houston Hoffmanb5168052016-04-14 02:18:01 -07003331 /* WMI_SMPS_FORCED_MODE values do not directly map
3332 * to SM power save values defined in the specification.
3333 * Make sure to send the right mapping.
3334 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303335 switch (value) {
3336 case 0:
3337 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3338 break;
3339 case 1:
3340 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3341 break;
3342 case 2:
3343 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3344 break;
3345 case 3:
3346 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3347 break;
3348 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303349 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3350 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303351 }
3352
Govind Singhb53420c2016-03-09 14:32:57 +05303353 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303354
3355 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3356 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303357 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303358 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303359 wmi_buf_free(buf);
3360 }
3361
3362 return ret;
3363}
3364
3365/**
3366 * send_set_smps_params_cmd_tlv() - set smps params
3367 * @wmi_handle: wmi handle
3368 * @vdev_id: vdev id
3369 * @value: value
3370 *
Govind Singhb53420c2016-03-09 14:32:57 +05303371 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303372 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303373static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303374 int value)
3375{
Govind Singh67922e82016-04-01 16:48:57 +05303376 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303377 wmi_sta_smps_param_cmd_fixed_param *cmd;
3378 wmi_buf_t buf;
3379 uint16_t len = sizeof(*cmd);
3380
3381 buf = wmi_buf_alloc(wmi_handle, len);
3382 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303383 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303384 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303385 }
3386 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3387 WMITLV_SET_HDR(&cmd->tlv_header,
3388 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3389 WMITLV_GET_STRUCT_TLVLEN
3390 (wmi_sta_smps_param_cmd_fixed_param));
3391
3392 cmd->vdev_id = vdev_id;
3393 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3394 cmd->param =
3395 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3396
Govind Singhb53420c2016-03-09 14:32:57 +05303397 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303398 cmd->param);
3399
3400 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3401 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303402 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303403 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303404 wmi_buf_free(buf);
3405 }
3406
3407 return ret;
3408}
3409
3410/**
3411 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3412 * @wmi_handle: wmi handle
3413 * @noa: p2p power save parameters
3414 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303415 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303416 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303417static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303418 struct p2p_ps_params *noa)
3419{
3420 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3421 wmi_p2p_noa_descriptor *noa_discriptor;
3422 wmi_buf_t buf;
3423 uint8_t *buf_ptr;
3424 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303425 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303426 uint32_t duration;
3427
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303429 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3430 buf = wmi_buf_alloc(wmi_handle, len);
3431 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303432 WMI_LOGE("Failed to allocate memory");
3433 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303434 goto end;
3435 }
3436
3437 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3438 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3439 WMITLV_SET_HDR(&cmd->tlv_header,
3440 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3441 WMITLV_GET_STRUCT_TLVLEN
3442 (wmi_p2p_set_noa_cmd_fixed_param));
3443 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3444 cmd->vdev_id = noa->session_id;
3445 cmd->enable = (duration) ? true : false;
3446 cmd->num_noa = 1;
3447
3448 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3449 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3450 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3451 sizeof
3452 (wmi_p2p_set_noa_cmd_fixed_param)
3453 + WMI_TLV_HDR_SIZE);
3454 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3455 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3456 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3457 noa_discriptor->type_count = noa->count;
3458 noa_discriptor->duration = duration;
3459 noa_discriptor->interval = noa->interval;
3460 noa_discriptor->start_time = 0;
3461
Govind Singhb53420c2016-03-09 14:32:57 +05303462 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303463 cmd->vdev_id, noa->count, noa_discriptor->duration,
3464 noa->interval);
3465 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3466 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303467 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303468 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303469 wmi_buf_free(buf);
3470 }
3471
3472end:
Govind Singhb53420c2016-03-09 14:32:57 +05303473 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303474 return status;
3475}
3476
3477
3478/**
3479 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3480 * @wmi_handle: wmi handle
3481 * @noa: p2p opp power save parameters
3482 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303483 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303484 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303485static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303486 struct p2p_ps_params *oppps)
3487{
3488 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3489 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303490 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303491
Govind Singhb53420c2016-03-09 14:32:57 +05303492 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303493 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3494 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303495 WMI_LOGE("Failed to allocate memory");
3496 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303497 goto end;
3498 }
3499
3500 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3501 WMITLV_SET_HDR(&cmd->tlv_header,
3502 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3503 WMITLV_GET_STRUCT_TLVLEN
3504 (wmi_p2p_set_oppps_cmd_fixed_param));
3505 cmd->vdev_id = oppps->session_id;
3506 if (oppps->ctwindow)
3507 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3508
3509 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303510 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303511 cmd->vdev_id, oppps->ctwindow);
3512 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3513 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303514 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303515 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303516 wmi_buf_free(buf);
3517 }
3518
3519end:
Govind Singhb53420c2016-03-09 14:32:57 +05303520 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303521 return status;
3522}
3523
Wu Gaocd3a8512017-03-13 20:17:34 +08003524#ifdef CONVERGED_P2P_ENABLE
3525/**
3526 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3527 * @wmi_handle: wmi handle
3528 * @param: p2p listen offload start parameters
3529 *
3530 * Return: QDF status
3531 */
3532static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3533 struct p2p_lo_start *param)
3534{
3535 wmi_buf_t buf;
3536 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3537 int32_t len = sizeof(*cmd);
3538 uint8_t *buf_ptr;
3539 QDF_STATUS status;
3540 int device_types_len_aligned;
3541 int probe_resp_len_aligned;
3542
3543 if (!param) {
3544 WMI_LOGE("lo start param is null");
3545 return QDF_STATUS_E_INVAL;
3546 }
3547
3548 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3549
3550 device_types_len_aligned =
3551 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303552 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003553 probe_resp_len_aligned =
3554 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303555 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003556
3557 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3558 probe_resp_len_aligned;
3559
3560 buf = wmi_buf_alloc(wmi_handle, len);
3561 if (!buf) {
3562 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3563 __func__);
3564 return QDF_STATUS_E_NOMEM;
3565 }
3566
3567 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3569
3570 WMITLV_SET_HDR(&cmd->tlv_header,
3571 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3572 WMITLV_GET_STRUCT_TLVLEN(
3573 wmi_p2p_lo_start_cmd_fixed_param));
3574
3575 cmd->vdev_id = param->vdev_id;
3576 cmd->ctl_flags = param->ctl_flags;
3577 cmd->channel = param->freq;
3578 cmd->period = param->period;
3579 cmd->interval = param->interval;
3580 cmd->count = param->count;
3581 cmd->device_types_len = param->dev_types_len;
3582 cmd->prob_resp_len = param->probe_resp_len;
3583
3584 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3585 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3586 device_types_len_aligned);
3587 buf_ptr += WMI_TLV_HDR_SIZE;
3588 qdf_mem_copy(buf_ptr, param->device_types,
3589 param->dev_types_len);
3590
3591 buf_ptr += device_types_len_aligned;
3592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3593 probe_resp_len_aligned);
3594 buf_ptr += WMI_TLV_HDR_SIZE;
3595 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3596 param->probe_resp_len);
3597
3598 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3599 cmd->channel, cmd->period, cmd->interval, cmd->count);
3600
3601 status = wmi_unified_cmd_send(wmi_handle,
3602 buf, len,
3603 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3604 if (status != QDF_STATUS_SUCCESS) {
3605 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3606 __func__, status);
3607 wmi_buf_free(buf);
3608 return status;
3609 }
3610
3611 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3612
3613 return QDF_STATUS_SUCCESS;
3614}
3615
3616/**
3617 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3618 * @wmi_handle: wmi handle
3619 * @param: p2p listen offload stop parameters
3620 *
3621 * Return: QDF status
3622 */
3623static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3624 uint8_t vdev_id)
3625{
3626 wmi_buf_t buf;
3627 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3628 int32_t len;
3629 QDF_STATUS status;
3630
3631 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3632
3633 len = sizeof(*cmd);
3634 buf = wmi_buf_alloc(wmi_handle, len);
3635 if (!buf) {
3636 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3637 __func__);
3638 return QDF_STATUS_E_NOMEM;
3639 }
3640 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3641
3642 WMITLV_SET_HDR(&cmd->tlv_header,
3643 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3644 WMITLV_GET_STRUCT_TLVLEN(
3645 wmi_p2p_lo_stop_cmd_fixed_param));
3646
3647 cmd->vdev_id = vdev_id;
3648
3649 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3650
3651 status = wmi_unified_cmd_send(wmi_handle,
3652 buf, len,
3653 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3654 if (status != QDF_STATUS_SUCCESS) {
3655 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3656 __func__, status);
3657 wmi_buf_free(buf);
3658 return status;
3659 }
3660
3661 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3662
3663 return QDF_STATUS_SUCCESS;
3664}
3665#endif /* End of CONVERGED_P2P_ENABLE */
3666
Govind Singh427ee5a2016-02-26 18:09:36 +05303667/**
3668 * send_get_temperature_cmd_tlv() - get pdev temperature req
3669 * @wmi_handle: wmi handle
3670 *
Govind Singhb53420c2016-03-09 14:32:57 +05303671 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303672 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303673static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303674{
3675 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3676 wmi_buf_t wmi_buf;
3677 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3678 uint8_t *buf_ptr;
3679
3680 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303681 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3682 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303683 }
3684
3685 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3686 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303687 WMI_LOGE(FL("wmi_buf_alloc failed"));
3688 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303689 }
3690
3691 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3692
3693 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3694 WMITLV_SET_HDR(&cmd->tlv_header,
3695 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3696 WMITLV_GET_STRUCT_TLVLEN
3697 (wmi_pdev_get_temperature_cmd_fixed_param));
3698
3699 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3700 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303701 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303702 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303703 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303704 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303705
Govind Singhb53420c2016-03-09 14:32:57 +05303706 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303707}
3708
3709/**
3710 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3711 * @wmi_handle: wmi handle
3712 * @vdevid: vdev id
3713 * @peer_addr: peer mac address
3714 * @auto_triggerparam: auto trigger parameters
3715 * @num_ac: number of access category
3716 *
3717 * This function sets the trigger
3718 * uapsd params such as service interval, delay interval
3719 * and suspend interval which will be used by the firmware
3720 * to send trigger frames periodically when there is no
3721 * traffic on the transmit side.
3722 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303723 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303724 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303725static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303726 struct sta_uapsd_trig_params *param)
3727{
3728 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303729 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303730 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3731 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3732 uint32_t i;
3733 wmi_buf_t buf;
3734 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003735 struct sta_uapsd_params *uapsd_param;
3736 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303737
3738 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3739 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303740 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303741 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303742 }
3743
3744 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3745 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3746 WMITLV_SET_HDR(&cmd->tlv_header,
3747 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3748 WMITLV_GET_STRUCT_TLVLEN
3749 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3750 cmd->vdev_id = param->vdevid;
3751 cmd->num_ac = param->num_ac;
3752 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3753
3754 /* TLV indicating array of structures to follow */
3755 buf_ptr += sizeof(*cmd);
3756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3757
3758 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303759
3760 /*
3761 * Update tag and length for uapsd auto trigger params (this will take
3762 * care of updating tag and length if it is not pre-filled by caller).
3763 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003764 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3765 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303766 for (i = 0; i < param->num_ac; i++) {
3767 WMITLV_SET_HDR((buf_ptr +
3768 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3769 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3770 WMITLV_GET_STRUCT_TLVLEN
3771 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003772 trig_param->wmm_ac = uapsd_param->wmm_ac;
3773 trig_param->user_priority = uapsd_param->user_priority;
3774 trig_param->service_interval = uapsd_param->service_interval;
3775 trig_param->suspend_interval = uapsd_param->suspend_interval;
3776 trig_param->delay_interval = uapsd_param->delay_interval;
3777 trig_param++;
3778 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303779 }
3780
3781 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3782 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303783 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303784 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303785 wmi_buf_free(buf);
3786 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303787
Govind Singh427ee5a2016-02-26 18:09:36 +05303788 return ret;
3789}
3790
Zhang Qian11c0de32018-01-05 16:50:53 +08003791#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303792/**
3793 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3794 * @wmi_handle: pointer to the wmi handle
3795 * @utc: pointer to the UTC time struct
3796 *
3797 * Return: 0 on succes
3798 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303799static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303800 struct ocb_utc_param *utc)
3801{
Govind Singh67922e82016-04-01 16:48:57 +05303802 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303803 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3804 uint8_t *buf_ptr;
3805 uint32_t len, i;
3806 wmi_buf_t buf;
3807
3808 len = sizeof(*cmd);
3809 buf = wmi_buf_alloc(wmi_handle, len);
3810 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303811 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303812 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303813 }
3814
3815 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3816 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3817 WMITLV_SET_HDR(&cmd->tlv_header,
3818 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3819 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3820 cmd->vdev_id = utc->vdev_id;
3821
3822 for (i = 0; i < SIZE_UTC_TIME; i++)
3823 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3824
3825 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3826 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3827
3828 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3829 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303830 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303831 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303832 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303833 }
3834
Govind Singh67922e82016-04-01 16:48:57 +05303835 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303836}
3837
3838/**
3839 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3840 * frames on a channel
3841 * @wmi_handle: pointer to the wmi handle
3842 * @timing_advert: pointer to the timing advertisement struct
3843 *
3844 * Return: 0 on succes
3845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303846static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303847 struct ocb_timing_advert_param *timing_advert)
3848{
Govind Singh67922e82016-04-01 16:48:57 +05303849 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303850 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3851 uint8_t *buf_ptr;
3852 uint32_t len, len_template;
3853 wmi_buf_t buf;
3854
3855 len = sizeof(*cmd) +
3856 WMI_TLV_HDR_SIZE;
3857
3858 len_template = timing_advert->template_length;
3859 /* Add padding to the template if needed */
3860 if (len_template % 4 != 0)
3861 len_template += 4 - (len_template % 4);
3862 len += len_template;
3863
3864 buf = wmi_buf_alloc(wmi_handle, len);
3865 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303866 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303867 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303868 }
3869
3870 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3871 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3872 WMITLV_SET_HDR(&cmd->tlv_header,
3873 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3874 WMITLV_GET_STRUCT_TLVLEN(
3875 wmi_ocb_start_timing_advert_cmd_fixed_param));
3876 cmd->vdev_id = timing_advert->vdev_id;
3877 cmd->repeat_rate = timing_advert->repeat_rate;
3878 cmd->channel_freq = timing_advert->chan_freq;
3879 cmd->timestamp_offset = timing_advert->timestamp_offset;
3880 cmd->time_value_offset = timing_advert->time_value_offset;
3881 cmd->timing_advert_template_length = timing_advert->template_length;
3882 buf_ptr += sizeof(*cmd);
3883
3884 /* Add the timing advert template */
3885 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3886 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303887 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303888 (uint8_t *)timing_advert->template_value,
3889 timing_advert->template_length);
3890
3891 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3892 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303893 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303894 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303895 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303896 }
3897
Govind Singh67922e82016-04-01 16:48:57 +05303898 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303899}
3900
3901/**
3902 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3903 * on a channel
3904 * @wmi_handle: pointer to the wmi handle
3905 * @timing_advert: pointer to the timing advertisement struct
3906 *
3907 * Return: 0 on succes
3908 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303909static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303910 struct ocb_timing_advert_param *timing_advert)
3911{
Govind Singh67922e82016-04-01 16:48:57 +05303912 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303913 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3914 uint8_t *buf_ptr;
3915 uint32_t len;
3916 wmi_buf_t buf;
3917
3918 len = sizeof(*cmd);
3919 buf = wmi_buf_alloc(wmi_handle, len);
3920 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303921 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303922 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303923 }
3924
3925 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3926 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3927 WMITLV_SET_HDR(&cmd->tlv_header,
3928 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3929 WMITLV_GET_STRUCT_TLVLEN(
3930 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3931 cmd->vdev_id = timing_advert->vdev_id;
3932 cmd->channel_freq = timing_advert->chan_freq;
3933
3934 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3935 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303936 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303937 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303938 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303939 }
3940
Govind Singh67922e82016-04-01 16:48:57 +05303941 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303942}
3943
3944/**
3945 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3946 * @wmi_handle: pointer to the wmi handle
3947 * @request: pointer to the request
3948 *
3949 * Return: 0 on succes
3950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303951static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303952 uint8_t vdev_id)
3953{
Govind Singhb53420c2016-03-09 14:32:57 +05303954 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303955 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3956 uint8_t *buf_ptr;
3957 wmi_buf_t buf;
3958 int32_t len;
3959
3960 len = sizeof(*cmd);
3961 buf = wmi_buf_alloc(wmi_handle, len);
3962 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303963 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303964 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303965 }
3966 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3967
3968 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303969 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303970 WMITLV_SET_HDR(&cmd->tlv_header,
3971 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3972 WMITLV_GET_STRUCT_TLVLEN(
3973 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3974 cmd->vdev_id = vdev_id;
3975
3976 /* Send the WMI command */
3977 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3978 WMI_OCB_GET_TSF_TIMER_CMDID);
3979 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303980 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303981 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303982 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303983 }
3984
Govind Singh67922e82016-04-01 16:48:57 +05303985 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303986}
3987
3988/**
3989 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3990 * @wmi_handle: pointer to the wmi handle
3991 * @get_stats_param: pointer to the dcc stats
3992 *
3993 * Return: 0 on succes
3994 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303995static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08003996 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05303997{
Govind Singh67922e82016-04-01 16:48:57 +05303998 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303999 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4000 wmi_dcc_channel_stats_request *channel_stats_array;
4001 wmi_buf_t buf;
4002 uint8_t *buf_ptr;
4003 uint32_t len;
4004 uint32_t i;
4005
4006 /* Validate the input */
4007 if (get_stats_param->request_array_len !=
4008 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304009 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304010 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304011 }
4012
4013 /* Allocate memory for the WMI command */
4014 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4015 get_stats_param->request_array_len;
4016
4017 buf = wmi_buf_alloc(wmi_handle, len);
4018 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304019 WMI_LOGE(FL("wmi_buf_alloc failed"));
4020 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304021 }
4022
4023 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304024 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304025
4026 /* Populate the WMI command */
4027 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4028 buf_ptr += sizeof(*cmd);
4029
4030 WMITLV_SET_HDR(&cmd->tlv_header,
4031 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4032 WMITLV_GET_STRUCT_TLVLEN(
4033 wmi_dcc_get_stats_cmd_fixed_param));
4034 cmd->vdev_id = get_stats_param->vdev_id;
4035 cmd->num_channels = get_stats_param->channel_count;
4036
4037 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4038 get_stats_param->request_array_len);
4039 buf_ptr += WMI_TLV_HDR_SIZE;
4040
4041 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304042 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304043 get_stats_param->request_array_len);
4044 for (i = 0; i < cmd->num_channels; i++)
4045 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4046 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4047 WMITLV_GET_STRUCT_TLVLEN(
4048 wmi_dcc_channel_stats_request));
4049
4050 /* Send the WMI command */
4051 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4052 WMI_DCC_GET_STATS_CMDID);
4053
Govind Singh67922e82016-04-01 16:48:57 +05304054 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304055 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304056 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304057 }
4058
Govind Singh67922e82016-04-01 16:48:57 +05304059 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304060}
4061
4062/**
4063 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4064 * @wmi_handle: pointer to the wmi handle
4065 * @vdev_id: vdev id
4066 * @dcc_stats_bitmap: dcc status bitmap
4067 *
4068 * Return: 0 on succes
4069 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304070static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304071 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4072{
Govind Singh67922e82016-04-01 16:48:57 +05304073 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304074 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4075 wmi_buf_t buf;
4076 uint8_t *buf_ptr;
4077 uint32_t len;
4078
4079 /* Allocate memory for the WMI command */
4080 len = sizeof(*cmd);
4081
4082 buf = wmi_buf_alloc(wmi_handle, len);
4083 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304084 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304085 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304086 }
4087
4088 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304089 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304090
4091 /* Populate the WMI command */
4092 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4093
4094 WMITLV_SET_HDR(&cmd->tlv_header,
4095 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4096 WMITLV_GET_STRUCT_TLVLEN(
4097 wmi_dcc_clear_stats_cmd_fixed_param));
4098 cmd->vdev_id = vdev_id;
4099 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4100
4101 /* Send the WMI command */
4102 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4103 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304104 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304105 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304106 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304107 }
4108
Govind Singh67922e82016-04-01 16:48:57 +05304109 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304110}
4111
4112/**
4113 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4114 * @wmi_handle: pointer to the wmi handle
4115 * @update_ndl_param: pointer to the request parameters
4116 *
4117 * Return: 0 on success
4118 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304119static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004120 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304121{
Govind Singhb53420c2016-03-09 14:32:57 +05304122 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304123 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4124 wmi_dcc_ndl_chan *ndl_chan_array;
4125 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4126 uint32_t active_state_count;
4127 wmi_buf_t buf;
4128 uint8_t *buf_ptr;
4129 uint32_t len;
4130 uint32_t i;
4131
4132 /* validate the input */
4133 if (update_ndl_param->dcc_ndl_chan_list_len !=
4134 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304135 WMI_LOGE(FL("Invalid parameter"));
4136 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304137 }
4138 active_state_count = 0;
4139 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4140 for (i = 0; i < update_ndl_param->channel_count; i++)
4141 active_state_count +=
4142 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4143 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4144 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304145 WMI_LOGE(FL("Invalid parameter"));
4146 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304147 }
4148
4149 /* Allocate memory for the WMI command */
4150 len = sizeof(*cmd) +
4151 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4152 WMI_TLV_HDR_SIZE +
4153 update_ndl_param->dcc_ndl_active_state_list_len;
4154
4155 buf = wmi_buf_alloc(wmi_handle, len);
4156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304158 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304159 }
4160
4161 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304162 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304163
4164 /* Populate the WMI command */
4165 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4166 buf_ptr += sizeof(*cmd);
4167
4168 WMITLV_SET_HDR(&cmd->tlv_header,
4169 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4170 WMITLV_GET_STRUCT_TLVLEN(
4171 wmi_dcc_update_ndl_cmd_fixed_param));
4172 cmd->vdev_id = update_ndl_param->vdev_id;
4173 cmd->num_channel = update_ndl_param->channel_count;
4174
4175 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4176 update_ndl_param->dcc_ndl_chan_list_len);
4177 buf_ptr += WMI_TLV_HDR_SIZE;
4178
4179 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304180 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304181 update_ndl_param->dcc_ndl_chan_list_len);
4182 for (i = 0; i < cmd->num_channel; i++)
4183 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4184 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4185 WMITLV_GET_STRUCT_TLVLEN(
4186 wmi_dcc_ndl_chan));
4187 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4188
4189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4190 update_ndl_param->dcc_ndl_active_state_list_len);
4191 buf_ptr += WMI_TLV_HDR_SIZE;
4192
4193 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304194 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304195 update_ndl_param->dcc_ndl_active_state_list,
4196 update_ndl_param->dcc_ndl_active_state_list_len);
4197 for (i = 0; i < active_state_count; i++) {
4198 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4199 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4200 WMITLV_GET_STRUCT_TLVLEN(
4201 wmi_dcc_ndl_active_state_config));
4202 }
4203 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4204
4205 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304206 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304207 WMI_DCC_UPDATE_NDL_CMDID);
4208 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304209 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304210 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304211 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304212 }
4213
Govind Singh67922e82016-04-01 16:48:57 +05304214 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304215}
4216
4217/**
4218 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4219 * @wmi_handle: pointer to the wmi handle
4220 * @config: the OCB configuration
4221 *
4222 * Return: 0 on success
4223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304224static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004225 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304226{
Govind Singh67922e82016-04-01 16:48:57 +05304227 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304228 wmi_ocb_set_config_cmd_fixed_param *cmd;
4229 wmi_channel *chan;
4230 wmi_ocb_channel *ocb_chan;
4231 wmi_qos_parameter *qos_param;
4232 wmi_dcc_ndl_chan *ndl_chan;
4233 wmi_dcc_ndl_active_state_config *ndl_active_config;
4234 wmi_ocb_schedule_element *sched_elem;
4235 uint8_t *buf_ptr;
4236 wmi_buf_t buf;
4237 int32_t len;
4238 int32_t i, j, active_state_count;
4239
4240 /*
4241 * Validate the dcc_ndl_chan_list_len and count the number of active
4242 * states. Validate dcc_ndl_active_state_list_len.
4243 */
4244 active_state_count = 0;
4245 if (config->dcc_ndl_chan_list_len) {
4246 if (!config->dcc_ndl_chan_list ||
4247 config->dcc_ndl_chan_list_len !=
4248 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304249 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304250 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304251 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304252 }
4253
4254 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4255 i < config->channel_count; ++i, ++ndl_chan)
4256 active_state_count +=
4257 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4258
4259 if (active_state_count) {
4260 if (!config->dcc_ndl_active_state_list ||
4261 config->dcc_ndl_active_state_list_len !=
4262 active_state_count *
4263 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304264 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304265 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304266 }
4267 }
4268 }
4269
4270 len = sizeof(*cmd) +
4271 WMI_TLV_HDR_SIZE + config->channel_count *
4272 sizeof(wmi_channel) +
4273 WMI_TLV_HDR_SIZE + config->channel_count *
4274 sizeof(wmi_ocb_channel) +
4275 WMI_TLV_HDR_SIZE + config->channel_count *
4276 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4277 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4278 WMI_TLV_HDR_SIZE + active_state_count *
4279 sizeof(wmi_dcc_ndl_active_state_config) +
4280 WMI_TLV_HDR_SIZE + config->schedule_size *
4281 sizeof(wmi_ocb_schedule_element);
4282 buf = wmi_buf_alloc(wmi_handle, len);
4283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304284 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304285 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304286 }
4287
4288 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4289 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4290 WMITLV_SET_HDR(&cmd->tlv_header,
4291 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4292 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004293 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304294 cmd->channel_count = config->channel_count;
4295 cmd->schedule_size = config->schedule_size;
4296 cmd->flags = config->flags;
4297 buf_ptr += sizeof(*cmd);
4298
4299 /* Add the wmi_channel info */
4300 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4301 config->channel_count*sizeof(wmi_channel));
4302 buf_ptr += WMI_TLV_HDR_SIZE;
4303 for (i = 0; i < config->channel_count; i++) {
4304 chan = (wmi_channel *)buf_ptr;
4305 WMITLV_SET_HDR(&chan->tlv_header,
4306 WMITLV_TAG_STRUC_wmi_channel,
4307 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4308 chan->mhz = config->channels[i].chan_freq;
4309 chan->band_center_freq1 = config->channels[i].chan_freq;
4310 chan->band_center_freq2 = 0;
4311 chan->info = 0;
4312
Zhang Qian11c0de32018-01-05 16:50:53 +08004313 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304314 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4315 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4316 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4317 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4318 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4319 config->channels[i].antenna_max);
4320
4321 if (config->channels[i].bandwidth < 10)
4322 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4323 else if (config->channels[i].bandwidth < 20)
4324 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4325 buf_ptr += sizeof(*chan);
4326 }
4327
4328 /* Add the wmi_ocb_channel info */
4329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4330 config->channel_count*sizeof(wmi_ocb_channel));
4331 buf_ptr += WMI_TLV_HDR_SIZE;
4332 for (i = 0; i < config->channel_count; i++) {
4333 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4334 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4335 WMITLV_TAG_STRUC_wmi_ocb_channel,
4336 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4337 ocb_chan->bandwidth = config->channels[i].bandwidth;
4338 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4339 config->channels[i].mac_address.bytes,
4340 &ocb_chan->mac_address);
4341 buf_ptr += sizeof(*ocb_chan);
4342 }
4343
4344 /* Add the wmi_qos_parameter info */
4345 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4346 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4347 buf_ptr += WMI_TLV_HDR_SIZE;
4348 /* WMI_MAX_NUM_AC parameters for each channel */
4349 for (i = 0; i < config->channel_count; i++) {
4350 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4351 qos_param = (wmi_qos_parameter *)buf_ptr;
4352 WMITLV_SET_HDR(&qos_param->tlv_header,
4353 WMITLV_TAG_STRUC_wmi_qos_parameter,
4354 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4355 qos_param->aifsn =
4356 config->channels[i].qos_params[j].aifsn;
4357 qos_param->cwmin =
4358 config->channels[i].qos_params[j].cwmin;
4359 qos_param->cwmax =
4360 config->channels[i].qos_params[j].cwmax;
4361 buf_ptr += sizeof(*qos_param);
4362 }
4363 }
4364
4365 /* Add the wmi_dcc_ndl_chan (per channel) */
4366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4367 config->dcc_ndl_chan_list_len);
4368 buf_ptr += WMI_TLV_HDR_SIZE;
4369 if (config->dcc_ndl_chan_list_len) {
4370 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304371 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304372 config->dcc_ndl_chan_list_len);
4373 for (i = 0; i < config->channel_count; i++)
4374 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4375 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4376 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4377 buf_ptr += config->dcc_ndl_chan_list_len;
4378 }
4379
4380 /* Add the wmi_dcc_ndl_active_state_config */
4381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4382 sizeof(wmi_dcc_ndl_active_state_config));
4383 buf_ptr += WMI_TLV_HDR_SIZE;
4384 if (active_state_count) {
4385 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304386 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304387 config->dcc_ndl_active_state_list,
4388 active_state_count * sizeof(*ndl_active_config));
4389 for (i = 0; i < active_state_count; ++i)
4390 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4391 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4392 WMITLV_GET_STRUCT_TLVLEN(
4393 wmi_dcc_ndl_active_state_config));
4394 buf_ptr += active_state_count *
4395 sizeof(*ndl_active_config);
4396 }
4397
4398 /* Add the wmi_ocb_schedule_element info */
4399 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4400 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4401 buf_ptr += WMI_TLV_HDR_SIZE;
4402 for (i = 0; i < config->schedule_size; i++) {
4403 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4404 WMITLV_SET_HDR(&sched_elem->tlv_header,
4405 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4406 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4407 sched_elem->channel_freq = config->schedule[i].chan_freq;
4408 sched_elem->total_duration = config->schedule[i].total_duration;
4409 sched_elem->guard_interval = config->schedule[i].guard_interval;
4410 buf_ptr += sizeof(*sched_elem);
4411 }
4412
4413
4414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4415 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304416 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304417 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304418 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304419 }
4420
Govind Singh67922e82016-04-01 16:48:57 +05304421 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304422}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304423
4424/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004425 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4426 * @wmi_handle: wmi handle
4427 * @evt_buf: wmi event buffer
4428 * @status: status buffer
4429 *
4430 * Return: QDF_STATUS_SUCCESS on success
4431 */
4432static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4433 void *evt_buf,
4434 uint32_t *status)
4435{
4436 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4437 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4438
4439 param_tlvs = evt_buf;
4440 fix_param = param_tlvs->fixed_param;
4441
4442 *status = fix_param->status;
4443 return QDF_STATUS_SUCCESS;
4444}
4445
4446/**
4447 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4448 * @wmi_handle: wmi handle
4449 * @evt_buf: wmi event buffer
4450 * @resp: response buffer
4451 *
4452 * Return: QDF_STATUS_SUCCESS on success
4453 */
4454static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4455 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4456{
4457 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4458 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4459
4460 param_tlvs = evt_buf;
4461 fix_param = param_tlvs->fixed_param;
4462 resp->vdev_id = fix_param->vdev_id;
4463 resp->timer_high = fix_param->tsf_timer_high;
4464 resp->timer_low = fix_param->tsf_timer_low;
4465
4466 return QDF_STATUS_SUCCESS;
4467}
4468
4469/**
4470 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4471 * @wmi_handle: wmi handle
4472 * @evt_buf: wmi event buffer
4473 * @resp: response buffer
4474 *
4475 * Return: QDF_STATUS_SUCCESS on success
4476 */
4477static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4478 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4479{
4480 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4481 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4482
4483 param_tlvs = evt_buf;
4484 fix_param = param_tlvs->fixed_param;
4485 resp->vdev_id = fix_param->vdev_id;
4486 resp->status = fix_param->status;
4487 return QDF_STATUS_SUCCESS;
4488}
4489
4490/**
4491 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4492 * @wmi_handle: wmi handle
4493 * @evt_buf: wmi event buffer
4494 * @resp: response buffer
4495 *
4496 * Since length of stats is variable, buffer for DCC stats will be allocated
4497 * in this function. The caller must free the buffer.
4498 *
4499 * Return: QDF_STATUS_SUCCESS on success
4500 */
4501static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4502 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4503{
4504 struct ocb_dcc_get_stats_response *response;
4505 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4506 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4507
4508 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4509 fix_param = param_tlvs->fixed_param;
4510
4511 /* Allocate and populate the response */
4512 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4513 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4514 WMI_LOGE("%s: too many channels:%d", __func__,
4515 fix_param->num_channels);
4516 QDF_ASSERT(0);
4517 *resp = NULL;
4518 return QDF_STATUS_E_INVAL;
4519 }
4520 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4521 sizeof(wmi_dcc_ndl_stats_per_channel));
4522 *resp = response;
4523 if (!response)
4524 return QDF_STATUS_E_NOMEM;
4525
4526 response->vdev_id = fix_param->vdev_id;
4527 response->num_channels = fix_param->num_channels;
4528 response->channel_stats_array_len =
4529 fix_param->num_channels *
4530 sizeof(wmi_dcc_ndl_stats_per_channel);
4531 response->channel_stats_array = ((uint8_t *)response) +
4532 sizeof(*response);
4533 qdf_mem_copy(response->channel_stats_array,
4534 param_tlvs->stats_per_channel_list,
4535 response->channel_stats_array_len);
4536
4537 return QDF_STATUS_SUCCESS;
4538}
4539#endif
4540
4541/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304542 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4543 * @wmi_handle: wmi handle
4544 * @mcc_adaptive_scheduler: enable/disable
4545 *
4546 * This function enable/disable mcc adaptive scheduler in fw.
4547 *
Govind Singhb53420c2016-03-09 14:32:57 +05304548 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304550static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004551 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4552 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304553{
Govind Singh67922e82016-04-01 16:48:57 +05304554 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304555 wmi_buf_t buf = 0;
4556 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4557 uint16_t len =
4558 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4559
4560 buf = wmi_buf_alloc(wmi_handle, len);
4561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304562 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4563 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304564 }
4565 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4566 wmi_buf_data(buf);
4567
4568 WMITLV_SET_HDR(&cmd->tlv_header,
4569 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4570 WMITLV_GET_STRUCT_TLVLEN
4571 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4572 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304573 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304574
4575 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4576 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304577 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304578 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304579 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304580 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304581 }
Govind Singh67922e82016-04-01 16:48:57 +05304582
4583 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304584}
4585
4586/**
4587 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4588 * @wmi: wmi handle
4589 * @mcc_channel: mcc channel
4590 * @mcc_channel_time_latency: MCC channel time latency.
4591 *
4592 * Currently used to set time latency for an MCC vdev/adapter using operating
4593 * channel of it and channel number. The info is provided run time using
4594 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4595 *
4596 * Return: CDF status
4597 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304598static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304599 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4600{
Govind Singh67922e82016-04-01 16:48:57 +05304601 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304602 wmi_buf_t buf = 0;
4603 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4604 uint16_t len = 0;
4605 uint8_t *buf_ptr = NULL;
4606 wmi_resmgr_chan_latency chan_latency;
4607 /* Note: we only support MCC time latency for a single channel */
4608 uint32_t num_channels = 1;
4609 uint32_t chan1_freq = mcc_channel_freq;
4610 uint32_t latency_chan1 = mcc_channel_time_latency;
4611
4612
4613 /* If 0ms latency is provided, then FW will set to a default.
4614 * Otherwise, latency must be at least 30ms.
4615 */
4616 if ((latency_chan1 > 0) &&
4617 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304618 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304619 "Minimum is 30ms (or 0 to use default value by "
4620 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304621 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304622 }
4623
4624 /* Set WMI CMD for channel time latency here */
4625 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4626 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4627 num_channels * sizeof(wmi_resmgr_chan_latency);
4628 buf = wmi_buf_alloc(wmi_handle, len);
4629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304630 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4631 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304632 }
4633 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4634 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4635 wmi_buf_data(buf);
4636 WMITLV_SET_HDR(&cmdTL->tlv_header,
4637 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4638 WMITLV_GET_STRUCT_TLVLEN
4639 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4640 cmdTL->num_chans = num_channels;
4641 /* Update channel time latency information for home channel(s) */
4642 buf_ptr += sizeof(*cmdTL);
4643 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4644 num_channels * sizeof(wmi_resmgr_chan_latency));
4645 buf_ptr += WMI_TLV_HDR_SIZE;
4646 chan_latency.chan_mhz = chan1_freq;
4647 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304648 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304649 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4650 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304651 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304652 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304653 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304654 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304655 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304656 }
Govind Singh67922e82016-04-01 16:48:57 +05304657
4658 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304659}
4660
4661/**
4662 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4663 * @wmi: wmi handle
4664 * @adapter_1_chan_number: adapter 1 channel number
4665 * @adapter_1_quota: adapter 1 quota
4666 * @adapter_2_chan_number: adapter 2 channel number
4667 *
4668 * Return: CDF status
4669 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304670static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304671 uint32_t adapter_1_chan_freq,
4672 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4673{
Govind Singh67922e82016-04-01 16:48:57 +05304674 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304675 wmi_buf_t buf = 0;
4676 uint16_t len = 0;
4677 uint8_t *buf_ptr = NULL;
4678 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4679 wmi_resmgr_chan_time_quota chan_quota;
4680 uint32_t quota_chan1 = adapter_1_quota;
4681 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4682 uint32_t quota_chan2 = 100 - quota_chan1;
4683 /* Note: setting time quota for MCC requires info for 2 channels */
4684 uint32_t num_channels = 2;
4685 uint32_t chan1_freq = adapter_1_chan_freq;
4686 uint32_t chan2_freq = adapter_2_chan_freq;
4687
Govind Singhb53420c2016-03-09 14:32:57 +05304688 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304689 "freq2:%dMHz, Quota2:%dms", __func__,
4690 chan1_freq, quota_chan1, chan2_freq,
4691 quota_chan2);
4692
4693 /*
4694 * Perform sanity check on time quota values provided.
4695 */
4696 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4697 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304698 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304699 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304700 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304701 }
4702 /* Set WMI CMD for channel time quota here */
4703 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4704 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4705 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4706 buf = wmi_buf_alloc(wmi_handle, len);
4707 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304708 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4709 QDF_ASSERT(0);
4710 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304711 }
4712 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4713 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4714 wmi_buf_data(buf);
4715 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4716 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4717 WMITLV_GET_STRUCT_TLVLEN
4718 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4719 cmdTQ->num_chans = num_channels;
4720
4721 /* Update channel time quota information for home channel(s) */
4722 buf_ptr += sizeof(*cmdTQ);
4723 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4724 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4725 buf_ptr += WMI_TLV_HDR_SIZE;
4726 chan_quota.chan_mhz = chan1_freq;
4727 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304728 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304729 /* Construct channel and quota record for the 2nd MCC mode. */
4730 buf_ptr += sizeof(chan_quota);
4731 chan_quota.chan_mhz = chan2_freq;
4732 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304733 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304734
4735 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4736 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304737 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304738 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304739 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304740 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304741 }
Govind Singh67922e82016-04-01 16:48:57 +05304742
4743 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304744}
4745
4746/**
4747 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4748 * @wmi_handle: Pointer to wmi handle
4749 * @thermal_info: Thermal command information
4750 *
4751 * This function sends the thermal management command
4752 * to the firmware
4753 *
Govind Singhb53420c2016-03-09 14:32:57 +05304754 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304755 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304756static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304757 struct thermal_cmd_params *thermal_info)
4758{
4759 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4760 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304761 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304762 uint32_t len = 0;
4763
4764 len = sizeof(*cmd);
4765
4766 buf = wmi_buf_alloc(wmi_handle, len);
4767 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304768 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4769 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304770 }
4771
4772 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4773
4774 WMITLV_SET_HDR(&cmd->tlv_header,
4775 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4776 WMITLV_GET_STRUCT_TLVLEN
4777 (wmi_thermal_mgmt_cmd_fixed_param));
4778
4779 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4780 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4781 cmd->enable = thermal_info->thermal_enable;
4782
Govind Singhb53420c2016-03-09 14:32:57 +05304783 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304784 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4785
4786 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4787 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304788 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304789 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304790 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304791 }
4792
Govind Singh67922e82016-04-01 16:48:57 +05304793 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304794}
4795
4796
4797/**
4798 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304799 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304800 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4801 *
4802 * This function sends down the LRO configuration parameters to
4803 * the firmware to enable LRO, sets the TCP flags and sets the
4804 * seed values for the toeplitz hash generation
4805 *
Govind Singhb53420c2016-03-09 14:32:57 +05304806 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304807 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304808static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304809 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4810{
4811 wmi_lro_info_cmd_fixed_param *cmd;
4812 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304813 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304814
4815
4816 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4817 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304818 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4819 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304820 }
4821
4822 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4823
4824 WMITLV_SET_HDR(&cmd->tlv_header,
4825 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4826 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4827
4828 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4829 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4830 wmi_lro_cmd->tcp_flag);
4831 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4832 wmi_lro_cmd->tcp_flag_mask);
4833 cmd->toeplitz_hash_ipv4_0_3 =
4834 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4835 cmd->toeplitz_hash_ipv4_4_7 =
4836 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4837 cmd->toeplitz_hash_ipv4_8_11 =
4838 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4839 cmd->toeplitz_hash_ipv4_12_15 =
4840 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4841 cmd->toeplitz_hash_ipv4_16 =
4842 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4843
4844 cmd->toeplitz_hash_ipv6_0_3 =
4845 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4846 cmd->toeplitz_hash_ipv6_4_7 =
4847 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4848 cmd->toeplitz_hash_ipv6_8_11 =
4849 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4850 cmd->toeplitz_hash_ipv6_12_15 =
4851 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4852 cmd->toeplitz_hash_ipv6_16_19 =
4853 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4854 cmd->toeplitz_hash_ipv6_20_23 =
4855 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4856 cmd->toeplitz_hash_ipv6_24_27 =
4857 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4858 cmd->toeplitz_hash_ipv6_28_31 =
4859 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4860 cmd->toeplitz_hash_ipv6_32_35 =
4861 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4862 cmd->toeplitz_hash_ipv6_36_39 =
4863 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4864 cmd->toeplitz_hash_ipv6_40 =
4865 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4866
Govind Singhb53420c2016-03-09 14:32:57 +05304867 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304868 cmd->lro_enable, cmd->tcp_flag_u32);
4869
4870 status = wmi_unified_cmd_send(wmi_handle, buf,
4871 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304872 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304873 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304874 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304875 }
4876
Govind Singh67922e82016-04-01 16:48:57 +05304877 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304878}
4879
Govind Singh4eacd2b2016-03-07 14:24:22 +05304880/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304881 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4882 * @wmi_handle: Pointer to wmi handle
4883 * @rate_report_params: Pointer to peer rate report parameters
4884 *
4885 *
4886 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4887 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304888static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304889 struct wmi_peer_rate_report_params *rate_report_params)
4890{
4891 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4892 wmi_buf_t buf = NULL;
4893 QDF_STATUS status = 0;
4894 uint32_t len = 0;
4895 uint32_t i, j;
4896
4897 len = sizeof(*cmd);
4898
4899 buf = wmi_buf_alloc(wmi_handle, len);
4900 if (!buf) {
4901 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4902 return QDF_STATUS_E_FAILURE;
4903 }
4904
4905 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4906 wmi_buf_data(buf);
4907
4908 WMITLV_SET_HDR(
4909 &cmd->tlv_header,
4910 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4911 WMITLV_GET_STRUCT_TLVLEN(
4912 wmi_peer_set_rate_report_condition_fixed_param));
4913
4914 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4915 cmd->report_backoff_time = rate_report_params->backoff_time;
4916 cmd->report_timer_period = rate_report_params->timer_period;
4917 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4918 cmd->cond_per_phy[i].val_cond_flags =
4919 rate_report_params->report_per_phy[i].cond_flags;
4920 cmd->cond_per_phy[i].rate_delta.min_delta =
4921 rate_report_params->report_per_phy[i].delta.delta_min;
4922 cmd->cond_per_phy[i].rate_delta.percentage =
4923 rate_report_params->report_per_phy[i].delta.percent;
4924 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4925 cmd->cond_per_phy[i].rate_threshold[j] =
4926 rate_report_params->report_per_phy[i].
4927 report_rate_threshold[j];
4928 }
4929 }
4930
4931 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4932 cmd->enable_rate_report,
4933 cmd->report_backoff_time, cmd->report_timer_period);
4934
4935 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4936 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4937 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304938 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304939 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4940 __func__);
4941 }
4942 return status;
4943}
4944
4945/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304946 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4947 * @wmi_handle: wmi handle
4948 * @param: bcn ll cmd parameter
4949 *
Govind Singhb53420c2016-03-09 14:32:57 +05304950 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304951 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304952static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304953 wmi_bcn_send_from_host_cmd_fixed_param *param)
4954{
4955 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4956 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304957 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304958
4959 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4960 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304961 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4962 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304963 }
4964
4965 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4966 WMITLV_SET_HDR(&cmd->tlv_header,
4967 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4968 WMITLV_GET_STRUCT_TLVLEN
4969 (wmi_bcn_send_from_host_cmd_fixed_param));
4970 cmd->vdev_id = param->vdev_id;
4971 cmd->data_len = param->data_len;
4972 cmd->frame_ctrl = param->frame_ctrl;
4973 cmd->frag_ptr = param->frag_ptr;
4974 cmd->dtim_flag = param->dtim_flag;
4975
4976 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4977 WMI_PDEV_SEND_BCN_CMDID);
4978
Govind Singh67922e82016-04-01 16:48:57 +05304979 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304980 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304981 wmi_buf_free(wmi_buf);
4982 }
4983
4984 return ret;
4985}
4986
4987/**
4988 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4989 * @wmi_handle: wmi handle
4990 * @vdev_id: vdev id
4991 * @max_retries: max retries
4992 * @retry_interval: retry interval
4993 * This function sets sta query related parameters in fw.
4994 *
Govind Singhb53420c2016-03-09 14:32:57 +05304995 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304996 */
4997
Sathish Kumarfd347372017-02-13 12:29:09 +05304998static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304999 uint8_t vdev_id, uint32_t max_retries,
5000 uint32_t retry_interval)
5001{
5002 wmi_buf_t buf;
5003 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5004 int len;
5005
5006 len = sizeof(*cmd);
5007 buf = wmi_buf_alloc(wmi_handle, len);
5008 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305009 WMI_LOGE(FL("wmi_buf_alloc failed"));
5010 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305011 }
5012
5013 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5014 WMITLV_SET_HDR(&cmd->tlv_header,
5015 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5016 WMITLV_GET_STRUCT_TLVLEN
5017 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5018
5019
5020 cmd->vdev_id = vdev_id;
5021 cmd->sa_query_max_retry_count = max_retries;
5022 cmd->sa_query_retry_interval = retry_interval;
5023
Govind Singhb53420c2016-03-09 14:32:57 +05305024 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305025 vdev_id, retry_interval, max_retries);
5026
5027 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5028 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305029 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305030 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305031 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305032 }
5033
Govind Singhb53420c2016-03-09 14:32:57 +05305034 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305035 return 0;
5036}
5037
5038/**
5039 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5040 * @wmi_handle: wmi handle
5041 * @params: sta keep alive parameter
5042 *
5043 * This function sets keep alive related parameters in fw.
5044 *
5045 * Return: CDF status
5046 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305047static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305048 struct sta_params *params)
5049{
5050 wmi_buf_t buf;
5051 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5052 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5053 uint8_t *buf_ptr;
5054 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305055 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305056
Govind Singhb53420c2016-03-09 14:32:57 +05305057 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305058
Govind Singh4eacd2b2016-03-07 14:24:22 +05305059 len = sizeof(*cmd) + sizeof(*arp_rsp);
5060 buf = wmi_buf_alloc(wmi_handle, len);
5061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305062 WMI_LOGE("wmi_buf_alloc failed");
5063 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305064 }
5065
5066 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5067 buf_ptr = (uint8_t *) cmd;
5068 WMITLV_SET_HDR(&cmd->tlv_header,
5069 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5070 WMITLV_GET_STRUCT_TLVLEN
5071 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5072 cmd->interval = params->timeperiod;
5073 cmd->enable = (params->timeperiod) ? 1 : 0;
5074 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305075 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305076 params->timeperiod, params->method);
5077 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5078 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5079 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5080 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5081
c_manjee2772b9c2017-01-23 15:14:13 +05305082 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5083 (params->method ==
5084 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305085 if ((NULL == params->hostv4addr) ||
5086 (NULL == params->destv4addr) ||
5087 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005088 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5089 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305090 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305091 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305092 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093 }
c_manjee2772b9c2017-01-23 15:14:13 +05305094 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305095 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305097 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305098 WMI_IPV4_ADDR_LEN);
5099 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5100 } else {
5101 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5102 }
5103
Govind Singh67922e82016-04-01 16:48:57 +05305104 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5105 WMI_STA_KEEPALIVE_CMDID);
5106 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305107 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305108 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305109 }
5110
Govind Singhb53420c2016-03-09 14:32:57 +05305111 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305112 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113}
5114
5115/**
5116 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5117 * @wmi_handle: wmi handle
5118 * @if_id: vdev id
5119 * @gtx_info: GTX config params
5120 *
5121 * This function set GTX related params in firmware.
5122 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305123 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305124 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305125static 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 +05305126 struct wmi_gtx_config *gtx_info)
5127{
5128 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5129 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305130 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305131 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305132
Govind Singh4eacd2b2016-03-07 14:24:22 +05305133 buf = wmi_buf_alloc(wmi_handle, len);
5134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305135 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305136 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305137 }
5138 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5139 WMITLV_SET_HDR(&cmd->tlv_header,
5140 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5141 WMITLV_GET_STRUCT_TLVLEN
5142 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5143 cmd->vdev_id = if_id;
5144
5145 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5146 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5147 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5148 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5149 cmd->gtxPERMargin = gtx_info->gtx_margin;
5150 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5151 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5152 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5153
Govind Singhb53420c2016-03-09 14:32:57 +05305154 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305155 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5156 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5157 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5158 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5159
Abhishek Singh716c46c2016-05-04 16:24:07 +05305160 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305161 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305162 if (QDF_IS_STATUS_ERROR(ret)) {
5163 WMI_LOGE("Failed to set GTX PARAMS");
5164 wmi_buf_free(buf);
5165 }
5166 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305167}
5168
5169/**
5170 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5171 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305172 * @vdev_id: vdev id.
5173 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305174 *
5175 * This function updates EDCA parameters to the target
5176 *
5177 * Return: CDF Status
5178 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305179static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005180 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305181 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305182{
5183 uint8_t *buf_ptr;
5184 wmi_buf_t buf;
5185 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305186 wmi_wmm_vparams *wmm_param;
5187 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 int len = sizeof(*cmd);
5189 int ac;
5190
5191 buf = wmi_buf_alloc(wmi_handle, len);
5192
5193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305194 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5195 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305196 }
5197
5198 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5199 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5200 WMITLV_SET_HDR(&cmd->tlv_header,
5201 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5202 WMITLV_GET_STRUCT_TLVLEN
5203 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5204 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005205 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305206
5207 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5208 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305209 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305210 WMITLV_SET_HDR(&wmm_param->tlv_header,
5211 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5212 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5213 wmm_param->cwmin = twmm_param->cwmin;
5214 wmm_param->cwmax = twmm_param->cwmax;
5215 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005216 if (mu_edca_param)
5217 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5218 else
5219 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305221 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305222 }
5223
5224 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5225 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5226 goto fail;
5227
Govind Singhb53420c2016-03-09 14:32:57 +05305228 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305229
5230fail:
5231 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305232 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5233 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234}
5235
5236/**
5237 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5238 * @wmi_handle: wmi handle
5239 * @vdev_id: vdev id
5240 * @probe_rsp_info: probe response info
5241 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305242 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305243 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305244static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305245 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005246 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247{
5248 wmi_prb_tmpl_cmd_fixed_param *cmd;
5249 wmi_bcn_prb_info *bcn_prb_info;
5250 wmi_buf_t wmi_buf;
5251 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5252 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305253 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305254
Govind Singhb53420c2016-03-09 14:32:57 +05305255 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256
Krunal Soni89426862017-11-14 15:42:48 -08005257 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305258 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305259
5260 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5261 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5262 tmpl_len_aligned;
5263
5264 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305265 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305266 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305267 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305268 }
5269
5270 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5271 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305272 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305273 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305274 }
5275
5276 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5277
5278 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5279 WMITLV_SET_HDR(&cmd->tlv_header,
5280 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5281 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5282 cmd->vdev_id = vdev_id;
5283 cmd->buf_len = tmpl_len;
5284 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5285
5286 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5287 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5288 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5289 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5290 bcn_prb_info->caps = 0;
5291 bcn_prb_info->erp = 0;
5292 buf_ptr += sizeof(wmi_bcn_prb_info);
5293
5294 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5295 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005296 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305297
5298 ret = wmi_unified_cmd_send(wmi_handle,
5299 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305300 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305301 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305302 wmi_buf_free(wmi_buf);
5303 }
5304
5305 return ret;
5306}
5307
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305308#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305309#define WPI_IV_LEN 16
5310
5311/**
5312 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5313 *
5314 * @dest_tx: destination address of tsc key counter
5315 * @src_tx: source address of tsc key counter
5316 * @dest_rx: destination address of rsc key counter
5317 * @src_rx: source address of rsc key counter
5318 *
5319 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5320 *
5321 * Return: None
5322 *
5323 */
5324static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5325 uint8_t *dest_rx, uint8_t *src_rx)
5326{
5327 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5328 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5329}
5330#else
5331static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5332 uint8_t *dest_rx, uint8_t *src_rx)
5333{
5334 return;
5335}
5336#endif
5337
5338/**
5339 * send_setup_install_key_cmd_tlv() - set key parameters
5340 * @wmi_handle: wmi handle
5341 * @key_params: key parameters
5342 *
5343 * This function fills structure from information
5344 * passed in key_params.
5345 *
5346 * Return: QDF_STATUS_SUCCESS - success
5347 * QDF_STATUS_E_FAILURE - failure
5348 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5349 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305350static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305351 struct set_key_params *key_params)
5352{
5353 wmi_vdev_install_key_cmd_fixed_param *cmd;
5354 wmi_buf_t buf;
5355 uint8_t *buf_ptr;
5356 uint32_t len;
5357 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305358 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305359
5360 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5361 WMI_TLV_HDR_SIZE;
5362
5363 buf = wmi_buf_alloc(wmi_handle, len);
5364 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305365 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305366 return QDF_STATUS_E_NOMEM;
5367 }
5368
5369 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5370 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5371 WMITLV_SET_HDR(&cmd->tlv_header,
5372 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5373 WMITLV_GET_STRUCT_TLVLEN
5374 (wmi_vdev_install_key_cmd_fixed_param));
5375 cmd->vdev_id = key_params->vdev_id;
5376 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305377
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305378
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305379 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5380 cmd->key_flags |= key_params->key_flags;
5381 cmd->key_cipher = key_params->key_cipher;
5382 if ((key_params->key_txmic_len) &&
5383 (key_params->key_rxmic_len)) {
5384 cmd->key_txmic_len = key_params->key_txmic_len;
5385 cmd->key_rxmic_len = key_params->key_rxmic_len;
5386 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305387#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305388 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5389 key_params->tx_iv,
5390 cmd->wpi_key_rsc_counter,
5391 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305392#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305393 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5395 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305396 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305397 qdf_mem_copy((void *)key_data,
5398 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005399 if (key_params->key_rsc_counter)
5400 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5401 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305402 cmd->key_len = key_params->key_len;
5403
5404 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5405 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305406 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305407 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305408
Govind Singh67922e82016-04-01 16:48:57 +05305409 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305410}
5411
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305412/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005413 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5414 * @wmi_handle: wmi handle
5415 * @params: sar limit params
5416 *
5417 * Return: QDF_STATUS_SUCCESS for success or error code
5418 */
5419static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5420 struct sar_limit_cmd_params *sar_limit_params)
5421{
5422 wmi_buf_t buf;
5423 QDF_STATUS qdf_status;
5424 wmi_sar_limits_cmd_fixed_param *cmd;
5425 int i;
5426 uint8_t *buf_ptr;
5427 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5428 struct sar_limit_cmd_row *sar_rows_list;
5429 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5430
5431 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5432 buf = wmi_buf_alloc(wmi_handle, len);
5433 if (!buf) {
5434 WMI_LOGE("Failed to allocate memory");
5435 qdf_status = QDF_STATUS_E_NOMEM;
5436 goto end;
5437 }
5438
5439 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5440 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5441 WMITLV_SET_HDR(&cmd->tlv_header,
5442 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5443 WMITLV_GET_STRUCT_TLVLEN
5444 (wmi_sar_limits_cmd_fixed_param));
5445 cmd->sar_enable = sar_limit_params->sar_enable;
5446 cmd->commit_limits = sar_limit_params->commit_limits;
5447 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5448
5449 WMI_LOGD("no of sar rows = %d, len = %d",
5450 sar_limit_params->num_limit_rows, len);
5451 buf_ptr += sizeof(*cmd);
5452 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5453 sizeof(wmi_sar_limit_cmd_row) *
5454 sar_limit_params->num_limit_rows);
5455 if (cmd->num_limit_rows == 0)
5456 goto send_sar_limits;
5457
5458 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5459 (buf_ptr + WMI_TLV_HDR_SIZE);
5460 sar_rows_list = sar_limit_params->sar_limit_row_list;
5461
5462 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5463 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5464 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5465 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5466 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5467 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5468 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5469 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5470 wmi_sar_rows_list->validity_bitmap =
5471 sar_rows_list->validity_bitmap;
5472 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5473 i, wmi_sar_rows_list->band_id,
5474 wmi_sar_rows_list->chain_id,
5475 wmi_sar_rows_list->mod_id,
5476 wmi_sar_rows_list->limit_value,
5477 wmi_sar_rows_list->validity_bitmap);
5478 sar_rows_list++;
5479 wmi_sar_rows_list++;
5480 }
5481send_sar_limits:
5482 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5483 WMI_SAR_LIMITS_CMDID);
5484
5485 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5486 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5487 wmi_buf_free(buf);
5488 }
5489
5490end:
5491 return qdf_status;
5492}
5493
Jeff Johnson4783f902017-12-14 15:50:16 -08005494static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5495{
5496 wmi_sar_get_limits_cmd_fixed_param *cmd;
5497 wmi_buf_t wmi_buf;
5498 uint32_t len;
5499 QDF_STATUS status;
5500
5501 WMI_LOGD(FL("Enter"));
5502
5503 len = sizeof(*cmd);
5504 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5505 if (!wmi_buf) {
5506 WMI_LOGP(FL("failed to allocate memory for msg"));
5507 return QDF_STATUS_E_NOMEM;
5508 }
5509
5510 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5511
5512 WMITLV_SET_HDR(&cmd->tlv_header,
5513 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5514 WMITLV_GET_STRUCT_TLVLEN
5515 (wmi_sar_get_limits_cmd_fixed_param));
5516
5517 cmd->reserved = 0;
5518
5519 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5520 WMI_SAR_GET_LIMITS_CMDID);
5521 if (QDF_IS_STATUS_ERROR(status)) {
5522 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5523 wmi_buf_free(wmi_buf);
5524 }
5525
5526 WMI_LOGD(FL("Exit"));
5527
5528 return status;
5529}
5530
5531static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5532 uint8_t *evt_buf,
5533 struct sar_limit_event *event)
5534{
5535 wmi_sar_get_limits_event_fixed_param *fixed_param;
5536 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5537 wmi_sar_get_limit_event_row *row_in;
5538 struct sar_limit_event_row *row_out;
5539 uint32_t row;
5540
5541 if (!evt_buf) {
5542 WMI_LOGE(FL("input event is NULL"));
5543 return QDF_STATUS_E_INVAL;
5544 }
5545 if (!event) {
5546 WMI_LOGE(FL("output event is NULL"));
5547 return QDF_STATUS_E_INVAL;
5548 }
5549
5550 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5551
5552 fixed_param = param_buf->fixed_param;
5553 if (!fixed_param) {
5554 WMI_LOGE(FL("Invalid fixed param"));
5555 return QDF_STATUS_E_INVAL;
5556 }
5557
5558 event->sar_enable = fixed_param->sar_enable;
5559 event->num_limit_rows = fixed_param->num_limit_rows;
5560
5561 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5562 QDF_ASSERT(0);
5563 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5564 event->num_limit_rows,
5565 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5566 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5567 }
5568
5569 row_in = param_buf->sar_get_limits;
5570 row_out = &event->sar_limit_row[0];
5571 for (row = 0; row < event->num_limit_rows; row++) {
5572 row_out->band_id = row_in->band_id;
5573 row_out->chain_id = row_in->chain_id;
5574 row_out->mod_id = row_in->mod_id;
5575 row_out->limit_value = row_in->limit_value;
5576 row_out++;
5577 row_in++;
5578 }
5579
5580 return QDF_STATUS_SUCCESS;
5581}
5582
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305583#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005584/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305585 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5586 * @wmi_handle: wmi handle
5587 * @params: encrypt/decrypt params
5588 *
5589 * Return: QDF_STATUS_SUCCESS for success or error code
5590 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005591static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305592QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305593 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305594{
5595 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5596 wmi_buf_t wmi_buf;
5597 uint8_t *buf_ptr;
5598 QDF_STATUS ret;
5599 uint32_t len;
5600
5601 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5602
5603 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305604 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305605 WMI_TLV_HDR_SIZE;
5606 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5607 if (!wmi_buf) {
5608 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5609 __func__);
5610 return QDF_STATUS_E_NOMEM;
5611 }
5612
5613 buf_ptr = wmi_buf_data(wmi_buf);
5614 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5615
5616 WMITLV_SET_HDR(&cmd->tlv_header,
5617 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5618 WMITLV_GET_STRUCT_TLVLEN(
5619 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5620
5621 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5622 cmd->key_flag = encrypt_decrypt_params->key_flag;
5623 cmd->key_idx = encrypt_decrypt_params->key_idx;
5624 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5625 cmd->key_len = encrypt_decrypt_params->key_len;
5626 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5627 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5628
5629 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5630 encrypt_decrypt_params->key_len);
5631
5632 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5633 MAX_MAC_HEADER_LEN);
5634
5635 cmd->data_len = encrypt_decrypt_params->data_len;
5636
5637 if (cmd->data_len) {
5638 buf_ptr += sizeof(*cmd);
5639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5640 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305641 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305642 buf_ptr += WMI_TLV_HDR_SIZE;
5643 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5644 encrypt_decrypt_params->data_len);
5645 }
5646
5647 /* This conversion is to facilitate data to FW in little endian */
5648 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5649 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5650 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5651 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5652 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5653 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5654
5655 ret = wmi_unified_cmd_send(wmi_handle,
5656 wmi_buf, len,
5657 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5658 if (QDF_IS_STATUS_ERROR(ret)) {
5659 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5660 wmi_buf_free(wmi_buf);
5661 }
5662
5663 return ret;
5664}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305665
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305666/**
5667 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5668 * params from event
5669 * @wmi_handle: wmi handle
5670 * @evt_buf: pointer to event buffer
5671 * @resp: Pointer to hold resp parameters
5672 *
5673 * Return: QDF_STATUS_SUCCESS for success or error code
5674 */
5675static
5676QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5677 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5678{
5679 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5680 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5681
5682 param_buf = evt_buf;
5683 if (!param_buf) {
5684 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5685 return QDF_STATUS_E_INVAL;
5686 }
5687
5688 data_event = param_buf->fixed_param;
5689
5690 resp->vdev_id = data_event->vdev_id;
5691 resp->status = data_event->status;
5692
5693 if (data_event->data_length > param_buf->num_enc80211_frame) {
5694 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5695 data_event->data_length,
5696 param_buf->num_enc80211_frame);
5697 return QDF_STATUS_E_INVAL;
5698 }
5699
5700 resp->data_len = data_event->data_length;
5701
5702 if (resp->data_len)
5703 resp->data = (uint8_t *)param_buf->enc80211_frame;
5704
5705 return QDF_STATUS_SUCCESS;
5706}
5707#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305708
Govind Singh4eacd2b2016-03-07 14:24:22 +05305709/**
5710 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5711 * @wmi_handle: wmi handle
5712 * @vdev_id: vdev id
5713 * @p2p_ie: p2p IE
5714 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305715 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305717static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305718 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305719{
Govind Singh67922e82016-04-01 16:48:57 +05305720 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305721 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5722 wmi_buf_t wmi_buf;
5723 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5724 uint8_t *buf_ptr;
5725
5726 ie_len = (uint32_t) (p2p_ie[1] + 2);
5727
5728 /* More than one P2P IE may be included in a single frame.
5729 If multiple P2P IEs are present, the complete P2P attribute
5730 data consists of the concatenation of the P2P Attribute
5731 fields of the P2P IEs. The P2P Attributes field of each
5732 P2P IE may be any length up to the maximum (251 octets).
5733 In this case host sends one P2P IE to firmware so the length
5734 should not exceed more than 251 bytes
5735 */
5736 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305737 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305738 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305739 }
5740
Vivekc5823092018-03-22 23:27:21 +05305741 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305742
5743 wmi_buf_len =
5744 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5745 WMI_TLV_HDR_SIZE;
5746
5747 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5748 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305749 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305750 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305751 }
5752
5753 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5754
5755 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5756 WMITLV_SET_HDR(&cmd->tlv_header,
5757 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5758 WMITLV_GET_STRUCT_TLVLEN
5759 (wmi_p2p_go_set_beacon_ie_fixed_param));
5760 cmd->vdev_id = vdev_id;
5761 cmd->ie_buf_len = ie_len;
5762
5763 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5765 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305766 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305767
Govind Singhb53420c2016-03-09 14:32:57 +05305768 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305769
5770 ret = wmi_unified_cmd_send(wmi_handle,
5771 wmi_buf, wmi_buf_len,
5772 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305773 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305774 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305775 wmi_buf_free(wmi_buf);
5776 }
5777
Govind Singhb53420c2016-03-09 14:32:57 +05305778 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305779 return ret;
5780}
5781
5782/**
5783 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5784 * @wmi_handle: wmi handle
5785 * @req: gateway parameter update request structure
5786 *
5787 * This function reads the incoming @req and fill in the destination
5788 * WMI structure and sends down the gateway configs down to the firmware
5789 *
Govind Singhb53420c2016-03-09 14:32:57 +05305790 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305792static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305793 struct gateway_update_req_param *req)
5794{
5795 wmi_roam_subnet_change_config_fixed_param *cmd;
5796 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305797 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305798 int len = sizeof(*cmd);
5799
5800 buf = wmi_buf_alloc(wmi_handle, len);
5801 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305802 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5803 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305804 }
5805
5806 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5807 WMITLV_SET_HDR(&cmd->tlv_header,
5808 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5809 WMITLV_GET_STRUCT_TLVLEN(
5810 wmi_roam_subnet_change_config_fixed_param));
5811
5812 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305813 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5814 QDF_IPV4_ADDR_SIZE);
5815 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5816 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305817 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5818 &cmd->inet_gw_mac_addr);
5819 cmd->max_retries = req->max_retries;
5820 cmd->timeout = req->timeout;
5821 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5822 cmd->flag = 0;
5823 if (req->ipv4_addr_type)
5824 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5825
5826 if (req->ipv6_addr_type)
5827 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5828
5829 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5830 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305831 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305832 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833 ret);
5834 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305835 }
5836
Govind Singh67922e82016-04-01 16:48:57 +05305837 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305838}
5839
5840/**
5841 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5842 * @wmi_handle: wmi handle
5843 * @req: rssi monitoring request structure
5844 *
5845 * This function reads the incoming @req and fill in the destination
5846 * WMI structure and send down the rssi monitoring configs down to the firmware
5847 *
5848 * Return: 0 on success; error number otherwise
5849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305850static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305851 struct rssi_monitor_param *req)
5852{
5853 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5854 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305855 QDF_STATUS ret;
5856 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305857
5858 buf = wmi_buf_alloc(wmi_handle, len);
5859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305860 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5861 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305862 }
5863
5864 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5865 WMITLV_SET_HDR(&cmd->tlv_header,
5866 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5867 WMITLV_GET_STRUCT_TLVLEN(
5868 wmi_rssi_breach_monitor_config_fixed_param));
5869
5870 cmd->vdev_id = req->session_id;
5871 cmd->request_id = req->request_id;
5872 cmd->lo_rssi_reenable_hysteresis = 0;
5873 cmd->hi_rssi_reenable_histeresis = 0;
5874 cmd->min_report_interval = 0;
5875 cmd->max_num_report = 1;
5876 if (req->control) {
5877 /* enable one threshold for each min/max */
5878 cmd->enabled_bitmap = 0x09;
5879 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5880 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5881 } else {
5882 cmd->enabled_bitmap = 0;
5883 cmd->low_rssi_breach_threshold[0] = 0;
5884 cmd->hi_rssi_breach_threshold[0] = 0;
5885 }
5886
5887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5888 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305889 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305890 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305891 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305892 }
5893
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005894 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5895
Govind Singh67922e82016-04-01 16:48:57 +05305896 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305897}
5898
5899/**
5900 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5901 * @wmi_handle: wmi handle
5902 * @psetoui: OUI parameters
5903 *
5904 * set scan probe OUI parameters in firmware
5905 *
5906 * Return: CDF status
5907 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305908static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305909 struct scan_mac_oui *psetoui)
5910{
5911 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5912 wmi_buf_t wmi_buf;
5913 uint32_t len;
5914 uint8_t *buf_ptr;
5915 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305916 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305917
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305918 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5919 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5920
Govind Singh4eacd2b2016-03-07 14:24:22 +05305921 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5922 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305923 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5924 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305925 }
5926 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5927 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5928 WMITLV_SET_HDR(&cmd->tlv_header,
5929 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5930 WMITLV_GET_STRUCT_TLVLEN
5931 (wmi_scan_prob_req_oui_cmd_fixed_param));
5932
5933 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305934 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305935 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5936 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305937 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305938 cmd->prob_req_oui);
5939
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305940 cmd->vdev_id = psetoui->vdev_id;
5941 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5942 if (psetoui->enb_probe_req_sno_randomization)
5943 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5944
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305945 if (ie_whitelist->white_list) {
5946 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5947 &cmd->num_vendor_oui,
5948 ie_whitelist);
5949 cmd->flags |=
5950 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5951 }
5952
5953 buf_ptr += sizeof(*cmd);
5954 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5955 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5956 buf_ptr += WMI_TLV_HDR_SIZE;
5957
5958 if (cmd->num_vendor_oui != 0) {
5959 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5960 ie_whitelist->voui);
5961 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5962 }
5963
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5965 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305966 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305967 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305968 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305969 }
Govind Singhb53420c2016-03-09 14:32:57 +05305970 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971}
5972
5973/**
5974 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5975 * @wmi_handle: wmi handle
5976 * @req: passpoint network request structure
5977 *
5978 * This function sends down WMI command with network id set to wildcard id.
5979 * firmware shall clear all the config entries
5980 *
Govind Singhb53420c2016-03-09 14:32:57 +05305981 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305983static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305984 struct wifi_passpoint_req_param *req)
5985{
5986 wmi_passpoint_config_cmd_fixed_param *cmd;
5987 wmi_buf_t buf;
5988 uint32_t len;
5989 int ret;
5990
5991 len = sizeof(*cmd);
5992 buf = wmi_buf_alloc(wmi_handle, len);
5993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305994 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5995 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305996 }
5997
5998 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5999
6000 WMITLV_SET_HDR(&cmd->tlv_header,
6001 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6002 WMITLV_GET_STRUCT_TLVLEN(
6003 wmi_passpoint_config_cmd_fixed_param));
6004 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
6005
6006 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6007 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6008 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306009 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010 __func__);
6011 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306012 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 }
6014
Govind Singhb53420c2016-03-09 14:32:57 +05306015 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306016}
6017
6018/**
6019 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6020 * @wmi_handle: wmi handle
6021 * @req: passpoint network request structure
6022 *
6023 * This function reads the incoming @req and fill in the destination
6024 * WMI structure and send down the passpoint configs down to the firmware
6025 *
Govind Singhb53420c2016-03-09 14:32:57 +05306026 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306027 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306028static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306029 struct wifi_passpoint_req_param *req)
6030{
6031 wmi_passpoint_config_cmd_fixed_param *cmd;
6032 u_int8_t i, j, *bytes;
6033 wmi_buf_t buf;
6034 uint32_t len;
6035 int ret;
6036
6037 len = sizeof(*cmd);
6038 for (i = 0; i < req->num_networks; i++) {
6039 buf = wmi_buf_alloc(wmi_handle, len);
6040 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306041 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6042 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306043 }
6044
6045 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6046 wmi_buf_data(buf);
6047
6048 WMITLV_SET_HDR(&cmd->tlv_header,
6049 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6050 WMITLV_GET_STRUCT_TLVLEN(
6051 wmi_passpoint_config_cmd_fixed_param));
6052 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306053 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6054 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306055 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306056 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306057 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6058 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306059 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306060 j, bytes[0], bytes[1], bytes[2], bytes[3],
6061 bytes[4], bytes[5], bytes[6], bytes[7]);
6062
Govind Singhb53420c2016-03-09 14:32:57 +05306063 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064 &req->networks[i].roaming_consortium_ids[j],
6065 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6066 }
Govind Singhb53420c2016-03-09 14:32:57 +05306067 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306068 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306069 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306070 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6071
6072 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6073 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6074 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306075 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306076 __func__);
6077 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306078 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306079 }
6080 }
6081
Govind Singhb53420c2016-03-09 14:32:57 +05306082 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306083}
6084
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306085#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306086/**
6087 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6088 * @wmi_handle: wmi handle
6089 * @roam_req: Roam scan offload params
6090 * @buf_ptr: command buffer to send
6091 * @fils_tlv_len: fils tlv length
6092 *
6093 * Return: Updated buffer pointer
6094 */
6095static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6096 struct roam_offload_scan_params *roam_req,
6097 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6098{
6099 wmi_roam_fils_offload_tlv_param *fils_tlv;
6100 wmi_erp_info *erp_info;
6101 struct roam_fils_params *roam_fils_params;
6102
6103 if (!roam_req->add_fils_tlv)
6104 return buf_ptr;
6105
6106 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6107 sizeof(*fils_tlv));
6108 buf_ptr += WMI_TLV_HDR_SIZE;
6109
6110 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6111 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6112 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6113 WMITLV_GET_STRUCT_TLVLEN
6114 (wmi_roam_fils_offload_tlv_param));
6115
6116 roam_fils_params = &roam_req->roam_fils_params;
6117 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6118
6119 erp_info->username_length = roam_fils_params->username_length;
6120 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6121 erp_info->username_length);
6122
6123 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6124
6125 erp_info->rRk_length = roam_fils_params->rrk_length;
6126 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6127 erp_info->rRk_length);
6128
6129 erp_info->rIk_length = roam_fils_params->rik_length;
6130 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6131 erp_info->rIk_length);
6132
6133 erp_info->realm_len = roam_fils_params->realm_len;
6134 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6135 erp_info->realm_len);
6136
6137 buf_ptr += sizeof(*fils_tlv);
6138 return buf_ptr;
6139}
6140#else
6141static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6142 struct roam_offload_scan_params *roam_req,
6143 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6144{
6145 return buf_ptr;
6146}
6147#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306148/**
6149 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6150 * @wmi_handle: wmi handle
6151 * @scan_cmd_fp: start scan command ptr
6152 * @roam_req: roam request param
6153 *
6154 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6155 * of WMI_ROAM_SCAN_MODE.
6156 *
6157 * Return: QDF status
6158 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306159static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306160 wmi_start_scan_cmd_fixed_param *
6161 scan_cmd_fp,
6162 struct roam_offload_scan_params *roam_req)
6163{
6164 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306165 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306166 int len;
6167 uint8_t *buf_ptr;
6168 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306169
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306170#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6171 int auth_mode = roam_req->auth_mode;
6172 wmi_roam_offload_tlv_param *roam_offload_params;
6173 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6174 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6175 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306176 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306177 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306178#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6179 /* Need to create a buf with roam_scan command at
6180 * front and piggyback with scan command */
6181 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6182#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6183 (2 * WMI_TLV_HDR_SIZE) +
6184#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6185 sizeof(wmi_start_scan_cmd_fixed_param);
6186#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006187 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306188 if (roam_req->is_roam_req_valid &&
6189 roam_req->roam_offload_enabled) {
6190 len += sizeof(wmi_roam_offload_tlv_param);
6191 len += WMI_TLV_HDR_SIZE;
6192 if ((auth_mode != WMI_AUTH_NONE) &&
6193 ((auth_mode != WMI_AUTH_OPEN) ||
6194 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306195 roam_req->mdid.mdie_present &&
6196 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306197 roam_req->is_ese_assoc)) {
6198 len += WMI_TLV_HDR_SIZE;
6199 if (roam_req->is_ese_assoc)
6200 len +=
6201 sizeof(wmi_roam_ese_offload_tlv_param);
6202 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6203 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6204 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306205 roam_req->mdid.mdie_present &&
6206 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306207 len +=
6208 sizeof(wmi_roam_11r_offload_tlv_param);
6209 else
6210 len +=
6211 sizeof(wmi_roam_11i_offload_tlv_param);
6212 } else {
6213 len += WMI_TLV_HDR_SIZE;
6214 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306215
6216 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6217 + roundup(roam_req->assoc_ie_length,
6218 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306219
6220 if (roam_req->add_fils_tlv) {
6221 fils_tlv_len = sizeof(
6222 wmi_roam_fils_offload_tlv_param);
6223 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6224 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306225 } else {
6226 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306227 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306228 __func__, roam_req->roam_offload_enabled);
6229 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306230 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306231 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306232 }
6233 if (roam_req->is_roam_req_valid &&
6234 roam_req->roam_offload_enabled) {
6235 roam_req->mode = roam_req->mode |
6236 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6237 }
6238#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6239
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306240 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6241 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6242 len = sizeof(wmi_roam_scan_mode_fixed_param);
6243
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306244 buf = wmi_buf_alloc(wmi_handle, len);
6245 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306246 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306247 return QDF_STATUS_E_NOMEM;
6248 }
6249
6250 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6251 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6252 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6253 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6254 WMITLV_GET_STRUCT_TLVLEN
6255 (wmi_roam_scan_mode_fixed_param));
6256
Abhinav Kumar334355f2018-04-06 17:18:52 +05306257 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6258 roam_req->roam_trigger_reason_bitmask;
6259 roam_scan_mode_fp->min_delay_btw_scans =
6260 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306261 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6262 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306263 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6264 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6265 roam_scan_mode_fp->flags |=
6266 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306267 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306268 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306269
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306270 /* Fill in scan parameters suitable for roaming scan */
6271 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306272
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306273 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6274 sizeof(wmi_start_scan_cmd_fixed_param));
6275 /* Ensure there is no additional IEs */
6276 scan_cmd_fp->ie_len = 0;
6277 WMITLV_SET_HDR(buf_ptr,
6278 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6279 WMITLV_GET_STRUCT_TLVLEN
6280 (wmi_start_scan_cmd_fixed_param));
6281#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6282 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6283 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6284 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6285 sizeof(wmi_roam_offload_tlv_param));
6286 buf_ptr += WMI_TLV_HDR_SIZE;
6287 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6288 WMITLV_SET_HDR(buf_ptr,
6289 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6290 WMITLV_GET_STRUCT_TLVLEN
6291 (wmi_roam_offload_tlv_param));
6292 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6293 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6294 roam_offload_params->select_5g_margin =
6295 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306296 roam_offload_params->handoff_delay_for_rx =
6297 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306298 roam_offload_params->reassoc_failure_timeout =
6299 roam_req->reassoc_failure_timeout;
6300
6301 /* Fill the capabilities */
6302 roam_offload_params->capability =
6303 roam_req->roam_offload_params.capability;
6304 roam_offload_params->ht_caps_info =
6305 roam_req->roam_offload_params.ht_caps_info;
6306 roam_offload_params->ampdu_param =
6307 roam_req->roam_offload_params.ampdu_param;
6308 roam_offload_params->ht_ext_cap =
6309 roam_req->roam_offload_params.ht_ext_cap;
6310 roam_offload_params->ht_txbf =
6311 roam_req->roam_offload_params.ht_txbf;
6312 roam_offload_params->asel_cap =
6313 roam_req->roam_offload_params.asel_cap;
6314 roam_offload_params->qos_caps =
6315 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006316 roam_offload_params->qos_enabled =
6317 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306318 roam_offload_params->wmm_caps =
6319 roam_req->roam_offload_params.wmm_caps;
6320 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6321 (uint8_t *)roam_req->roam_offload_params.mcsset,
6322 ROAM_OFFLOAD_NUM_MCS_SET);
6323
6324 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6325 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6326 * they are filled in the same order.Depending on the
6327 * authentication type, the other mode TLV's are nullified
6328 * and only headers are filled.*/
6329 if ((auth_mode != WMI_AUTH_NONE) &&
6330 ((auth_mode != WMI_AUTH_OPEN) ||
6331 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306332 && roam_req->mdid.mdie_present &&
6333 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306334 roam_req->is_ese_assoc)) {
6335 if (roam_req->is_ese_assoc) {
6336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6337 WMITLV_GET_STRUCT_TLVLEN(0));
6338 buf_ptr += WMI_TLV_HDR_SIZE;
6339 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6340 WMITLV_GET_STRUCT_TLVLEN(0));
6341 buf_ptr += WMI_TLV_HDR_SIZE;
6342 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6343 sizeof(wmi_roam_ese_offload_tlv_param));
6344 buf_ptr += WMI_TLV_HDR_SIZE;
6345 roam_offload_ese =
6346 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6347 qdf_mem_copy(roam_offload_ese->krk,
6348 roam_req->krk,
6349 sizeof(roam_req->krk));
6350 qdf_mem_copy(roam_offload_ese->btk,
6351 roam_req->btk,
6352 sizeof(roam_req->btk));
6353 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6354 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6355 WMITLV_GET_STRUCT_TLVLEN
6356 (wmi_roam_ese_offload_tlv_param));
6357 buf_ptr +=
6358 sizeof(wmi_roam_ese_offload_tlv_param);
6359 } else if (auth_mode == WMI_AUTH_FT_RSNA
6360 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6361 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306362 && roam_req->mdid.mdie_present &&
6363 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6365 0);
6366 buf_ptr += WMI_TLV_HDR_SIZE;
6367 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6368 sizeof(wmi_roam_11r_offload_tlv_param));
6369 buf_ptr += WMI_TLV_HDR_SIZE;
6370 roam_offload_11r =
6371 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6372 roam_offload_11r->r0kh_id_len =
6373 roam_req->rokh_id_length;
6374 qdf_mem_copy(roam_offload_11r->r0kh_id,
6375 roam_req->rokh_id,
6376 roam_offload_11r->r0kh_id_len);
6377 qdf_mem_copy(roam_offload_11r->psk_msk,
6378 roam_req->psk_pmk,
6379 sizeof(roam_req->psk_pmk));
6380 roam_offload_11r->psk_msk_len =
6381 roam_req->pmk_len;
6382 roam_offload_11r->mdie_present =
6383 roam_req->mdid.mdie_present;
6384 roam_offload_11r->mdid =
6385 roam_req->mdid.mobility_domain;
6386 if (auth_mode == WMI_AUTH_OPEN) {
6387 /* If FT-Open ensure pmk length
6388 and r0khid len are zero */
6389 roam_offload_11r->r0kh_id_len = 0;
6390 roam_offload_11r->psk_msk_len = 0;
6391 }
6392 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6393 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6394 WMITLV_GET_STRUCT_TLVLEN
6395 (wmi_roam_11r_offload_tlv_param));
6396 buf_ptr +=
6397 sizeof(wmi_roam_11r_offload_tlv_param);
6398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6399 WMITLV_GET_STRUCT_TLVLEN(0));
6400 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006401 WMI_LOGD("psk_msk_len = %d",
6402 roam_offload_11r->psk_msk_len);
6403 if (roam_offload_11r->psk_msk_len)
6404 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6405 QDF_TRACE_LEVEL_DEBUG,
6406 roam_offload_11r->psk_msk,
6407 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306408 } else {
6409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6410 sizeof(wmi_roam_11i_offload_tlv_param));
6411 buf_ptr += WMI_TLV_HDR_SIZE;
6412 roam_offload_11i =
6413 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006414
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006415 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006416 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306417 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6418 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006419 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306420 } else {
6421 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6422 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006423 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006424 }
6425 if (roam_req->roam_key_mgmt_offload_enabled &&
6426 roam_req->fw_pmksa_cache) {
6427 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6428 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006429 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006430 } else {
6431 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6432 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006433 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306434 }
6435
6436 qdf_mem_copy(roam_offload_11i->pmk,
6437 roam_req->psk_pmk,
6438 sizeof(roam_req->psk_pmk));
6439 roam_offload_11i->pmk_len = roam_req->pmk_len;
6440 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6441 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6442 WMITLV_GET_STRUCT_TLVLEN
6443 (wmi_roam_11i_offload_tlv_param));
6444 buf_ptr +=
6445 sizeof(wmi_roam_11i_offload_tlv_param);
6446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6447 0);
6448 buf_ptr += WMI_TLV_HDR_SIZE;
6449 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6450 0);
6451 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006452 WMI_LOGD("pmk_len = %d",
6453 roam_offload_11i->pmk_len);
6454 if (roam_offload_11i->pmk_len)
6455 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6456 QDF_TRACE_LEVEL_DEBUG,
6457 roam_offload_11i->pmk,
6458 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306459 }
6460 } else {
6461 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6462 WMITLV_GET_STRUCT_TLVLEN(0));
6463 buf_ptr += WMI_TLV_HDR_SIZE;
6464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6465 WMITLV_GET_STRUCT_TLVLEN(0));
6466 buf_ptr += WMI_TLV_HDR_SIZE;
6467 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6468 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306469 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306470 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306471
6472 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6473 sizeof(*assoc_ies));
6474 buf_ptr += WMI_TLV_HDR_SIZE;
6475
6476 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6477 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6478 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6479 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6480 assoc_ies->buf_len = roam_req->assoc_ie_length;
6481
6482 buf_ptr += sizeof(*assoc_ies);
6483
6484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6485 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6486 buf_ptr += WMI_TLV_HDR_SIZE;
6487
6488 if (assoc_ies->buf_len != 0) {
6489 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6490 assoc_ies->buf_len);
6491 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306492 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6493 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6494 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306495 } else {
6496 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6497 WMITLV_GET_STRUCT_TLVLEN(0));
6498 buf_ptr += WMI_TLV_HDR_SIZE;
6499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6500 WMITLV_GET_STRUCT_TLVLEN(0));
6501 buf_ptr += WMI_TLV_HDR_SIZE;
6502 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6503 WMITLV_GET_STRUCT_TLVLEN(0));
6504 buf_ptr += WMI_TLV_HDR_SIZE;
6505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6506 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306507 buf_ptr += WMI_TLV_HDR_SIZE;
6508 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6509 WMITLV_GET_STRUCT_TLVLEN(0));
6510 buf_ptr += WMI_TLV_HDR_SIZE;
6511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6512 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306513 }
6514#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306515
6516send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306517 status = wmi_unified_cmd_send(wmi_handle, buf,
6518 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306519 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306520 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306521 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6522 status);
6523 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306524 }
6525
Govind Singh67922e82016-04-01 16:48:57 +05306526 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306527}
6528
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006529static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6530 struct wmi_mawc_roam_params *params)
6531{
6532 wmi_buf_t buf = NULL;
6533 QDF_STATUS status;
6534 int len;
6535 uint8_t *buf_ptr;
6536 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6537
6538 len = sizeof(*wmi_roam_mawc_params);
6539 buf = wmi_buf_alloc(wmi_handle, len);
6540 if (!buf) {
6541 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6542 return QDF_STATUS_E_NOMEM;
6543 }
6544
6545 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6546 wmi_roam_mawc_params =
6547 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6548 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6549 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6550 WMITLV_GET_STRUCT_TLVLEN
6551 (wmi_roam_configure_mawc_cmd_fixed_param));
6552 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6553 if (params->enable)
6554 wmi_roam_mawc_params->enable = 1;
6555 else
6556 wmi_roam_mawc_params->enable = 0;
6557 wmi_roam_mawc_params->traffic_load_threshold =
6558 params->traffic_load_threshold;
6559 wmi_roam_mawc_params->best_ap_rssi_threshold =
6560 params->best_ap_rssi_threshold;
6561 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6562 params->rssi_stationary_high_adjust;
6563 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6564 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006565 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6566 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6567 wmi_roam_mawc_params->traffic_load_threshold,
6568 wmi_roam_mawc_params->best_ap_rssi_threshold,
6569 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6570 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006571
6572 status = wmi_unified_cmd_send(wmi_handle, buf,
6573 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6574 if (QDF_IS_STATUS_ERROR(status)) {
6575 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6576 status);
6577 wmi_buf_free(buf);
6578 return status;
6579 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006580
6581 return QDF_STATUS_SUCCESS;
6582}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306583
6584/**
6585 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6586 * rssi threashold
6587 * @wmi_handle: wmi handle
6588 * @roam_req: Roaming request buffer
6589 *
6590 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6591 *
6592 * Return: QDF status
6593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306594static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306595 struct roam_offload_scan_rssi_params *roam_req)
6596{
6597 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306598 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306599 int len;
6600 uint8_t *buf_ptr;
6601 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6602 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6603 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306604 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006605 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306606
6607 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6608 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6609 len += sizeof(wmi_roam_scan_extended_threshold_param);
6610 len += WMI_TLV_HDR_SIZE;
6611 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306612 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6613 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006614 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6615 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306616 buf = wmi_buf_alloc(wmi_handle, len);
6617 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306618 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306619 return QDF_STATUS_E_NOMEM;
6620 }
6621
6622 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6623 rssi_threshold_fp =
6624 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6625 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6626 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6627 WMITLV_GET_STRUCT_TLVLEN
6628 (wmi_roam_scan_rssi_threshold_fixed_param));
6629 /* fill in threshold values */
6630 rssi_threshold_fp->vdev_id = roam_req->session_id;
6631 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6632 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6633 rssi_threshold_fp->hirssi_scan_max_count =
6634 roam_req->hi_rssi_scan_max_count;
6635 rssi_threshold_fp->hirssi_scan_delta =
6636 roam_req->hi_rssi_scan_rssi_delta;
6637 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006638 rssi_threshold_fp->rssi_thresh_offset_5g =
6639 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306640
6641 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6642 WMITLV_SET_HDR(buf_ptr,
6643 WMITLV_TAG_ARRAY_STRUC,
6644 sizeof(wmi_roam_scan_extended_threshold_param));
6645 buf_ptr += WMI_TLV_HDR_SIZE;
6646 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6647
6648 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6649 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6650 ext_thresholds->boost_threshold_5g =
6651 roam_req->boost_threshold_5g;
6652
6653 ext_thresholds->boost_algorithm_5g =
6654 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6655 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6656 ext_thresholds->penalty_algorithm_5g =
6657 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6658 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6659 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6660 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6661 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6662
6663 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6664 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6665 WMITLV_GET_STRUCT_TLVLEN
6666 (wmi_roam_scan_extended_threshold_param));
6667 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6668 WMITLV_SET_HDR(buf_ptr,
6669 WMITLV_TAG_ARRAY_STRUC,
6670 sizeof(wmi_roam_earlystop_rssi_thres_param));
6671 buf_ptr += WMI_TLV_HDR_SIZE;
6672 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6673 early_stop_thresholds->roam_earlystop_thres_min =
6674 roam_req->roam_earlystop_thres_min;
6675 early_stop_thresholds->roam_earlystop_thres_max =
6676 roam_req->roam_earlystop_thres_max;
6677 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6678 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6679 WMITLV_GET_STRUCT_TLVLEN
6680 (wmi_roam_earlystop_rssi_thres_param));
6681
Gupta, Kapil7e652922016-04-12 15:02:00 +05306682 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6683 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6684 sizeof(wmi_roam_dense_thres_param));
6685 buf_ptr += WMI_TLV_HDR_SIZE;
6686 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6687 dense_thresholds->roam_dense_rssi_thres_offset =
6688 roam_req->dense_rssi_thresh_offset;
6689 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6690 dense_thresholds->roam_dense_traffic_thres =
6691 roam_req->traffic_threshold;
6692 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6693 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6694 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6695 WMITLV_GET_STRUCT_TLVLEN
6696 (wmi_roam_dense_thres_param));
6697
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006698 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6700 sizeof(wmi_roam_bg_scan_roaming_param));
6701 buf_ptr += WMI_TLV_HDR_SIZE;
6702 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6703 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6704 roam_req->bg_scan_bad_rssi_thresh;
6705 bg_scan_params->roam_bg_scan_client_bitmap =
6706 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306707 bg_scan_params->bad_rssi_thresh_offset_2g =
6708 roam_req->roam_bad_rssi_thresh_offset_2g;
6709 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006710 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6711 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6712 WMITLV_GET_STRUCT_TLVLEN
6713 (wmi_roam_bg_scan_roaming_param));
6714
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306715 status = wmi_unified_cmd_send(wmi_handle, buf,
6716 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306717 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306718 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306719 status);
6720 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306721 }
6722
Govind Singh67922e82016-04-01 16:48:57 +05306723 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306724}
6725
6726/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306727 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6728 * configuration params
6729 * @wma_handle: wma handler
6730 * @dwelltime_params: pointer to dwelltime_params
6731 *
6732 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6733 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006734static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306735QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6736 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6737{
6738 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6739 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6740 wmi_buf_t buf;
6741 uint8_t *buf_ptr;
6742 int32_t err;
6743 int len;
6744
6745 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6746 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6747 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6748 buf = wmi_buf_alloc(wmi_handle, len);
6749 if (!buf) {
6750 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6751 __func__);
6752 return QDF_STATUS_E_NOMEM;
6753 }
6754 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6755 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6756 WMITLV_SET_HDR(&dwell_param->tlv_header,
6757 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6758 WMITLV_GET_STRUCT_TLVLEN
6759 (wmi_scan_adaptive_dwell_config_fixed_param));
6760
6761 dwell_param->enable = dwelltime_params->is_enabled;
6762 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6763 WMITLV_SET_HDR(buf_ptr,
6764 WMITLV_TAG_ARRAY_STRUC,
6765 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6766 buf_ptr += WMI_TLV_HDR_SIZE;
6767
6768 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6769 WMITLV_SET_HDR(&cmd->tlv_header,
6770 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6771 WMITLV_GET_STRUCT_TLVLEN(
6772 wmi_scan_adaptive_dwell_parameters_tlv));
6773
6774 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6775 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6776 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6777 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6778 err = wmi_unified_cmd_send(wmi_handle, buf,
6779 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6780 if (err) {
6781 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6782 wmi_buf_free(buf);
6783 return QDF_STATUS_E_FAILURE;
6784 }
6785
6786 return QDF_STATUS_SUCCESS;
6787}
6788
Nitesh Shah52323d02017-05-22 15:49:00 +05306789/**
6790 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6791 * configuration params
6792 * @wmi_handle: wmi handler
6793 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6794 *
6795 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6796 */
6797static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6798 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6799{
6800 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6801 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6802 wmi_buf_t buf;
6803 uint8_t *buf_ptr;
6804 QDF_STATUS err;
6805 uint32_t i;
6806 int len;
6807
6808 len = sizeof(*dbs_scan_param);
6809 len += WMI_TLV_HDR_SIZE;
6810 len += dbs_scan_params->num_clients * sizeof(*cmd);
6811
6812 buf = wmi_buf_alloc(wmi_handle, len);
6813 if (!buf) {
6814 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6815 return QDF_STATUS_E_NOMEM;
6816 }
6817
6818 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6819 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6820 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6821 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6822 WMITLV_GET_STRUCT_TLVLEN
6823 (wmi_scan_dbs_duty_cycle_fixed_param));
6824
6825 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6826 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6827 buf_ptr += sizeof(*dbs_scan_param);
6828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6829 (sizeof(*cmd) * dbs_scan_params->num_clients));
6830 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6831
6832 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6833 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6834 WMITLV_SET_HDR(&cmd->tlv_header,
6835 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6836 WMITLV_GET_STRUCT_TLVLEN(
6837 wmi_scan_dbs_duty_cycle_tlv_param));
6838 cmd->module_id = dbs_scan_params->module_id[i];
6839 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6840 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6841 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6842 }
6843
6844 err = wmi_unified_cmd_send(wmi_handle, buf,
6845 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6846 if (QDF_IS_STATUS_ERROR(err)) {
6847 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6848 wmi_buf_free(buf);
6849 return QDF_STATUS_E_FAILURE;
6850 }
6851
6852 return QDF_STATUS_SUCCESS;
6853}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306854
6855/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306856 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6857 * @wmi_handle: wmi handle
6858 * @roam_req: Request which contains the filters
6859 *
6860 * There are filters such as whitelist, blacklist and preferred
6861 * list that need to be applied to the scan results to form the
6862 * probable candidates for roaming.
6863 *
6864 * Return: Return success upon succesfully passing the
6865 * parameters to the firmware, otherwise failure.
6866 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306867static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306868 struct roam_scan_filter_params *roam_req)
6869{
6870 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306871 QDF_STATUS status;
6872 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306873 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306874 uint8_t *buf_ptr;
6875 wmi_roam_filter_fixed_param *roam_filter;
6876 uint8_t *bssid_src_ptr = NULL;
6877 wmi_mac_addr *bssid_dst_ptr = NULL;
6878 wmi_ssid *ssid_ptr = NULL;
6879 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306880 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306881 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306882
6883 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306884
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306885 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306886 if (roam_req->num_bssid_black_list)
6887 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6888 len += WMI_TLV_HDR_SIZE;
6889 if (roam_req->num_ssid_white_list)
6890 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6891 len += 2 * WMI_TLV_HDR_SIZE;
6892 if (roam_req->num_bssid_preferred_list) {
6893 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306894 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306895 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306896 len += WMI_TLV_HDR_SIZE;
6897 if (roam_req->lca_disallow_config_present) {
6898 len += sizeof(*blist_param);
6899 blist_len = sizeof(*blist_param);
6900 }
6901
6902 len += WMI_TLV_HDR_SIZE;
6903 if (roam_req->num_rssi_rejection_ap)
6904 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306905
6906 buf = wmi_buf_alloc(wmi_handle, len);
6907 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306908 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306909 return QDF_STATUS_E_NOMEM;
6910 }
6911
6912 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6913 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6914 WMITLV_SET_HDR(&roam_filter->tlv_header,
6915 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6916 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6917 /* fill in fixed values */
6918 roam_filter->vdev_id = roam_req->session_id;
6919 roam_filter->flags = 0;
6920 roam_filter->op_bitmap = roam_req->op_bitmap;
6921 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6922 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6923 roam_filter->num_bssid_preferred_list =
6924 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306925 roam_filter->num_rssi_rejection_ap =
6926 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306927 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6928
6929 WMITLV_SET_HDR((buf_ptr),
6930 WMITLV_TAG_ARRAY_FIXED_STRUC,
6931 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6932 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6933 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6934 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6935 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6936 bssid_src_ptr += ATH_MAC_LEN;
6937 bssid_dst_ptr++;
6938 }
6939 buf_ptr += WMI_TLV_HDR_SIZE +
6940 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6941 WMITLV_SET_HDR((buf_ptr),
6942 WMITLV_TAG_ARRAY_FIXED_STRUC,
6943 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6944 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6945 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6946 qdf_mem_copy(&ssid_ptr->ssid,
6947 &roam_req->ssid_allowed_list[i].mac_ssid,
6948 roam_req->ssid_allowed_list[i].length);
6949 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6950 ssid_ptr++;
6951 }
6952 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6953 sizeof(wmi_ssid));
6954 WMITLV_SET_HDR((buf_ptr),
6955 WMITLV_TAG_ARRAY_FIXED_STRUC,
6956 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6957 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6958 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6959 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6960 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6961 (wmi_mac_addr *)bssid_dst_ptr);
6962 bssid_src_ptr += ATH_MAC_LEN;
6963 bssid_dst_ptr++;
6964 }
6965 buf_ptr += WMI_TLV_HDR_SIZE +
6966 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6968 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6969 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6970 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6971 *bssid_preferred_factor_ptr =
6972 roam_req->bssid_favored_factor[i];
6973 bssid_preferred_factor_ptr++;
6974 }
6975 buf_ptr += WMI_TLV_HDR_SIZE +
6976 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6977
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306978 WMITLV_SET_HDR(buf_ptr,
6979 WMITLV_TAG_ARRAY_STRUC, blist_len);
6980 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306981 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306982 blist_param =
6983 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6984 WMITLV_SET_HDR(&blist_param->tlv_header,
6985 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6986 WMITLV_GET_STRUCT_TLVLEN(
6987 wmi_roam_lca_disallow_config_tlv_param));
6988
6989 blist_param->disallow_duration = roam_req->disallow_duration;
6990 blist_param->rssi_channel_penalization =
6991 roam_req->rssi_channel_penalization;
6992 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306993 blist_param->disallow_lca_enable_source_bitmap =
6994 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6995 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306996 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6997 }
6998
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306999 WMITLV_SET_HDR(buf_ptr,
7000 WMITLV_TAG_ARRAY_STRUC,
7001 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7002 buf_ptr += WMI_TLV_HDR_SIZE;
7003 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7004 rssi_rej =
7005 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7006 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7007 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7008 WMITLV_GET_STRUCT_TLVLEN(
7009 wmi_roam_rssi_rejection_oce_config_param));
7010 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7011 roam_req->rssi_rejection_ap[i].bssid.bytes,
7012 &rssi_rej->bssid);
7013 rssi_rej->remaining_disallow_duration =
7014 roam_req->rssi_rejection_ap[i].remaining_duration;
7015 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307016 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307017 buf_ptr +=
7018 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7019 }
7020
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307021 status = wmi_unified_cmd_send(wmi_handle, buf,
7022 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307023 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307024 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307025 status);
7026 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307027 }
Govind Singh67922e82016-04-01 16:48:57 +05307028
7029 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307030}
7031
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307032#if defined(WLAN_FEATURE_FILS_SK)
7033static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7034 struct hlp_params *params)
7035{
7036 uint32_t len;
7037 uint8_t *buf_ptr;
7038 wmi_buf_t buf = NULL;
7039 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7040
7041 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7042 len += WMI_TLV_HDR_SIZE;
7043 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7044
7045 buf = wmi_buf_alloc(wmi_handle, len);
7046 if (!buf) {
7047 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7048 return QDF_STATUS_E_NOMEM;
7049 }
7050
7051 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7052 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7053 WMITLV_SET_HDR(&hlp_params->tlv_header,
7054 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7055 WMITLV_GET_STRUCT_TLVLEN(
7056 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7057
7058 hlp_params->vdev_id = params->vdev_id;
7059 hlp_params->size = params->hlp_ie_len;
7060 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7061
7062 buf_ptr += sizeof(*hlp_params);
7063
7064 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7065 round_up(params->hlp_ie_len,
7066 sizeof(uint32_t)));
7067 buf_ptr += WMI_TLV_HDR_SIZE;
7068 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7069
7070 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7071 hlp_params->vdev_id, hlp_params->size);
7072 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7073 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7074 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7075 wmi_buf_free(buf);
7076 return QDF_STATUS_E_FAILURE;
7077 }
7078
7079 return QDF_STATUS_SUCCESS;
7080}
7081#endif
7082
Govind Singh4eacd2b2016-03-07 14:24:22 +05307083/** send_set_epno_network_list_cmd_tlv() - set epno network list
7084 * @wmi_handle: wmi handle
7085 * @req: epno config params request structure
7086 *
7087 * This function reads the incoming epno config request structure
7088 * and constructs the WMI message to the firmware.
7089 *
7090 * Returns: 0 on success, error number otherwise
7091 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307092static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307093 struct wifi_enhanched_pno_params *req)
7094{
7095 wmi_nlo_config_cmd_fixed_param *cmd;
7096 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307097 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307098 u_int8_t i, *buf_ptr;
7099 wmi_buf_t buf;
7100 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307101 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307102
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307103 /* Fixed Params */
7104 len = sizeof(*cmd);
7105 if (req->num_networks) {
7106 /* TLV place holder for array of structures
7107 * then each nlo_configured_parameters(nlo_list) TLV.
7108 */
7109 len += WMI_TLV_HDR_SIZE;
7110 len += (sizeof(nlo_configured_parameters)
7111 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7112 /* TLV for array of uint32 channel_list */
7113 len += WMI_TLV_HDR_SIZE;
7114 /* TLV for nlo_channel_prediction_cfg */
7115 len += WMI_TLV_HDR_SIZE;
7116 /* TLV for candidate score params */
7117 len += sizeof(enlo_candidate_score_params);
7118 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119
7120 buf = wmi_buf_alloc(wmi_handle, len);
7121 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307122 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7123 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307124 }
7125
7126 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7127
7128 buf_ptr = (u_int8_t *) cmd;
7129 WMITLV_SET_HDR(&cmd->tlv_header,
7130 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7131 WMITLV_GET_STRUCT_TLVLEN(
7132 wmi_nlo_config_cmd_fixed_param));
7133 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307134
7135 /* set flag to reset if num of networks are 0 */
7136 cmd->flags = (req->num_networks == 0 ?
7137 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307138
7139 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7140
Govind Singhb53420c2016-03-09 14:32:57 +05307141 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307142 WMI_LOGD("SSID count: %d flags: %d",
7143 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307144
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307145 /* Fill nlo_config only when num_networks are non zero */
7146 if (cmd->no_of_ssids) {
7147 /* Fill networks */
7148 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7149 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7150 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307151
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307152 nlo_list = (nlo_configured_parameters *) buf_ptr;
7153 for (i = 0; i < cmd->no_of_ssids; i++) {
7154 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7155 WMITLV_TAG_ARRAY_BYTE,
7156 WMITLV_GET_STRUCT_TLVLEN(
7157 nlo_configured_parameters));
7158 /* Copy ssid and it's length */
7159 nlo_list[i].ssid.valid = true;
7160 nlo_list[i].ssid.ssid.ssid_len =
7161 req->networks[i].ssid.length;
7162 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7163 req->networks[i].ssid.mac_ssid,
7164 nlo_list[i].ssid.ssid.ssid_len);
7165 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7166 nlo_list[i].ssid.ssid.ssid_len,
7167 (char *) nlo_list[i].ssid.ssid.ssid,
7168 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307169
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307170 /* Copy pno flags */
7171 nlo_list[i].bcast_nw_type.valid = true;
7172 nlo_list[i].bcast_nw_type.bcast_nw_type =
7173 req->networks[i].flags;
7174 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307175 nlo_list[i].bcast_nw_type.bcast_nw_type);
7176
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307177 /* Copy auth bit field */
7178 nlo_list[i].auth_type.valid = true;
7179 nlo_list[i].auth_type.auth_type =
7180 req->networks[i].auth_bit_field;
7181 WMI_LOGD("Auth bit field (%u)",
7182 nlo_list[i].auth_type.auth_type);
7183 }
7184
7185 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7186 /* Fill the channel list */
7187 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7188 buf_ptr += WMI_TLV_HDR_SIZE;
7189
7190 /* Fill prediction_param */
7191 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7192 buf_ptr += WMI_TLV_HDR_SIZE;
7193
7194 /* Fill epno candidate score params */
7195 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7196 WMITLV_SET_HDR(buf_ptr,
7197 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7198 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7199 cand_score_params->min5GHz_rssi =
7200 req->min_5ghz_rssi;
7201 cand_score_params->min24GHz_rssi =
7202 req->min_24ghz_rssi;
7203 cand_score_params->initial_score_max =
7204 req->initial_score_max;
7205 cand_score_params->current_connection_bonus =
7206 req->current_connection_bonus;
7207 cand_score_params->same_network_bonus =
7208 req->same_network_bonus;
7209 cand_score_params->secure_bonus =
7210 req->secure_bonus;
7211 cand_score_params->band5GHz_bonus =
7212 req->band_5ghz_bonus;
7213 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307214 }
7215
Govind Singh4eacd2b2016-03-07 14:24:22 +05307216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307217 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307218 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307219 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307221 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307222 }
7223
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307225 req->session_id);
7226
Govind Singh67922e82016-04-01 16:48:57 +05307227 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307228}
7229
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307230#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307231/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7232 * @wmi_handle: wmi handle
7233 * @ipa_offload: ipa offload control parameter
7234 *
7235 * Returns: 0 on success, error number otherwise
7236 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307237static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307238 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307239{
7240 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7241 wmi_buf_t wmi_buf;
7242 uint32_t len;
7243 u_int8_t *buf_ptr;
7244
7245 len = sizeof(*cmd);
7246 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7247 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307248 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7249 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307250 }
7251
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007252 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307253 ipa_offload->offload_type, ipa_offload->enable);
7254
7255 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7256
7257 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7258 WMITLV_SET_HDR(&cmd->tlv_header,
7259 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7260 WMITLV_GET_STRUCT_TLVLEN(
7261 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7262
7263 cmd->offload_type = ipa_offload->offload_type;
7264 cmd->vdev_id = ipa_offload->vdev_id;
7265 cmd->enable = ipa_offload->enable;
7266
7267 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7268 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307269 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307271 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307272 }
7273
Govind Singhb53420c2016-03-09 14:32:57 +05307274 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307275}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307276#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307277
7278/**
7279 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7280 * @wmi_handle: wmi handle
7281 * @pgetcapab: get capabilities params
7282 *
7283 * This function send request to fw to get extscan capabilities.
7284 *
7285 * Return: CDF status
7286 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307287static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307288 struct extscan_capabilities_params *pgetcapab)
7289{
7290 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7291 wmi_buf_t wmi_buf;
7292 uint32_t len;
7293 uint8_t *buf_ptr;
7294
7295 len = sizeof(*cmd);
7296 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7297 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307298 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7299 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307300 }
7301 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7302
7303 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7304 WMITLV_SET_HDR(&cmd->tlv_header,
7305 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7306 WMITLV_GET_STRUCT_TLVLEN
7307 (wmi_extscan_get_capabilities_cmd_fixed_param));
7308
7309 cmd->request_id = pgetcapab->request_id;
7310
7311 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7312 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307313 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307314 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307315 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307316 }
Govind Singhb53420c2016-03-09 14:32:57 +05307317 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307318}
7319
7320/**
7321 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7322 * @wmi_handle: wmi handle
7323 * @pcached_results: cached results parameters
7324 *
7325 * This function send request to fw to get cached results.
7326 *
7327 * Return: CDF status
7328 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307329static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307330 struct extscan_cached_result_params *pcached_results)
7331{
7332 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7333 wmi_buf_t wmi_buf;
7334 uint32_t len;
7335 uint8_t *buf_ptr;
7336
7337 len = sizeof(*cmd);
7338 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7339 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307340 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7341 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307342 }
7343 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7344
7345 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7346 WMITLV_SET_HDR(&cmd->tlv_header,
7347 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7348 WMITLV_GET_STRUCT_TLVLEN
7349 (wmi_extscan_get_cached_results_cmd_fixed_param));
7350
7351 cmd->request_id = pcached_results->request_id;
7352 cmd->vdev_id = pcached_results->session_id;
7353 cmd->control_flags = pcached_results->flush;
7354
7355 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7356 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307357 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307358 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307359 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307360 }
Govind Singhb53420c2016-03-09 14:32:57 +05307361 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307362}
7363
7364/**
7365 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7366 * @wmi_handle: wmi handle
7367 * @reset_req: Reset change request params
7368 *
7369 * This function sends stop change monitor request to fw.
7370 *
7371 * Return: CDF status
7372 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307373static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307374 struct extscan_capabilities_reset_params *reset_req)
7375{
7376 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7377 wmi_buf_t wmi_buf;
7378 uint32_t len;
7379 uint8_t *buf_ptr;
7380 int change_list = 0;
7381
7382 len = sizeof(*cmd);
7383
7384 /* reset significant change tlv is set to 0 */
7385 len += WMI_TLV_HDR_SIZE;
7386 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7387 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7388 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307389 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7390 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307391 }
7392 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7393
7394 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7395 buf_ptr;
7396 WMITLV_SET_HDR(&cmd->tlv_header,
7397 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7398 WMITLV_GET_STRUCT_TLVLEN
7399 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7400
7401 cmd->request_id = reset_req->request_id;
7402 cmd->vdev_id = reset_req->session_id;
7403 cmd->mode = 0;
7404
7405 buf_ptr += sizeof(*cmd);
7406 WMITLV_SET_HDR(buf_ptr,
7407 WMITLV_TAG_ARRAY_STRUC,
7408 change_list *
7409 sizeof(wmi_extscan_wlan_change_bssid_param));
7410 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7411 sizeof
7412 (wmi_extscan_wlan_change_bssid_param));
7413
7414 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7415 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307416 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307417 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307418 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307419 }
Govind Singhb53420c2016-03-09 14:32:57 +05307420 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307421}
7422
7423/**
7424 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7425 * @wmi_handle: wmi handle
7426 * @psigchange: change monitor request params
7427 * @buf: wmi buffer
7428 * @buf_len: buffer length
7429 *
7430 * This function fills elements of change monitor request buffer.
7431 *
7432 * Return: CDF status
7433 */
Govind Singhb53420c2016-03-09 14:32:57 +05307434static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307435 struct extscan_set_sig_changereq_params
7436 *psigchange, wmi_buf_t *buf, int *buf_len)
7437{
7438 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7439 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7440 uint8_t *buf_ptr;
7441 int j;
7442 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007443 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307444 struct ap_threshold_params *src_ap = psigchange->ap;
7445
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007446 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307447 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7448 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307449 }
7450 len += WMI_TLV_HDR_SIZE;
7451 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7452
7453 *buf = wmi_buf_alloc(wmi_handle, len);
7454 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307455 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307457 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307458 }
7459 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7460 cmd =
7461 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7462 buf_ptr;
7463 WMITLV_SET_HDR(&cmd->tlv_header,
7464 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7465 WMITLV_GET_STRUCT_TLVLEN
7466 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7467
7468 cmd->request_id = psigchange->request_id;
7469 cmd->vdev_id = psigchange->session_id;
7470 cmd->total_entries = numap;
7471 cmd->mode = 1;
7472 cmd->num_entries_in_page = numap;
7473 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7474 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7475 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7476 cmd->max_out_of_range_count = psigchange->min_breaching;
7477
7478 buf_ptr += sizeof(*cmd);
7479 WMITLV_SET_HDR(buf_ptr,
7480 WMITLV_TAG_ARRAY_STRUC,
7481 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7482 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7483 (buf_ptr + WMI_TLV_HDR_SIZE);
7484
7485 for (j = 0; j < numap; j++) {
7486 WMITLV_SET_HDR(dest_chglist,
7487 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7488 WMITLV_GET_STRUCT_TLVLEN
7489 (wmi_extscan_wlan_change_bssid_param));
7490
7491 dest_chglist->lower_rssi_limit = src_ap->low;
7492 dest_chglist->upper_rssi_limit = src_ap->high;
7493 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7494 &dest_chglist->bssid);
7495
Govind Singhb53420c2016-03-09 14:32:57 +05307496 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307497 dest_chglist->lower_rssi_limit);
7498 dest_chglist++;
7499 src_ap++;
7500 }
7501 buf_ptr += WMI_TLV_HDR_SIZE +
7502 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7503 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307504 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307505}
7506
7507/**
7508 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7509 * @wmi_handle: wmi handle
7510 * @psigchange: change monitor request params
7511 *
7512 * This function sends start change monitor request to fw.
7513 *
7514 * Return: CDF status
7515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307516static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307517 struct extscan_set_sig_changereq_params *
7518 psigchange)
7519{
Govind Singhb53420c2016-03-09 14:32:57 +05307520 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307521 wmi_buf_t buf;
7522 int len;
7523
7524
Govind Singhb53420c2016-03-09 14:32:57 +05307525 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307526 psigchange, &buf,
7527 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307528 if (qdf_status != QDF_STATUS_SUCCESS) {
7529 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307530 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307531 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307532 }
7533 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307534 WMI_LOGE("%s: Failed to get buffer", __func__);
7535 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307536 }
7537 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7538 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307539 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307540 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307541 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307542 }
Govind Singhb53420c2016-03-09 14:32:57 +05307543 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307544}
7545
7546/**
7547 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7548 * @wmi_handle: wmi handle
7549 * @photlist_reset: hotlist reset params
7550 *
7551 * This function configures hotlist monitor to stop in fw.
7552 *
7553 * Return: CDF status
7554 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307555static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307556 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7557{
7558 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7559 wmi_buf_t wmi_buf;
7560 uint32_t len;
7561 uint8_t *buf_ptr;
7562 int hotlist_entries = 0;
7563
7564 len = sizeof(*cmd);
7565
7566 /* reset bssid hotlist with tlv set to 0 */
7567 len += WMI_TLV_HDR_SIZE;
7568 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7569
7570 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7571 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307572 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7573 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307574 }
7575
7576 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7577 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7578 buf_ptr;
7579 WMITLV_SET_HDR(&cmd->tlv_header,
7580 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7581 WMITLV_GET_STRUCT_TLVLEN
7582 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7583
7584 cmd->request_id = photlist_reset->request_id;
7585 cmd->vdev_id = photlist_reset->session_id;
7586 cmd->mode = 0;
7587
7588 buf_ptr += sizeof(*cmd);
7589 WMITLV_SET_HDR(buf_ptr,
7590 WMITLV_TAG_ARRAY_STRUC,
7591 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7592 buf_ptr += WMI_TLV_HDR_SIZE +
7593 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7594
7595 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7596 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307597 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307598 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307599 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307600 }
Govind Singhb53420c2016-03-09 14:32:57 +05307601 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307602}
7603
7604/**
7605 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7606 * @wmi_handle: wmi handle
7607 * @pstopcmd: stop scan command request params
7608 *
7609 * This function sends stop extscan request to fw.
7610 *
7611 * Return: CDF Status.
7612 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307613static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307614 struct extscan_stop_req_params *pstopcmd)
7615{
7616 wmi_extscan_stop_cmd_fixed_param *cmd;
7617 wmi_buf_t wmi_buf;
7618 uint32_t len;
7619 uint8_t *buf_ptr;
7620
7621 len = sizeof(*cmd);
7622 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7623 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307624 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7625 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307626 }
7627 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7628 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7629 WMITLV_SET_HDR(&cmd->tlv_header,
7630 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7631 WMITLV_GET_STRUCT_TLVLEN
7632 (wmi_extscan_stop_cmd_fixed_param));
7633
7634 cmd->request_id = pstopcmd->request_id;
7635 cmd->vdev_id = pstopcmd->session_id;
7636
7637 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7638 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307639 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307640 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307641 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642 }
7643
Govind Singhb53420c2016-03-09 14:32:57 +05307644 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307645}
7646
7647/**
7648 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7649 * @wmi_handle: wmi handle
7650 * @pstart: scan command request params
7651 * @buf: event buffer
7652 * @buf_len: length of buffer
7653 *
7654 * This function fills individual elements of extscan request and
7655 * TLV for buckets, channel list.
7656 *
7657 * Return: CDF Status.
7658 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007659static
Govind Singhb53420c2016-03-09 14:32:57 +05307660QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307661 struct wifi_scan_cmd_req_params *pstart,
7662 wmi_buf_t *buf, int *buf_len)
7663{
7664 wmi_extscan_start_cmd_fixed_param *cmd;
7665 wmi_extscan_bucket *dest_blist;
7666 wmi_extscan_bucket_channel *dest_clist;
7667 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7668 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7669 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7670
7671 uint8_t *buf_ptr;
7672 int i, k, count = 0;
7673 int len = sizeof(*cmd);
7674 int nbuckets = pstart->numBuckets;
7675 int nchannels = 0;
7676
7677 /* These TLV's are are NULL by default */
7678 uint32_t ie_len_with_pad = 0;
7679 int num_ssid = 0;
7680 int num_bssid = 0;
7681 int ie_len = 0;
7682
7683 uint32_t base_period = pstart->basePeriod;
7684
7685 /* TLV placeholder for ssid_list (NULL) */
7686 len += WMI_TLV_HDR_SIZE;
7687 len += num_ssid * sizeof(wmi_ssid);
7688
7689 /* TLV placeholder for bssid_list (NULL) */
7690 len += WMI_TLV_HDR_SIZE;
7691 len += num_bssid * sizeof(wmi_mac_addr);
7692
7693 /* TLV placeholder for ie_data (NULL) */
7694 len += WMI_TLV_HDR_SIZE;
7695 len += ie_len * sizeof(uint32_t);
7696
7697 /* TLV placeholder for bucket */
7698 len += WMI_TLV_HDR_SIZE;
7699 len += nbuckets * sizeof(wmi_extscan_bucket);
7700
7701 /* TLV channel placeholder */
7702 len += WMI_TLV_HDR_SIZE;
7703 for (i = 0; i < nbuckets; i++) {
7704 nchannels += src_bucket->numChannels;
7705 src_bucket++;
7706 }
7707
Govind Singhb53420c2016-03-09 14:32:57 +05307708 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307709 __func__, nbuckets, nchannels);
7710 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7711 /* Allocate the memory */
7712 *buf = wmi_buf_alloc(wmi_handle, len);
7713 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307714 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307715 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307716 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307717 }
7718 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7719 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7720 WMITLV_SET_HDR(&cmd->tlv_header,
7721 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7722 WMITLV_GET_STRUCT_TLVLEN
7723 (wmi_extscan_start_cmd_fixed_param));
7724
7725 cmd->request_id = pstart->requestId;
7726 cmd->vdev_id = pstart->sessionId;
7727 cmd->base_period = pstart->basePeriod;
7728 cmd->num_buckets = nbuckets;
7729 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307730 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307731 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307732 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307733 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307734#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307735 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7736 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307737 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7738 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7739#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307740 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7741
7742 /* The max dwell time is retrieved from the first channel
7743 * of the first bucket and kept common for all channels.
7744 */
7745 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7746 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7747 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7748 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7749 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7750 cmd->max_table_usage = pstart->report_threshold_percent;
7751 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7752
7753 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307754 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307755 cmd->probe_delay = 0;
7756 cmd->probe_spacing_time = 0;
7757 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307758 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7759 WMI_SCAN_ADD_CCK_RATES |
7760 WMI_SCAN_ADD_OFDM_RATES |
7761 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7762 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307763 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7764 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307765 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307766 cmd->num_ssids = 0;
7767 cmd->num_bssid = 0;
7768 cmd->ie_len = 0;
7769 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7770 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7771
7772 buf_ptr += sizeof(*cmd);
7773 WMITLV_SET_HDR(buf_ptr,
7774 WMITLV_TAG_ARRAY_FIXED_STRUC,
7775 num_ssid * sizeof(wmi_ssid));
7776 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7777
7778 WMITLV_SET_HDR(buf_ptr,
7779 WMITLV_TAG_ARRAY_FIXED_STRUC,
7780 num_bssid * sizeof(wmi_mac_addr));
7781 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7782
7783 ie_len_with_pad = 0;
7784 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7785 ie_len_with_pad);
7786 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7787
7788 WMITLV_SET_HDR(buf_ptr,
7789 WMITLV_TAG_ARRAY_STRUC,
7790 nbuckets * sizeof(wmi_extscan_bucket));
7791 dest_blist = (wmi_extscan_bucket *)
7792 (buf_ptr + WMI_TLV_HDR_SIZE);
7793 src_bucket = pstart->buckets;
7794
7795 /* Retrieve scanning information from each bucket and
7796 * channels and send it to the target
7797 */
7798 for (i = 0; i < nbuckets; i++) {
7799 WMITLV_SET_HDR(dest_blist,
7800 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7801 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7802
7803 dest_blist->bucket_id = src_bucket->bucket;
7804 dest_blist->base_period_multiplier =
7805 src_bucket->period / base_period;
7806 dest_blist->min_period = src_bucket->period;
7807 dest_blist->max_period = src_bucket->max_period;
7808 dest_blist->exp_backoff = src_bucket->exponent;
7809 dest_blist->exp_max_step_count = src_bucket->step_count;
7810 dest_blist->channel_band = src_bucket->band;
7811 dest_blist->num_channels = src_bucket->numChannels;
7812 dest_blist->notify_extscan_events = 0;
7813
7814 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7815 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007816 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7817 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307818
7819 if (src_bucket->reportEvents &
7820 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7821 dest_blist->forwarding_flags =
7822 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7823 dest_blist->notify_extscan_events |=
7824 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7825 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7826 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7827 } else {
7828 dest_blist->forwarding_flags =
7829 WMI_EXTSCAN_NO_FORWARDING;
7830 }
7831
7832 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7833 dest_blist->configuration_flags = 0;
7834 else
7835 dest_blist->configuration_flags =
7836 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7837
Govind Singhb53420c2016-03-09 14:32:57 +05307838 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839 __func__, dest_blist->notify_extscan_events,
7840 dest_blist->configuration_flags,
7841 dest_blist->forwarding_flags);
7842
7843 dest_blist->min_dwell_time_active =
7844 src_bucket->min_dwell_time_active;
7845 dest_blist->max_dwell_time_active =
7846 src_bucket->max_dwell_time_active;
7847 dest_blist->min_dwell_time_passive =
7848 src_bucket->min_dwell_time_passive;
7849 dest_blist->max_dwell_time_passive =
7850 src_bucket->max_dwell_time_passive;
7851 src_channel = src_bucket->channels;
7852
7853 /* save the channel info to later populate
7854 * the channel TLV
7855 */
7856 for (k = 0; k < src_bucket->numChannels; k++) {
7857 save_channel[count++].channel = src_channel->channel;
7858 src_channel++;
7859 }
7860 dest_blist++;
7861 src_bucket++;
7862 }
7863 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7864 WMITLV_SET_HDR(buf_ptr,
7865 WMITLV_TAG_ARRAY_STRUC,
7866 nchannels * sizeof(wmi_extscan_bucket_channel));
7867 dest_clist = (wmi_extscan_bucket_channel *)
7868 (buf_ptr + WMI_TLV_HDR_SIZE);
7869
7870 /* Active or passive scan is based on the bucket dwell time
7871 * and channel specific active,passive scans are not
7872 * supported yet
7873 */
7874 for (i = 0; i < nchannels; i++) {
7875 WMITLV_SET_HDR(dest_clist,
7876 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7877 WMITLV_GET_STRUCT_TLVLEN
7878 (wmi_extscan_bucket_channel));
7879 dest_clist->channel = save_channel[i].channel;
7880 dest_clist++;
7881 }
7882 buf_ptr += WMI_TLV_HDR_SIZE +
7883 (nchannels * sizeof(wmi_extscan_bucket_channel));
7884 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307885 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307886}
7887
7888/**
7889 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7890 * @wmi_handle: wmi handle
7891 * @pstart: scan command request params
7892 *
7893 * This function sends start extscan request to fw.
7894 *
7895 * Return: CDF Status.
7896 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307897static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307898 struct wifi_scan_cmd_req_params *pstart)
7899{
Govind Singhb53420c2016-03-09 14:32:57 +05307900 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307901 wmi_buf_t buf;
7902 int len;
7903
7904 /* Fill individual elements of extscan request and
7905 * TLV for buckets, channel list.
7906 */
Govind Singhb53420c2016-03-09 14:32:57 +05307907 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307908 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307909 if (qdf_status != QDF_STATUS_SUCCESS) {
7910 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7911 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307912 }
7913 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307914 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307915 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307916 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307917 }
7918 if (wmi_unified_cmd_send(wmi_handle, buf,
7919 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307920 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307921 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307922 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307923 }
7924
Govind Singhb53420c2016-03-09 14:32:57 +05307925 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307926}
7927
7928/**
7929 * send_plm_stop_cmd_tlv() - plm stop request
7930 * @wmi_handle: wmi handle
7931 * @plm: plm request parameters
7932 *
7933 * This function request FW to stop PLM.
7934 *
7935 * Return: CDF status
7936 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307937static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307938 const struct plm_req_params *plm)
7939{
7940 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7941 int32_t len;
7942 wmi_buf_t buf;
7943 uint8_t *buf_ptr;
7944 int ret;
7945
7946 len = sizeof(*cmd);
7947 buf = wmi_buf_alloc(wmi_handle, len);
7948 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307949 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7950 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307951 }
7952
7953 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7954
7955 buf_ptr = (uint8_t *) cmd;
7956
7957 WMITLV_SET_HDR(&cmd->tlv_header,
7958 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7959 WMITLV_GET_STRUCT_TLVLEN
7960 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7961
7962 cmd->vdev_id = plm->session_id;
7963
7964 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307965 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307966
7967 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7968 WMI_VDEV_PLMREQ_STOP_CMDID);
7969 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307970 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307971 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307972 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307973 }
7974
Govind Singhb53420c2016-03-09 14:32:57 +05307975 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307976}
7977
7978/**
7979 * send_plm_start_cmd_tlv() - plm start request
7980 * @wmi_handle: wmi handle
7981 * @plm: plm request parameters
7982 *
7983 * This function request FW to start PLM.
7984 *
7985 * Return: CDF status
7986 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307987static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307988 const struct plm_req_params *plm,
7989 uint32_t *gchannel_list)
7990{
7991 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7992 uint32_t *channel_list;
7993 int32_t len;
7994 wmi_buf_t buf;
7995 uint8_t *buf_ptr;
7996 uint8_t count;
7997 int ret;
7998
7999 /* TLV place holder for channel_list */
8000 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
8001 len += sizeof(uint32_t) * plm->plm_num_ch;
8002
8003 buf = wmi_buf_alloc(wmi_handle, len);
8004 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308005 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8006 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308007 }
8008 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8009
8010 buf_ptr = (uint8_t *) cmd;
8011
8012 WMITLV_SET_HDR(&cmd->tlv_header,
8013 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8014 WMITLV_GET_STRUCT_TLVLEN
8015 (wmi_vdev_plmreq_start_cmd_fixed_param));
8016
8017 cmd->vdev_id = plm->session_id;
8018
8019 cmd->meas_token = plm->meas_token;
8020 cmd->dialog_token = plm->diag_token;
8021 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308022 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308023 cmd->off_duration = plm->meas_duration;
8024 cmd->burst_cycle = plm->burst_len;
8025 cmd->tx_power = plm->desired_tx_pwr;
8026 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8027 cmd->num_chans = plm->plm_num_ch;
8028
8029 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8030
Govind Singhb53420c2016-03-09 14:32:57 +05308031 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8032 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8033 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8034 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8035 WMI_LOGD("off_duration: %d", cmd->off_duration);
8036 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8037 WMI_LOGD("tx_power: %d", cmd->tx_power);
8038 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308039
8040 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8041 (cmd->num_chans * sizeof(uint32_t)));
8042
8043 buf_ptr += WMI_TLV_HDR_SIZE;
8044 if (cmd->num_chans) {
8045 channel_list = (uint32_t *) buf_ptr;
8046 for (count = 0; count < cmd->num_chans; count++) {
8047 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308048 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308049 channel_list[count] =
8050 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308051 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308052 }
8053 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8054 }
8055
8056 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8057 WMI_VDEV_PLMREQ_START_CMDID);
8058 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308059 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308060 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308061 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308062 }
8063
Govind Singhb53420c2016-03-09 14:32:57 +05308064 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308065}
8066
8067/**
8068 * send_pno_stop_cmd_tlv() - PNO stop request
8069 * @wmi_handle: wmi handle
8070 * @vdev_id: vdev id
8071 *
8072 * This function request FW to stop ongoing PNO operation.
8073 *
8074 * Return: CDF status
8075 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308076static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308077{
8078 wmi_nlo_config_cmd_fixed_param *cmd;
8079 int32_t len = sizeof(*cmd);
8080 wmi_buf_t buf;
8081 uint8_t *buf_ptr;
8082 int ret;
8083
8084 /*
8085 * TLV place holder for array of structures nlo_configured_parameters
8086 * TLV place holder for array of uint32_t channel_list
8087 * TLV place holder for chnl prediction cfg
8088 */
8089 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8090 buf = wmi_buf_alloc(wmi_handle, len);
8091 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308092 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8093 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308094 }
8095
8096 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8097 buf_ptr = (uint8_t *) cmd;
8098
8099 WMITLV_SET_HDR(&cmd->tlv_header,
8100 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8101 WMITLV_GET_STRUCT_TLVLEN
8102 (wmi_nlo_config_cmd_fixed_param));
8103
8104 cmd->vdev_id = vdev_id;
8105 cmd->flags = WMI_NLO_CONFIG_STOP;
8106 buf_ptr += sizeof(*cmd);
8107
8108 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8109 buf_ptr += WMI_TLV_HDR_SIZE;
8110
8111 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8112 buf_ptr += WMI_TLV_HDR_SIZE;
8113
8114 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8115 buf_ptr += WMI_TLV_HDR_SIZE;
8116
8117
8118 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8119 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8120 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308121 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308122 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308123 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308124 }
8125
Govind Singhb53420c2016-03-09 14:32:57 +05308126 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308127}
8128
8129/**
Govind Singhccb0c272016-04-01 16:30:08 +05308130 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8131 * @buf_ptr: Buffer passed by upper layers
8132 * @pno: Buffer to be sent to the firmware
8133 *
8134 * Copy the PNO Channel prediction configuration parameters
8135 * passed by the upper layers to a WMI format TLV and send it
8136 * down to the firmware.
8137 *
8138 * Return: None
8139 */
8140static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8141 struct pno_scan_req_params *pno)
8142{
8143 nlo_channel_prediction_cfg *channel_prediction_cfg =
8144 (nlo_channel_prediction_cfg *) buf_ptr;
8145 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8146 WMITLV_TAG_ARRAY_BYTE,
8147 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308148#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308149 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8150 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8151 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8152 channel_prediction_cfg->full_scan_period_ms =
8153 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308154#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308155 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8156 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8157 channel_prediction_cfg->enable,
8158 channel_prediction_cfg->top_k_num,
8159 channel_prediction_cfg->stationary_threshold,
8160 channel_prediction_cfg->full_scan_period_ms);
8161}
8162
8163/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008164 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8165 * @wmi_handle: wmi handle
8166 * @params: configuration parameters
8167 *
8168 * Return: QDF_STATUS
8169 */
8170static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8171 struct nlo_mawc_params *params)
8172{
8173 wmi_buf_t buf = NULL;
8174 QDF_STATUS status;
8175 int len;
8176 uint8_t *buf_ptr;
8177 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8178
8179 len = sizeof(*wmi_nlo_mawc_params);
8180 buf = wmi_buf_alloc(wmi_handle, len);
8181 if (!buf) {
8182 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8183 return QDF_STATUS_E_NOMEM;
8184 }
8185
8186 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8187 wmi_nlo_mawc_params =
8188 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8189 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8190 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8191 WMITLV_GET_STRUCT_TLVLEN
8192 (wmi_nlo_configure_mawc_cmd_fixed_param));
8193 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8194 if (params->enable)
8195 wmi_nlo_mawc_params->enable = 1;
8196 else
8197 wmi_nlo_mawc_params->enable = 0;
8198 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8199 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8200 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008201 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8202 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8203 wmi_nlo_mawc_params->exp_backoff_ratio,
8204 wmi_nlo_mawc_params->init_scan_interval,
8205 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008206
8207 status = wmi_unified_cmd_send(wmi_handle, buf,
8208 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8209 if (QDF_IS_STATUS_ERROR(status)) {
8210 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8211 status);
8212 wmi_buf_free(buf);
8213 return QDF_STATUS_E_FAILURE;
8214 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008215
8216 return QDF_STATUS_SUCCESS;
8217}
8218
8219/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308220 * send_pno_start_cmd_tlv() - PNO start request
8221 * @wmi_handle: wmi handle
8222 * @pno: PNO request
8223 *
8224 * This function request FW to start PNO request.
8225 * Request: CDF status
8226 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308227static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308228 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308229{
8230 wmi_nlo_config_cmd_fixed_param *cmd;
8231 nlo_configured_parameters *nlo_list;
8232 uint32_t *channel_list;
8233 int32_t len;
8234 wmi_buf_t buf;
8235 uint8_t *buf_ptr;
8236 uint8_t i;
8237 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308238 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308239 connected_nlo_rssi_params *nlo_relative_rssi;
8240 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308241
8242 /*
8243 * TLV place holder for array nlo_configured_parameters(nlo_list)
8244 * TLV place holder for array of uint32_t channel_list
8245 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308246 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308247 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308248 */
8249 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308250 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308251 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308252
Abhishek Singh5987b632017-03-03 22:09:07 +05308253 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308254 WMI_NLO_MAX_CHAN);
8255 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308256 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308257 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308258 len += sizeof(enlo_candidate_score_params);
8259 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308260 len += sizeof(connected_nlo_rssi_params);
8261 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308262
8263 buf = wmi_buf_alloc(wmi_handle, len);
8264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308265 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8266 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308267 }
8268
8269 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8270
8271 buf_ptr = (uint8_t *) cmd;
8272 WMITLV_SET_HDR(&cmd->tlv_header,
8273 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8274 WMITLV_GET_STRUCT_TLVLEN
8275 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308276 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308277 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8278
Govind Singh87542482016-06-08 19:40:11 +05308279#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308280 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308281 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308282#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308283 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308284 cmd->active_dwell_time = pno->active_dwell_time;
8285 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308286
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308287 if (pno->do_passive_scan)
8288 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308289 /* Copy scan interval */
8290 cmd->fast_scan_period = pno->fast_scan_period;
8291 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008292 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308293 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008294 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308295 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308296 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308297 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308298
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308299 /* mac randomization attributes */
8300 if (pno->scan_random.randomize) {
8301 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8302 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8303 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8304 pno->scan_random.mac_mask,
8305 &cmd->mac_addr,
8306 &cmd->mac_mask);
8307 }
8308
Govind Singh4eacd2b2016-03-07 14:24:22 +05308309 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8310
Abhishek Singh5987b632017-03-03 22:09:07 +05308311 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308312 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308313 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8314 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8315 buf_ptr += WMI_TLV_HDR_SIZE;
8316
8317 nlo_list = (nlo_configured_parameters *) buf_ptr;
8318 for (i = 0; i < cmd->no_of_ssids; i++) {
8319 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8320 WMITLV_TAG_ARRAY_BYTE,
8321 WMITLV_GET_STRUCT_TLVLEN
8322 (nlo_configured_parameters));
8323 /* Copy ssid and it's length */
8324 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308325 nlo_list[i].ssid.ssid.ssid_len =
8326 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308327 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308328 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308329 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308330 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308331 nlo_list[i].ssid.ssid.ssid_len,
8332 (char *)nlo_list[i].ssid.ssid.ssid,
8333 nlo_list[i].ssid.ssid.ssid_len);
8334
8335 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308336 if (pno->networks_list[i].rssi_thresh &&
8337 pno->networks_list[i].rssi_thresh >
8338 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308339 nlo_list[i].rssi_cond.valid = true;
8340 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308341 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308342 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308343 nlo_list[i].rssi_cond.rssi);
8344 }
8345 nlo_list[i].bcast_nw_type.valid = true;
8346 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308347 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008348 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308349 nlo_list[i].bcast_nw_type.bcast_nw_type);
8350 }
8351 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8352
8353 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308354 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308355 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308356 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8358 (cmd->num_of_channels * sizeof(uint32_t)));
8359 buf_ptr += WMI_TLV_HDR_SIZE;
8360
8361 channel_list = (uint32_t *) buf_ptr;
8362 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308363 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308364
8365 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308366 channel_list[i] =
8367 wlan_chan_to_freq(pno->
8368 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308369
Govind Singhb53420c2016-03-09 14:32:57 +05308370 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308371 }
8372 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8374 sizeof(nlo_channel_prediction_cfg));
8375 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308376 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308377 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308378 /** TODO: Discrete firmware doesn't have command/option to configure
8379 * App IE which comes from wpa_supplicant as of part PNO start request.
8380 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8382 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8383 buf_ptr += sizeof(enlo_candidate_score_params);
8384
8385 if (ie_whitelist->white_list) {
8386 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8387 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8388 &cmd->num_vendor_oui,
8389 ie_whitelist);
8390 }
8391
8392 /* ie white list */
8393 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8394 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8395 buf_ptr += WMI_TLV_HDR_SIZE;
8396 if (cmd->num_vendor_oui != 0) {
8397 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8398 ie_whitelist->voui);
8399 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8400 }
8401
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308402 if (pno->relative_rssi_set)
8403 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8404
8405 /*
8406 * Firmware calculation using connected PNO params:
8407 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8408 * deduction of rssi_pref for chosen band_pref and
8409 * addition of rssi_pref for remaining bands (other than chosen band).
8410 */
8411 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8412 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8413 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8414 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8415 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8416 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8417 buf_ptr += sizeof(*nlo_relative_rssi);
8418
8419 /*
8420 * As of now Kernel and Host supports one band and rssi preference.
8421 * Firmware supports array of band and rssi preferences
8422 */
8423 cmd->num_cnlo_band_pref = 1;
8424 WMITLV_SET_HDR(buf_ptr,
8425 WMITLV_TAG_ARRAY_STRUC,
8426 cmd->num_cnlo_band_pref *
8427 sizeof(connected_nlo_bss_band_rssi_pref));
8428 buf_ptr += WMI_TLV_HDR_SIZE;
8429
8430 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8431 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8432 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8433 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8434 WMITLV_GET_STRUCT_TLVLEN(
8435 connected_nlo_bss_band_rssi_pref));
8436 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8437 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8438 WMI_LOGI("band_pref %d, rssi_pref %d",
8439 nlo_band_rssi[i].band,
8440 nlo_band_rssi[i].rssi_pref);
8441 }
8442 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8443
Govind Singh4eacd2b2016-03-07 14:24:22 +05308444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8445 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8446 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308447 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308448 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308449 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308450 }
8451
Govind Singhb53420c2016-03-09 14:32:57 +05308452 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308453}
8454
8455/* send_set_ric_req_cmd_tlv() - set ric request element
8456 * @wmi_handle: wmi handle
8457 * @msg: message
8458 * @is_add_ts: is addts required
8459 *
8460 * This function sets ric request element for 11r roaming.
8461 *
8462 * Return: CDF status
8463 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308464static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308465 void *msg, uint8_t is_add_ts)
8466{
8467 wmi_ric_request_fixed_param *cmd;
8468 wmi_ric_tspec *tspec_param;
8469 wmi_buf_t buf;
8470 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308471 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308472 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8473 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8474
8475 buf = wmi_buf_alloc(wmi_handle, len);
8476 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308477 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8478 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308479 }
8480
8481 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8482
8483 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8484 WMITLV_SET_HDR(&cmd->tlv_header,
8485 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8486 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8487 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008488 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308489 else
8490 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8491 cmd->num_ric_request = 1;
8492 cmd->is_add_ric = is_add_ts;
8493
8494 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8496
8497 buf_ptr += WMI_TLV_HDR_SIZE;
8498 tspec_param = (wmi_ric_tspec *) buf_ptr;
8499 WMITLV_SET_HDR(&tspec_param->tlv_header,
8500 WMITLV_TAG_STRUC_wmi_ric_tspec,
8501 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8502
8503 if (is_add_ts)
8504 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308505#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308506 else
8507 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308508#endif
8509 if (ptspecIE) {
8510 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308511#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308512 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8513 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308514#else
Govind Singh87542482016-06-08 19:40:11 +05308515 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8516 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308517#endif /* ANI_LITTLE_BIT_ENDIAN */
8518
Govind Singh87542482016-06-08 19:40:11 +05308519 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8520 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8521 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8522 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8523 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8524 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8525 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8526 tspec_param->min_data_rate = ptspecIE->minDataRate;
8527 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8528 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8529 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8530 tspec_param->delay_bound = ptspecIE->delayBound;
8531 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8532 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8533 tspec_param->medium_time = 0;
8534 }
Govind Singhb53420c2016-03-09 14:32:57 +05308535 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308536
8537 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8538 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308539 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308540 __func__);
8541 if (is_add_ts)
8542 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308543 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308544 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308545 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308546 }
8547
Govind Singhb53420c2016-03-09 14:32:57 +05308548 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308549}
8550
8551/**
8552 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8553 * @wmi_handle: wmi handle
8554 * @clear_req: ll stats clear request command params
8555 *
Govind Singhb53420c2016-03-09 14:32:57 +05308556 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308557 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308558static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308559 const struct ll_stats_clear_params *clear_req,
8560 uint8_t addr[IEEE80211_ADDR_LEN])
8561{
8562 wmi_clear_link_stats_cmd_fixed_param *cmd;
8563 int32_t len;
8564 wmi_buf_t buf;
8565 uint8_t *buf_ptr;
8566 int ret;
8567
8568 len = sizeof(*cmd);
8569 buf = wmi_buf_alloc(wmi_handle, len);
8570
8571 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308572 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8573 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308574 }
8575
8576 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308577 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308578 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8579
8580 WMITLV_SET_HDR(&cmd->tlv_header,
8581 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8582 WMITLV_GET_STRUCT_TLVLEN
8583 (wmi_clear_link_stats_cmd_fixed_param));
8584
8585 cmd->stop_stats_collection_req = clear_req->stop_req;
8586 cmd->vdev_id = clear_req->sta_id;
8587 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8588
8589 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8590 &cmd->peer_macaddr);
8591
Govind Singhb53420c2016-03-09 14:32:57 +05308592 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8593 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8594 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8595 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8596 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308597 cmd->peer_macaddr); */
8598
8599 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8600 WMI_CLEAR_LINK_STATS_CMDID);
8601 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308602 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308603 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308604 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308605 }
8606
Govind Singhb53420c2016-03-09 14:32:57 +05308607 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8608 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308609}
8610
8611/**
8612 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8613 * @wmi_handle: wmi handle
8614 * @setReq: ll stats set request command params
8615 *
Govind Singhb53420c2016-03-09 14:32:57 +05308616 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308617 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308618static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308619 const struct ll_stats_set_params *set_req)
8620{
8621 wmi_start_link_stats_cmd_fixed_param *cmd;
8622 int32_t len;
8623 wmi_buf_t buf;
8624 uint8_t *buf_ptr;
8625 int ret;
8626
8627 len = sizeof(*cmd);
8628 buf = wmi_buf_alloc(wmi_handle, len);
8629
8630 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308631 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8632 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308633 }
8634
8635 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308636 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308637 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8638
8639 WMITLV_SET_HDR(&cmd->tlv_header,
8640 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8641 WMITLV_GET_STRUCT_TLVLEN
8642 (wmi_start_link_stats_cmd_fixed_param));
8643
8644 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8645 cmd->aggressive_statistics_gathering =
8646 set_req->aggressive_statistics_gathering;
8647
Govind Singhb53420c2016-03-09 14:32:57 +05308648 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8649 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8650 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308651
8652 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8653 WMI_START_LINK_STATS_CMDID);
8654 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308655 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308656 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308657 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308658 }
8659
Govind Singhb53420c2016-03-09 14:32:57 +05308660 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308661}
8662
8663/**
8664 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8665 * @wmi_handle:wmi handle
8666 * @get_req:ll stats get request command params
8667 * @addr: mac address
8668 *
Govind Singhb53420c2016-03-09 14:32:57 +05308669 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308670 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308671static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308672 const struct ll_stats_get_params *get_req,
8673 uint8_t addr[IEEE80211_ADDR_LEN])
8674{
8675 wmi_request_link_stats_cmd_fixed_param *cmd;
8676 int32_t len;
8677 wmi_buf_t buf;
8678 uint8_t *buf_ptr;
8679 int ret;
8680
8681 len = sizeof(*cmd);
8682 buf = wmi_buf_alloc(wmi_handle, len);
8683
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308684 if (!buf) {
8685 WMI_LOGE("%s: buf allocation failed", __func__);
8686 return QDF_STATUS_E_NOMEM;
8687 }
8688
Govind Singh4eacd2b2016-03-07 14:24:22 +05308689 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308690 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308691 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8692
8693 WMITLV_SET_HDR(&cmd->tlv_header,
8694 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8695 WMITLV_GET_STRUCT_TLVLEN
8696 (wmi_request_link_stats_cmd_fixed_param));
8697
8698 cmd->request_id = get_req->req_id;
8699 cmd->stats_type = get_req->param_id_mask;
8700 cmd->vdev_id = get_req->sta_id;
8701
8702 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8703 &cmd->peer_macaddr);
8704
Govind Singhb53420c2016-03-09 14:32:57 +05308705 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008706 WMI_LOGD("Request ID : %u", cmd->request_id);
8707 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308708 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8709 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308710
8711 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8712 WMI_REQUEST_LINK_STATS_CMDID);
8713 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308714 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308715 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308716 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308717 }
8718
Govind Singhb53420c2016-03-09 14:32:57 +05308719 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308720}
8721
Govind Singh4eacd2b2016-03-07 14:24:22 +05308722
Govind Singh20c5dac2016-03-07 15:33:31 +05308723/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308724 * send_congestion_cmd_tlv() - send request to fw to get CCA
8725 * @wmi_handle: wmi handle
8726 * @vdev_id: vdev id
8727 *
8728 * Return: CDF status
8729 */
8730static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308731 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308732{
8733 wmi_buf_t buf;
8734 wmi_request_stats_cmd_fixed_param *cmd;
8735 uint8_t len;
8736 uint8_t *buf_ptr;
8737
8738 len = sizeof(*cmd);
8739 buf = wmi_buf_alloc(wmi_handle, len);
8740 if (!buf) {
8741 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8742 return QDF_STATUS_E_FAILURE;
8743 }
8744
8745 buf_ptr = wmi_buf_data(buf);
8746 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8747 WMITLV_SET_HDR(&cmd->tlv_header,
8748 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8749 WMITLV_GET_STRUCT_TLVLEN
8750 (wmi_request_stats_cmd_fixed_param));
8751
8752 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8753 cmd->vdev_id = vdev_id;
8754 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8755 cmd->vdev_id, cmd->stats_id);
8756
8757 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8758 WMI_REQUEST_STATS_CMDID)) {
8759 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8760 __func__);
8761 wmi_buf_free(buf);
8762 return QDF_STATUS_E_FAILURE;
8763 }
8764
8765 return QDF_STATUS_SUCCESS;
8766}
8767
8768/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308769 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8770 * @wmi_handle: wmi handle
8771 * @rssi_req: get RSSI request
8772 *
8773 * Return: CDF status
8774 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308775static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308776{
8777 wmi_buf_t buf;
8778 wmi_request_stats_cmd_fixed_param *cmd;
8779 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8780
8781 buf = wmi_buf_alloc(wmi_handle, len);
8782 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308783 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8784 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308785 }
8786
8787 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8788 WMITLV_SET_HDR(&cmd->tlv_header,
8789 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8790 WMITLV_GET_STRUCT_TLVLEN
8791 (wmi_request_stats_cmd_fixed_param));
8792 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8793 if (wmi_unified_cmd_send
8794 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308795 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308796 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308797 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308798 }
8799
Govind Singhb53420c2016-03-09 14:32:57 +05308800 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308801}
8802
8803/**
8804 * send_snr_cmd_tlv() - get RSSI from fw
8805 * @wmi_handle: wmi handle
8806 * @vdev_id: vdev id
8807 *
8808 * Return: CDF status
8809 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308810static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308811{
8812 wmi_buf_t buf;
8813 wmi_request_stats_cmd_fixed_param *cmd;
8814 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8815
8816 buf = wmi_buf_alloc(wmi_handle, len);
8817 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308818 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8819 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308820 }
8821
8822 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8823 cmd->vdev_id = vdev_id;
8824
8825 WMITLV_SET_HDR(&cmd->tlv_header,
8826 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8827 WMITLV_GET_STRUCT_TLVLEN
8828 (wmi_request_stats_cmd_fixed_param));
8829 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8830 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8831 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308832 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308833 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308834 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308835 }
8836
Govind Singhb53420c2016-03-09 14:32:57 +05308837 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308838}
8839
8840/**
8841 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8842 * @wmi_handle: wmi handle
8843 * @link_status: get link params
8844 *
8845 * Return: CDF status
8846 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308847static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308848 struct link_status_params *link_status)
8849{
8850 wmi_buf_t buf;
8851 wmi_request_stats_cmd_fixed_param *cmd;
8852 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8853
8854 buf = wmi_buf_alloc(wmi_handle, len);
8855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308856 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8857 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308858 }
8859
8860 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8861 WMITLV_SET_HDR(&cmd->tlv_header,
8862 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8863 WMITLV_GET_STRUCT_TLVLEN
8864 (wmi_request_stats_cmd_fixed_param));
8865 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8866 cmd->vdev_id = link_status->session_id;
8867 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8868 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308869 WMI_LOGE("Failed to send WMI link status request to fw");
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
Govind Singh20c5dac2016-03-07 15:33:31 +05308877/**
8878 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8879 * @wmi_handle: wmi handle
8880 * @ta_dhcp_ind: DHCP indication parameter
8881 *
8882 * Return: CDF Status
8883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308884static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308885 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8886{
Govind Singh67922e82016-04-01 16:48:57 +05308887 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308888 wmi_buf_t buf = NULL;
8889 uint8_t *buf_ptr;
8890 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8891 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8892
8893
8894 buf = wmi_buf_alloc(wmi_handle, len);
8895 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308896 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8897 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308898 }
8899
8900 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8901 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8902 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8903 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8904 WMITLV_GET_STRUCT_TLVLEN
8905 (wmi_peer_set_param_cmd_fixed_param));
8906
8907 /* fill in values */
8908 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8909 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8910 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308911 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 &ta_dhcp_ind->peer_macaddr,
8913 sizeof(ta_dhcp_ind->peer_macaddr));
8914
8915 status = wmi_unified_cmd_send(wmi_handle, buf,
8916 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308917 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308918 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308919 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308920 wmi_buf_free(buf);
8921 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308922
Govind Singh67922e82016-04-01 16:48:57 +05308923 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308924}
8925
8926/**
8927 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8928 * @wmi_handle: wmi handle
8929 * @pLinkSpeed: link speed info
8930 *
8931 * Return: CDF status
8932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308933static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308934 wmi_mac_addr peer_macaddr)
8935{
8936 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8937 wmi_buf_t wmi_buf;
8938 uint32_t len;
8939 uint8_t *buf_ptr;
8940
8941 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8942 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8943 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308944 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8945 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308946 }
8947 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8948
8949 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8950 WMITLV_SET_HDR(&cmd->tlv_header,
8951 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8952 WMITLV_GET_STRUCT_TLVLEN
8953 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8954
8955 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308956 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308957 &peer_macaddr,
8958 sizeof(peer_macaddr));
8959
8960
8961 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8962 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308963 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308964 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308965 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308966 }
Govind Singhb53420c2016-03-09 14:32:57 +05308967 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308968}
8969
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308970#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308971/**
8972 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8973 * @wmi_handle: wmi handler
8974 * @egap_params: pointer to egap_params
8975 *
8976 * Return: 0 for success, otherwise appropriate error code
8977 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308978static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308979 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308980{
8981 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8982 wmi_buf_t buf;
8983 int32_t err;
8984
8985 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308987 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8988 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308989 }
8990 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8991 WMITLV_SET_HDR(&cmd->tlv_header,
8992 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8993 WMITLV_GET_STRUCT_TLVLEN(
8994 wmi_ap_ps_egap_param_cmd_fixed_param));
8995
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308996 cmd->enable = egap_params->host_enable_egap;
8997 cmd->inactivity_time = egap_params->egap_inactivity_time;
8998 cmd->wait_time = egap_params->egap_wait_time;
8999 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05309000 err = wmi_unified_cmd_send(wmi_handle, buf,
9001 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
9002 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309003 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309004 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309005 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309006 }
9007
Govind Singhb53420c2016-03-09 14:32:57 +05309008 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309009}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309010#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309011
9012/**
9013 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9014 * @wmi_handl: wmi handle
9015 * @cmd: Profiling command index
9016 * @value1: parameter1 value
9017 * @value2: parameter2 value
9018 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309019 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309021static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309022 uint32_t cmd, uint32_t value1, uint32_t value2)
9023{
9024 wmi_buf_t buf;
9025 int32_t len = 0;
9026 int ret;
9027 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9028 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9029 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9030 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9031
9032 switch (cmd) {
9033 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9034 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9035 buf = wmi_buf_alloc(wmi_handle, len);
9036 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309037 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309038 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309039 }
9040 prof_trig_cmd =
9041 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9042 wmi_buf_data(buf);
9043 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9044 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9045 WMITLV_GET_STRUCT_TLVLEN
9046 (wmi_wlan_profile_trigger_cmd_fixed_param));
9047 prof_trig_cmd->enable = value1;
9048 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9049 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9050 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309051 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309052 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309053 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309054 return ret;
9055 }
9056 break;
9057
9058 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9059 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9060 buf = wmi_buf_alloc(wmi_handle, len);
9061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309062 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309063 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309064 }
9065 profile_getdata_cmd =
9066 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9067 wmi_buf_data(buf);
9068 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9069 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9070 WMITLV_GET_STRUCT_TLVLEN
9071 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9072 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9073 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9074 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309075 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309077 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309078 return ret;
9079 }
9080 break;
9081
9082 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9083 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9084 buf = wmi_buf_alloc(wmi_handle, len);
9085 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309086 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309087 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309088 }
9089 hist_intvl_cmd =
9090 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9091 wmi_buf_data(buf);
9092 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9093 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9094 WMITLV_GET_STRUCT_TLVLEN
9095 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9096 hist_intvl_cmd->profile_id = value1;
9097 hist_intvl_cmd->value = value2;
9098 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9099 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9100 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309101 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309102 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309103 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 return ret;
9105 }
9106 break;
9107
9108 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
9109 len =
9110 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9111 buf = wmi_buf_alloc(wmi_handle, len);
9112 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309113 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309114 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309115 }
9116 profile_enable_cmd =
9117 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9118 wmi_buf_data(buf);
9119 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9120 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9121 WMITLV_GET_STRUCT_TLVLEN
9122 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9123 profile_enable_cmd->profile_id = value1;
9124 profile_enable_cmd->enable = value2;
9125 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9126 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9127 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309128 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309129 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309130 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309131 return ret;
9132 }
9133 break;
9134
9135 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309136 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309137 break;
9138 }
9139
9140 return 0;
9141}
9142
Paul Zhang92ab8d32017-12-08 16:08:00 +08009143static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9144 struct wlm_latency_level_param *params)
9145{
9146 wmi_wlm_config_cmd_fixed_param *cmd;
9147 wmi_buf_t buf;
9148 uint32_t len = sizeof(*cmd);
9149 static uint32_t ll[4] = {100, 60, 40, 20};
9150
9151 buf = wmi_buf_alloc(wmi_handle, len);
9152 if (!buf) {
9153 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9154 return QDF_STATUS_E_NOMEM;
9155 }
9156 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9157 WMITLV_SET_HDR(&cmd->tlv_header,
9158 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9159 WMITLV_GET_STRUCT_TLVLEN
9160 (wmi_wlm_config_cmd_fixed_param));
9161 cmd->vdev_id = params->vdev_id;
9162 cmd->latency_level = params->wlm_latency_level;
9163 cmd->ul_latency = ll[params->wlm_latency_level];
9164 cmd->dl_latency = ll[params->wlm_latency_level];
9165 cmd->flags = params->wlm_latency_flags;
9166 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9167 WMI_WLM_CONFIG_CMDID)) {
9168 WMI_LOGE("%s: Failed to send setting latency config command",
9169 __func__);
9170 wmi_buf_free(buf);
9171 return QDF_STATUS_E_FAILURE;
9172 }
9173
9174 return 0;
9175}
Govind Singh20c5dac2016-03-07 15:33:31 +05309176/**
9177 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9178 * @wmi_handle: wmi handle
9179 * @vdev_id: vdev id
9180 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309181 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309182 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309183static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309184{
9185 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9186 wmi_buf_t buf;
9187 int32_t len = sizeof(*cmd);
9188
Govind Singhb53420c2016-03-09 14:32:57 +05309189 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 buf = wmi_buf_alloc(wmi_handle, len);
9191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309192 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309193 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309194 }
9195 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9196 wmi_buf_data(buf);
9197 WMITLV_SET_HDR(&cmd->tlv_header,
9198 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9199 WMITLV_GET_STRUCT_TLVLEN
9200 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9201 cmd->vdev_id = vdev_id;
9202 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9203 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9204 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309205 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309206 __func__);
9207 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309208 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309209 }
9210
9211 return 0;
9212}
9213
9214/**
9215 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9216 * @wmi_handle: wmi handle
9217 * @vdev_id: vdev id
9218 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309219 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309220 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309221static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 uint8_t vdev_id)
9223{
9224 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9225 wmi_buf_t buf;
9226 int32_t len = sizeof(*cmd);
9227
Govind Singhb53420c2016-03-09 14:32:57 +05309228 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309229 buf = wmi_buf_alloc(wmi_handle, len);
9230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309231 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309232 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309233 }
9234 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9235 WMITLV_SET_HDR(&cmd->tlv_header,
9236 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9237 WMITLV_GET_STRUCT_TLVLEN
9238 (wmi_csa_offload_enable_cmd_fixed_param));
9239 cmd->vdev_id = vdev_id;
9240 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9241 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9242 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309243 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309244 __func__);
9245 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309246 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309247 }
9248
9249 return 0;
9250}
9251
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009252#ifdef WLAN_FEATURE_CIF_CFR
9253/**
9254 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9255 * @wmi_handle: wmi handle
9256 * @data_len: len of dma cfg req
9257 * @data: dma cfg req
9258 *
9259 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9260 */
9261static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9262 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9263{
9264 wmi_buf_t buf;
9265 uint8_t *cmd;
9266 QDF_STATUS ret;
9267
9268 WMITLV_SET_HDR(cfg,
9269 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9270 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9271
9272 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9273 if (!buf) {
9274 WMI_LOGE(FL("wmi_buf_alloc failed"));
9275 return QDF_STATUS_E_FAILURE;
9276 }
9277
9278 cmd = (uint8_t *) wmi_buf_data(buf);
9279 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9280 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9281 sizeof(*cfg));
9282 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9283 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9284 if (QDF_IS_STATUS_ERROR(ret)) {
9285 WMI_LOGE(FL(":wmi cmd send failed"));
9286 wmi_buf_free(buf);
9287 }
9288
9289 return ret;
9290}
9291#endif
9292
Govind Singh20c5dac2016-03-07 15:33:31 +05309293/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309294 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9295 * @wmi_handle: wmi handle
9296 * @data_len: len of dma cfg req
9297 * @data: dma cfg req
9298 *
9299 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9300 */
9301static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9302 struct direct_buf_rx_cfg_req *cfg)
9303{
9304 wmi_buf_t buf;
9305 wmi_dma_ring_cfg_req_fixed_param *cmd;
9306 QDF_STATUS ret;
9307 int32_t len = sizeof(*cmd);
9308
9309 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9310 if (!buf) {
9311 WMI_LOGE(FL("wmi_buf_alloc failed"));
9312 return QDF_STATUS_E_FAILURE;
9313 }
9314
9315 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9316
9317 WMITLV_SET_HDR(&cmd->tlv_header,
9318 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9319 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9320
9321 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9322 cfg->pdev_id);
9323 cmd->mod_id = cfg->mod_id;
9324 cmd->base_paddr_lo = cfg->base_paddr_lo;
9325 cmd->base_paddr_hi = cfg->base_paddr_hi;
9326 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9327 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9328 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9329 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9330 cmd->num_elems = cfg->num_elems;
9331 cmd->buf_size = cfg->buf_size;
9332 cmd->num_resp_per_event = cfg->num_resp_per_event;
9333 cmd->event_timeout_ms = cfg->event_timeout_ms;
9334
9335 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9336 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9337 "head idx paddr hi %x tail idx paddr lo %x"
9338 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9339 "event timeout %d\n", __func__, cmd->pdev_id,
9340 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9341 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9342 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9343 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9344 cmd->event_timeout_ms);
9345 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9346 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9347 if (QDF_IS_STATUS_ERROR(ret)) {
9348 WMI_LOGE(FL(":wmi cmd send failed"));
9349 wmi_buf_free(buf);
9350 }
9351
9352 return ret;
9353}
9354
9355/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009356 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9357 * @wmi_handle: wmi handle
9358 * @start_11d_scan: 11d scan start request parameters
9359 *
9360 * This function request FW to start 11d scan.
9361 *
9362 * Return: QDF status
9363 */
9364static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9365 struct reg_start_11d_scan_req *start_11d_scan)
9366{
9367 wmi_11d_scan_start_cmd_fixed_param *cmd;
9368 int32_t len;
9369 wmi_buf_t buf;
9370 int ret;
9371
9372 len = sizeof(*cmd);
9373 buf = wmi_buf_alloc(wmi_handle, len);
9374 if (!buf) {
9375 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9376 return QDF_STATUS_E_NOMEM;
9377 }
9378
9379 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9380
9381 WMITLV_SET_HDR(&cmd->tlv_header,
9382 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9383 WMITLV_GET_STRUCT_TLVLEN
9384 (wmi_11d_scan_start_cmd_fixed_param));
9385
9386 cmd->vdev_id = start_11d_scan->vdev_id;
9387 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9388 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9389
9390 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9391
9392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9393 WMI_11D_SCAN_START_CMDID);
9394 if (ret) {
9395 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9396 wmi_buf_free(buf);
9397 return QDF_STATUS_E_FAILURE;
9398 }
9399
9400 return QDF_STATUS_SUCCESS;
9401}
9402
9403/**
9404 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9405 * @wmi_handle: wmi handle
9406 * @start_11d_scan: 11d scan stop request parameters
9407 *
9408 * This function request FW to stop 11d scan.
9409 *
9410 * Return: QDF status
9411 */
9412static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9413 struct reg_stop_11d_scan_req *stop_11d_scan)
9414{
9415 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9416 int32_t len;
9417 wmi_buf_t buf;
9418 int ret;
9419
9420 len = sizeof(*cmd);
9421 buf = wmi_buf_alloc(wmi_handle, len);
9422 if (!buf) {
9423 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9424 return QDF_STATUS_E_NOMEM;
9425 }
9426
9427 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9428
9429 WMITLV_SET_HDR(&cmd->tlv_header,
9430 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9431 WMITLV_GET_STRUCT_TLVLEN
9432 (wmi_11d_scan_stop_cmd_fixed_param));
9433
9434 cmd->vdev_id = stop_11d_scan->vdev_id;
9435
9436 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9437
9438 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9439 WMI_11D_SCAN_STOP_CMDID);
9440 if (ret) {
9441 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9442 wmi_buf_free(buf);
9443 return QDF_STATUS_E_FAILURE;
9444 }
9445
9446 return QDF_STATUS_SUCCESS;
9447}
9448
9449/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309450 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9451 * @wmi_handle: wmi handle
9452 * @startOemDataReq: start request params
9453 *
9454 * Return: CDF status
9455 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309456static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009457 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309458 uint8_t *data)
9459{
9460 wmi_buf_t buf;
9461 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309462 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309463
9464 buf = wmi_buf_alloc(wmi_handle,
9465 (data_len + WMI_TLV_HDR_SIZE));
9466 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309467 WMI_LOGE(FL("wmi_buf_alloc failed"));
9468 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309469 }
9470
9471 cmd = (uint8_t *) wmi_buf_data(buf);
9472
9473 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9474 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309475 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309476 data_len);
9477
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009478 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309479 data_len);
9480
9481 ret = wmi_unified_cmd_send(wmi_handle, buf,
9482 (data_len +
9483 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9484
Govind Singh67922e82016-04-01 16:48:57 +05309485 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309486 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309487 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309488 }
9489
Govind Singh67922e82016-04-01 16:48:57 +05309490 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309491}
9492
9493/**
9494 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9495 * @wmi_handle: wmi handle
9496 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9497 *
9498 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9499 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9500 * to firmware based on phyerr filtering
9501 * offload status.
9502 *
9503 * Return: 1 success, 0 failure
9504 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309505static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309506send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9507 bool dfs_phyerr_filter_offload)
9508{
9509 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9510 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9511 wmi_buf_t buf;
9512 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309513 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309514
9515
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009516 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309517 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309518 __func__);
9519 len = sizeof(*disable_phyerr_offload_cmd);
9520 buf = wmi_buf_alloc(wmi_handle, len);
9521 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309522 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309523 return 0;
9524 }
9525 disable_phyerr_offload_cmd =
9526 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9527 wmi_buf_data(buf);
9528
9529 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9530 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9531 WMITLV_GET_STRUCT_TLVLEN
9532 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9533
9534 /*
9535 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9536 * to the firmware to disable the phyerror
9537 * filtering offload.
9538 */
9539 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9540 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309541 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309542 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309543 __func__, ret);
9544 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309545 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309546 }
Govind Singhb53420c2016-03-09 14:32:57 +05309547 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309548 __func__);
9549 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309550 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309551 __func__);
9552
9553 len = sizeof(*enable_phyerr_offload_cmd);
9554 buf = wmi_buf_alloc(wmi_handle, len);
9555 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309556 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9557 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309558 }
9559
9560 enable_phyerr_offload_cmd =
9561 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9562 wmi_buf_data(buf);
9563
9564 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9565 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9566 WMITLV_GET_STRUCT_TLVLEN
9567 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9568
9569 /*
9570 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9571 * to the firmware to enable the phyerror
9572 * filtering offload.
9573 */
9574 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9575 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9576
Govind Singh67922e82016-04-01 16:48:57 +05309577 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309578 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309579 __func__, ret);
9580 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309581 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309582 }
Govind Singhb53420c2016-03-09 14:32:57 +05309583 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 __func__);
9585 }
9586
Govind Singhb53420c2016-03-09 14:32:57 +05309587 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309588}
9589
Naveen Rawata5817e72017-10-26 18:50:19 -07009590/**
9591 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9592 * will wake up host after specified time is elapsed
9593 * @wmi_handle: wmi handle
9594 * @vdev_id: vdev id
9595 * @cookie: value to identify reason why host set up wake call.
9596 * @time: time in ms
9597 *
9598 * Return: QDF status
9599 */
9600static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9601 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9602{
9603 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9604 wmi_buf_t buf;
9605 uint8_t *buf_ptr;
9606 int32_t len;
9607 int ret;
9608
9609 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9610 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9611 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9612 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9613 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05309614 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
9615 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009616
9617 buf = wmi_buf_alloc(wmi_handle, len);
9618 if (!buf) {
9619 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9620 return QDF_STATUS_E_NOMEM;
9621 }
9622
9623 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9624 buf_ptr = (uint8_t *) cmd;
9625
9626 WMITLV_SET_HDR(&cmd->tlv_header,
9627 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9628 WMITLV_GET_STRUCT_TLVLEN
9629 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9630 cmd->vdev_id = vdev_id;
9631 cmd->pattern_id = cookie,
9632 cmd->pattern_type = WOW_TIMER_PATTERN;
9633 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9634
9635 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9637 buf_ptr += WMI_TLV_HDR_SIZE;
9638
9639 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9641 buf_ptr += WMI_TLV_HDR_SIZE;
9642
9643 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9645 buf_ptr += WMI_TLV_HDR_SIZE;
9646
9647 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9648 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9649 buf_ptr += WMI_TLV_HDR_SIZE;
9650
9651 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05309652 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009653 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309654 *((uint32_t *) buf_ptr) = time;
9655 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009656
9657 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05309658 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009659 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309660 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07009661
9662 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9663 __func__, time, vdev_id);
9664
9665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9666 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9667 if (ret) {
9668 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9669 __func__);
9670 wmi_buf_free(buf);
9671 return QDF_STATUS_E_FAILURE;
9672 }
9673
9674 return QDF_STATUS_SUCCESS;
9675}
9676
Govind Singh20c5dac2016-03-07 15:33:31 +05309677#if !defined(REMOVE_PKT_LOG)
9678/**
9679 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9680 * @wmi_handle: wmi handle
9681 * @pktlog_event: pktlog event
9682 * @cmd_id: pktlog cmd id
9683 *
9684 * Return: CDF status
9685 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309686static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309687 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309688 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309689{
9690 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9691 WMI_CMD_ID CMD_ID;
9692 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9693 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9694 int len = 0;
9695 wmi_buf_t buf;
9696
9697 PKTLOG_EVENT = pktlog_event;
9698 CMD_ID = cmd_id;
9699
9700 switch (CMD_ID) {
9701 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9702 len = sizeof(*cmd);
9703 buf = wmi_buf_alloc(wmi_handle, len);
9704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309705 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 }
9708 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9709 wmi_buf_data(buf);
9710 WMITLV_SET_HDR(&cmd->tlv_header,
9711 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9712 WMITLV_GET_STRUCT_TLVLEN
9713 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9714 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309715 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9716 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309717 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9718 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309719 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9720 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309721 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309722 goto wmi_send_failed;
9723 }
9724 break;
9725 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9726 len = sizeof(*disable_cmd);
9727 buf = wmi_buf_alloc(wmi_handle, len);
9728 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309729 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9730 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309731 }
9732 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9733 wmi_buf_data(buf);
9734 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9735 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9736 WMITLV_GET_STRUCT_TLVLEN
9737 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309738 disable_cmd->pdev_id =
9739 wmi_handle->ops->convert_pdev_id_host_to_target(
9740 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309741 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9742 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309743 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309744 goto wmi_send_failed;
9745 }
9746 break;
9747 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309748 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309749 break;
9750 }
9751
Govind Singhb53420c2016-03-09 14:32:57 +05309752 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309753
9754wmi_send_failed:
9755 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309756 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309757}
9758#endif /* REMOVE_PKT_LOG */
9759
9760/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309761 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9762 * @wmi_handle: wmi handle
9763 * @ptrn_id: pattern id
9764 * @vdev_id: vdev id
9765 *
9766 * Return: CDF status
9767 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309768static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9769 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309770{
9771 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9772 wmi_buf_t buf;
9773 int32_t len;
9774 int ret;
9775
9776 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9777
9778
9779 buf = wmi_buf_alloc(wmi_handle, len);
9780 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309781 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9782 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309783 }
9784
9785 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9786
9787 WMITLV_SET_HDR(&cmd->tlv_header,
9788 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9789 WMITLV_GET_STRUCT_TLVLEN(
9790 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9791 cmd->vdev_id = vdev_id;
9792 cmd->pattern_id = ptrn_id;
9793 cmd->pattern_type = WOW_BITMAP_PATTERN;
9794
Govind Singhb53420c2016-03-09 14:32:57 +05309795 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309796 cmd->pattern_id, vdev_id);
9797
9798 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9799 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9800 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309801 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309802 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309803 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309804 }
9805
Govind Singhb53420c2016-03-09 14:32:57 +05309806 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309807}
9808
9809/**
9810 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9811 * @wmi_handle: wmi handle
9812 *
9813 * Sends host wakeup indication to FW. On receiving this indication,
9814 * FW will come out of WOW.
9815 *
9816 * Return: CDF status
9817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309818static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309819{
9820 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9821 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309822 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309823 int32_t len;
9824 int ret;
9825
9826 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9827
9828 buf = wmi_buf_alloc(wmi_handle, len);
9829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309830 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9831 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309832 }
9833
9834 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9835 wmi_buf_data(buf);
9836 WMITLV_SET_HDR(&cmd->tlv_header,
9837 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9838 WMITLV_GET_STRUCT_TLVLEN
9839 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9840
9841
9842 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9843 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9844 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309845 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309846 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309847 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309848 }
9849
Govind Singhb53420c2016-03-09 14:32:57 +05309850 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309851}
9852
9853/**
9854 * send_del_ts_cmd_tlv() - send DELTS request to fw
9855 * @wmi_handle: wmi handle
9856 * @msg: delts params
9857 *
9858 * Return: CDF status
9859 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309860static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309861 uint8_t ac)
9862{
9863 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9864 wmi_buf_t buf;
9865 int32_t len = sizeof(*cmd);
9866
9867 buf = wmi_buf_alloc(wmi_handle, len);
9868 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309869 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9870 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309871 }
9872 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9873 WMITLV_SET_HDR(&cmd->tlv_header,
9874 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9875 WMITLV_GET_STRUCT_TLVLEN
9876 (wmi_vdev_wmm_delts_cmd_fixed_param));
9877 cmd->vdev_id = vdev_id;
9878 cmd->ac = ac;
9879
Govind Singhb53420c2016-03-09 14:32:57 +05309880 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309881 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9882 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9883 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309884 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309885 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309886 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309887 }
9888
Govind Singhb53420c2016-03-09 14:32:57 +05309889 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309890}
9891
9892/**
9893 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9894 * @wmi_handle: handle to wmi
9895 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9896 *
Govind Singhb53420c2016-03-09 14:32:57 +05309897 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309898 * ADD_TS requestes to firmware in loop for all the ACs with
9899 * active flow.
9900 *
9901 * Return: CDF status
9902 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309903static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309904 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9905{
9906 int i = 0;
9907 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9908 wmi_buf_t buf;
9909 int32_t len = sizeof(*cmd);
9910
9911 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9912 /* if flow in this AC is active */
9913 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9914 /*
9915 * as per implementation of wma_add_ts_req() we
9916 * are not waiting any response from firmware so
9917 * apart from sending ADDTS to firmware just send
9918 * success to upper layers
9919 */
Govind Singhb53420c2016-03-09 14:32:57 +05309920 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309921
9922 buf = wmi_buf_alloc(wmi_handle, len);
9923 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309924 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9925 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309926 }
9927 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9928 wmi_buf_data(buf);
9929 WMITLV_SET_HDR(&cmd->tlv_header,
9930 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9931 WMITLV_GET_STRUCT_TLVLEN
9932 (wmi_vdev_wmm_addts_cmd_fixed_param));
9933 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9934 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309935 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309936 traffic.userPrio);
9937 cmd->medium_time_us =
9938 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9939 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309940 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309941 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9942 cmd->medium_time_us, cmd->downgrade_type);
9943 if (wmi_unified_cmd_send
9944 (wmi_handle, buf, len,
9945 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309946 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309947 __func__);
9948 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309949 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309950 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309951 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309952 }
9953 }
9954 }
9955
Govind Singhb53420c2016-03-09 14:32:57 +05309956 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309957}
9958
9959/**
9960 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9961 * @wmi_handle: wmi handle
9962 * @msg: ADDTS params
9963 *
9964 * Return: CDF status
9965 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309966static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309967 struct add_ts_param *msg)
9968{
9969 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9970 wmi_buf_t buf;
9971 int32_t len = sizeof(*cmd);
9972
Govind Singhb53420c2016-03-09 14:32:57 +05309973 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309974
9975 buf = wmi_buf_alloc(wmi_handle, len);
9976 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309977 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9978 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309979 }
9980 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9981 WMITLV_SET_HDR(&cmd->tlv_header,
9982 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9983 WMITLV_GET_STRUCT_TLVLEN
9984 (wmi_vdev_wmm_addts_cmd_fixed_param));
9985 cmd->vdev_id = msg->sme_session_id;
9986 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9987 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9988 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309989 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309990 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9991 cmd->downgrade_type, __func__, __LINE__);
9992 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9993 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309994 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9995 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309996 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309997 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309998 }
9999
Govind Singhb53420c2016-03-09 14:32:57 +053010000 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010001}
10002
10003/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010004 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
10005 * @wmi_handle: wmi handle
10006 * @pAddPeriodicTxPtrnParams: tx ptrn params
10007 *
10008 * Retrun: CDF status
10009 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010010static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010011 struct periodic_tx_pattern *
10012 pAddPeriodicTxPtrnParams,
10013 uint8_t vdev_id)
10014{
10015 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10016 wmi_buf_t wmi_buf;
10017 uint32_t len;
10018 uint8_t *buf_ptr;
10019 uint32_t ptrn_len, ptrn_len_aligned;
10020 int j;
10021
10022 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10023 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10024 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10025 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10026
10027 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10028 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010029 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10030 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010031 }
10032
10033 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10034
10035 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10036 WMITLV_SET_HDR(&cmd->tlv_header,
10037 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10038 WMITLV_GET_STRUCT_TLVLEN
10039 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10040
10041 /* Pass the pattern id to delete for the corresponding vdev id */
10042 cmd->vdev_id = vdev_id;
10043 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10044 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10045 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10046
10047 /* Pattern info */
10048 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10049 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10050 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010051 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010052 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010053 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010054
Govind Singhb53420c2016-03-09 14:32:57 +053010055 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010056 __func__, cmd->pattern_id, cmd->vdev_id);
10057
10058 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10059 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010060 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010061 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010062 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010063 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010064 }
Govind Singhb53420c2016-03-09 14:32:57 +053010065 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010066}
10067
10068/**
10069 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10070 * @wmi_handle: wmi handle
10071 * @vdev_id: vdev id
10072 * @pattern_id: pattern id
10073 *
10074 * Retrun: CDF status
10075 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010076static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010077 uint8_t vdev_id,
10078 uint8_t pattern_id)
10079{
10080 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10081 wmi_buf_t wmi_buf;
10082 uint32_t len =
10083 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10084
10085 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10086 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010087 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10088 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010089 }
10090
10091 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10092 wmi_buf_data(wmi_buf);
10093 WMITLV_SET_HDR(&cmd->tlv_header,
10094 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10095 WMITLV_GET_STRUCT_TLVLEN
10096 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10097
10098 /* Pass the pattern id to delete for the corresponding vdev id */
10099 cmd->vdev_id = vdev_id;
10100 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010101 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010102 __func__, cmd->pattern_id, cmd->vdev_id);
10103
10104 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10105 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010106 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010107 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010108 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010109 }
Govind Singhb53420c2016-03-09 14:32:57 +053010110 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010111}
10112
10113/**
10114 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10115 * @wmi_handle: wmi handle
10116 * @preq: stats ext params
10117 *
10118 * Return: CDF status
10119 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010120static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010121 struct stats_ext_params *preq)
10122{
Govind Singh67922e82016-04-01 16:48:57 +053010123 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010124 wmi_req_stats_ext_cmd_fixed_param *cmd;
10125 wmi_buf_t buf;
10126 uint16_t len;
10127 uint8_t *buf_ptr;
10128
10129 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10130
10131 buf = wmi_buf_alloc(wmi_handle, len);
10132 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010133 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010134 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010135 }
10136
10137 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10138 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10139
10140 WMITLV_SET_HDR(&cmd->tlv_header,
10141 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10142 WMITLV_GET_STRUCT_TLVLEN
10143 (wmi_req_stats_ext_cmd_fixed_param));
10144 cmd->vdev_id = preq->vdev_id;
10145 cmd->data_len = preq->request_data_len;
10146
Govind Singhb53420c2016-03-09 14:32:57 +053010147 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010148 __func__, preq->request_data_len, preq->vdev_id);
10149
10150 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10152
10153 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010154 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010155
10156 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10157 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010158 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010159 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010160 ret);
10161 wmi_buf_free(buf);
10162 }
10163
10164 return ret;
10165}
10166
10167/**
10168 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10169 * @wmi_handle: wmi handle
10170 * @params: ext wow params
10171 *
10172 * Return:0 for success or error code
10173 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010174static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010175 struct ext_wow_params *params)
10176{
10177 wmi_extwow_enable_cmd_fixed_param *cmd;
10178 wmi_buf_t buf;
10179 int32_t len;
10180 int ret;
10181
10182 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10183 buf = wmi_buf_alloc(wmi_handle, len);
10184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010185 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10186 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010187 }
10188
10189 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10190
10191 WMITLV_SET_HDR(&cmd->tlv_header,
10192 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10193 WMITLV_GET_STRUCT_TLVLEN
10194 (wmi_extwow_enable_cmd_fixed_param));
10195
10196 cmd->vdev_id = params->vdev_id;
10197 cmd->type = params->type;
10198 cmd->wakeup_pin_num = params->wakeup_pin_num;
10199
Govind Singhb53420c2016-03-09 14:32:57 +053010200 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010201 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10202
10203 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10204 WMI_EXTWOW_ENABLE_CMDID);
10205 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010206 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010207 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010208 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010209 }
10210
Govind Singhb53420c2016-03-09 14:32:57 +053010211 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010212
10213}
10214
10215/**
10216 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10217 * @wmi_handle: wmi handle
10218 * @app_type1_params: app type1 params
10219 *
10220 * Return: CDF status
10221 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010222static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010223 struct app_type1_params *app_type1_params)
10224{
10225 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10226 wmi_buf_t buf;
10227 int32_t len;
10228 int ret;
10229
10230 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10231 buf = wmi_buf_alloc(wmi_handle, len);
10232 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010233 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10234 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010235 }
10236
10237 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10238 wmi_buf_data(buf);
10239
10240 WMITLV_SET_HDR(&cmd->tlv_header,
10241 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10242 WMITLV_GET_STRUCT_TLVLEN
10243 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10244
10245 cmd->vdev_id = app_type1_params->vdev_id;
10246 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10247 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010248 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010249 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010250 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010251 cmd->passwd_len = app_type1_params->pass_length;
10252
Govind Singhb53420c2016-03-09 14:32:57 +053010253 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010254 "identification_id %.8s id_length %u "
10255 "password %.16s pass_length %u",
10256 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10257 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10258
10259 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10260 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10261 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010262 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010263 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010264 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010265 }
10266
Govind Singhb53420c2016-03-09 14:32:57 +053010267 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010268}
10269
10270/**
10271 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10272 * @wmi_handle: wmi handle
10273 * @appType2Params: app type2 params
10274 *
10275 * Return: CDF status
10276 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010277static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010278 struct app_type2_params *appType2Params)
10279{
10280 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10281 wmi_buf_t buf;
10282 int32_t len;
10283 int ret;
10284
10285 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10286 buf = wmi_buf_alloc(wmi_handle, len);
10287 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010288 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10289 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010290 }
10291
10292 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10293 wmi_buf_data(buf);
10294
10295 WMITLV_SET_HDR(&cmd->tlv_header,
10296 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10297 WMITLV_GET_STRUCT_TLVLEN
10298 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10299
10300 cmd->vdev_id = appType2Params->vdev_id;
10301
Govind Singhb53420c2016-03-09 14:32:57 +053010302 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010303 cmd->rc4_key_len = appType2Params->rc4_key_len;
10304
10305 cmd->ip_id = appType2Params->ip_id;
10306 cmd->ip_device_ip = appType2Params->ip_device_ip;
10307 cmd->ip_server_ip = appType2Params->ip_server_ip;
10308
10309 cmd->tcp_src_port = appType2Params->tcp_src_port;
10310 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10311 cmd->tcp_seq = appType2Params->tcp_seq;
10312 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10313
10314 cmd->keepalive_init = appType2Params->keepalive_init;
10315 cmd->keepalive_min = appType2Params->keepalive_min;
10316 cmd->keepalive_max = appType2Params->keepalive_max;
10317 cmd->keepalive_inc = appType2Params->keepalive_inc;
10318
10319 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10320 &cmd->gateway_mac);
10321 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10322 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10323
Govind Singhb53420c2016-03-09 14:32:57 +053010324 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010325 "rc4_key %.16s rc4_key_len %u "
10326 "ip_id %x ip_device_ip %x ip_server_ip %x "
10327 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10328 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10329 "keepalive_max %u keepalive_inc %u "
10330 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10331 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10332 cmd->rc4_key, cmd->rc4_key_len,
10333 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10334 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10335 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10336 cmd->keepalive_max, cmd->keepalive_inc,
10337 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10338
10339 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10340 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10341 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010342 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010343 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010344 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010345 }
10346
Govind Singhb53420c2016-03-09 14:32:57 +053010347 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010348
10349}
10350
10351/**
10352 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10353 * @wmi_handle: wmi handle
10354 * @timer_val: auto shutdown timer value
10355 *
10356 * Return: CDF status
10357 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010358static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010359 uint32_t timer_val)
10360{
Govind Singh67922e82016-04-01 16:48:57 +053010361 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010362 wmi_buf_t buf = NULL;
10363 uint8_t *buf_ptr;
10364 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10365 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10366
Govind Singhb53420c2016-03-09 14:32:57 +053010367 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010368 __func__, timer_val);
10369
10370 buf = wmi_buf_alloc(wmi_handle, len);
10371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010372 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10373 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010374 }
10375
10376 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10377 wmi_auto_sh_cmd =
10378 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10379 wmi_auto_sh_cmd->timer_value = timer_val;
10380
10381 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10382 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10383 WMITLV_GET_STRUCT_TLVLEN
10384 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10385
10386 status = wmi_unified_cmd_send(wmi_handle, buf,
10387 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010388 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010389 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010390 __func__, status);
10391 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010392 }
10393
Govind Singh67922e82016-04-01 16:48:57 +053010394 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010395}
10396
10397/**
10398 * send_nan_req_cmd_tlv() - to send nan request to target
10399 * @wmi_handle: wmi handle
10400 * @nan_req: request data which will be non-null
10401 *
10402 * Return: CDF status
10403 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010404static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010405 struct nan_req_params *nan_req)
10406{
Govind Singh67922e82016-04-01 16:48:57 +053010407 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010408 wmi_nan_cmd_param *cmd;
10409 wmi_buf_t buf;
10410 uint16_t len = sizeof(*cmd);
10411 uint16_t nan_data_len, nan_data_len_aligned;
10412 uint8_t *buf_ptr;
10413
10414 /*
10415 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10416 * +------------+----------+-----------------------+--------------+
10417 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10418 * +------------+----------+-----------------------+--------------+
10419 */
10420 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010421 WMI_LOGE("%s:nan req is not valid", __func__);
10422 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010423 }
10424 nan_data_len = nan_req->request_data_len;
10425 nan_data_len_aligned = roundup(nan_req->request_data_len,
10426 sizeof(uint32_t));
10427 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10428 buf = wmi_buf_alloc(wmi_handle, len);
10429 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010430 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10431 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010432 }
10433 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10434 cmd = (wmi_nan_cmd_param *) buf_ptr;
10435 WMITLV_SET_HDR(&cmd->tlv_header,
10436 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10437 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10438 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010439 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010440 __func__, nan_req->request_data_len);
10441 buf_ptr += sizeof(wmi_nan_cmd_param);
10442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10443 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010444 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010445
10446 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10447 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010448 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010449 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010450 __func__, ret);
10451 wmi_buf_free(buf);
10452 }
10453
10454 return ret;
10455}
10456
10457/**
10458 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10459 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010460 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010461 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010462 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010463 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010464static QDF_STATUS
10465send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10466 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010467{
10468 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10469 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010470 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010471
10472 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10473 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010474 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010475 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010476 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010477 }
10478
10479 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010480
10481 WMITLV_SET_HDR(&cmd->tlv_header,
10482 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10483 WMITLV_GET_STRUCT_TLVLEN
10484 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010485 cmd->vdev_id = params->vdev_id;
10486 cmd->enable = params->dhcp_offload_enabled;
10487 cmd->num_client = params->dhcp_client_num;
10488 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010489 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010490 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010491 sizeof(*cmd),
10492 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010493 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010494 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010495 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010496 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010497 }
Govind Singhb53420c2016-03-09 14:32:57 +053010498 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010499 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010500
10501 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010502}
10503
10504/**
10505 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10506 * @wmi_handle: wmi handle
10507 * @flashing: flashing request
10508 *
10509 * Return: CDF status
10510 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010511static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010512 struct flashing_req_params *flashing)
10513{
10514 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010515 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010516 wmi_buf_t buf;
10517 uint8_t *buf_ptr;
10518 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10519
10520 buf = wmi_buf_alloc(wmi_handle, len);
10521 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010522 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010523 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010524 }
10525 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10526 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10527 WMITLV_SET_HDR(&cmd->tlv_header,
10528 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10529 WMITLV_GET_STRUCT_TLVLEN
10530 (wmi_set_led_flashing_cmd_fixed_param));
10531 cmd->pattern_id = flashing->pattern_id;
10532 cmd->led_x0 = flashing->led_x0;
10533 cmd->led_x1 = flashing->led_x1;
10534
10535 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10536 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010537 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010538 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010539 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010540 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010541 }
Govind Singh67922e82016-04-01 16:48:57 +053010542
10543 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010544}
10545
10546/**
10547 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10548 * @wmi_handle: wmi handle
10549 * @ch_avoid_update_req: channel avoid update params
10550 *
10551 * Return: CDF status
10552 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010553static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010554{
Govind Singh67922e82016-04-01 16:48:57 +053010555 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010556 wmi_buf_t buf = NULL;
10557 uint8_t *buf_ptr;
10558 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10559 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10560
10561
10562 buf = wmi_buf_alloc(wmi_handle, len);
10563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010564 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10565 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010566 }
10567
10568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10569 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10570 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10571 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10572 WMITLV_GET_STRUCT_TLVLEN
10573 (wmi_chan_avoid_update_cmd_param));
10574
10575 status = wmi_unified_cmd_send(wmi_handle, buf,
10576 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010577 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010578 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010579 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10580 " returned Error %d", status);
10581 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010582 }
10583
Govind Singh67922e82016-04-01 16:48:57 +053010584 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010585}
10586
10587/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010588 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10589 * @wmi_handle: wmi handle
10590 * @param: pointer to pdev regdomain params
10591 *
10592 * Return: 0 for success or error code
10593 */
10594static QDF_STATUS
10595send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10596 struct pdev_set_regdomain_params *param)
10597{
10598 wmi_buf_t buf;
10599 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10600 int32_t len = sizeof(*cmd);
10601
10602
10603 buf = wmi_buf_alloc(wmi_handle, len);
10604 if (!buf) {
10605 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10606 return QDF_STATUS_E_NOMEM;
10607 }
10608 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10609 WMITLV_SET_HDR(&cmd->tlv_header,
10610 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10611 WMITLV_GET_STRUCT_TLVLEN
10612 (wmi_pdev_set_regdomain_cmd_fixed_param));
10613
10614 cmd->reg_domain = param->currentRDinuse;
10615 cmd->reg_domain_2G = param->currentRD2G;
10616 cmd->reg_domain_5G = param->currentRD5G;
10617 cmd->conformance_test_limit_2G = param->ctl_2G;
10618 cmd->conformance_test_limit_5G = param->ctl_5G;
10619 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010620 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10621 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010622
10623 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10624 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10625 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10626 __func__);
10627 wmi_buf_free(buf);
10628 return QDF_STATUS_E_FAILURE;
10629 }
10630
10631 return QDF_STATUS_SUCCESS;
10632}
10633
10634/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010635 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10636 * @wmi_handle: wmi handle
10637 * @reg_dmn: reg domain
10638 * @regdmn2G: 2G reg domain
10639 * @regdmn5G: 5G reg domain
10640 * @ctl2G: 2G test limit
10641 * @ctl5G: 5G test limit
10642 *
10643 * Return: none
10644 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010645static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010646 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010647 uint16_t regdmn5G, uint8_t ctl2G,
10648 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010649{
10650 wmi_buf_t buf;
10651 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10652 int32_t len = sizeof(*cmd);
10653
10654
10655 buf = wmi_buf_alloc(wmi_handle, len);
10656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010657 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10658 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010659 }
10660 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10661 WMITLV_SET_HDR(&cmd->tlv_header,
10662 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10663 WMITLV_GET_STRUCT_TLVLEN
10664 (wmi_pdev_set_regdomain_cmd_fixed_param));
10665 cmd->reg_domain = reg_dmn;
10666 cmd->reg_domain_2G = regdmn2G;
10667 cmd->reg_domain_5G = regdmn5G;
10668 cmd->conformance_test_limit_2G = ctl2G;
10669 cmd->conformance_test_limit_5G = ctl5G;
10670
10671 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10672 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010673 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010674 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010675 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010676 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010677 }
10678
Govind Singhb53420c2016-03-09 14:32:57 +053010679 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010680}
10681
10682
10683/**
10684 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10685 * @wmi_handle: wmi handle
10686 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10687 *
10688 * This function sets tdls off channel mode
10689 *
10690 * Return: 0 on success; Negative errno otherwise
10691 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010692static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010693 struct tdls_channel_switch_params *chan_switch_params)
10694{
10695 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10696 wmi_buf_t wmi_buf;
10697 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10698
10699 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10700 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010701 WMI_LOGE(FL("wmi_buf_alloc failed"));
10702 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010703 }
10704 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10705 wmi_buf_data(wmi_buf);
10706 WMITLV_SET_HDR(&cmd->tlv_header,
10707 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10708 WMITLV_GET_STRUCT_TLVLEN(
10709 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10710
10711 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10712 &cmd->peer_macaddr);
10713 cmd->vdev_id = chan_switch_params->vdev_id;
10714 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10715 cmd->is_peer_responder = chan_switch_params->is_responder;
10716 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10717 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10718 cmd->offchan_oper_class = chan_switch_params->oper_class;
10719
Govind Singhb53420c2016-03-09 14:32:57 +053010720 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010721 cmd->peer_macaddr.mac_addr31to0,
10722 cmd->peer_macaddr.mac_addr47to32);
10723
Govind Singhb53420c2016-03-09 14:32:57 +053010724 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010725 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10726 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10727 ),
10728 cmd->vdev_id,
10729 cmd->offchan_mode,
10730 cmd->offchan_num,
10731 cmd->offchan_bw_bitmap,
10732 cmd->is_peer_responder,
10733 cmd->offchan_oper_class);
10734
10735 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10736 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010737 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010738 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010739 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010740 }
10741
10742
Govind Singhb53420c2016-03-09 14:32:57 +053010743 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010744}
10745
10746/**
10747 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10748 * @wmi_handle: wmi handle
10749 * @pwmaTdlsparams: TDLS params
10750 *
10751 * Return: 0 for sucess or error code
10752 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010753static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010754 void *tdls_param, uint8_t tdls_state)
10755{
10756 wmi_tdls_set_state_cmd_fixed_param *cmd;
10757 wmi_buf_t wmi_buf;
10758
10759 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10760 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10761
10762 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10763 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010764 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10765 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010766 }
10767 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10768 WMITLV_SET_HDR(&cmd->tlv_header,
10769 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10770 WMITLV_GET_STRUCT_TLVLEN
10771 (wmi_tdls_set_state_cmd_fixed_param));
10772 cmd->vdev_id = wmi_tdls->vdev_id;
10773 cmd->state = tdls_state;
10774 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10775 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10776 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10777 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10778 cmd->rssi_delta = wmi_tdls->rssi_delta;
10779 cmd->tdls_options = wmi_tdls->tdls_options;
10780 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10781 cmd->tdls_peer_traffic_response_timeout_ms =
10782 wmi_tdls->peer_traffic_response_timeout;
10783 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10784 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10785 cmd->tdls_puapsd_rx_frame_threshold =
10786 wmi_tdls->puapsd_rx_frame_threshold;
10787 cmd->teardown_notification_ms =
10788 wmi_tdls->teardown_notification_ms;
10789 cmd->tdls_peer_kickout_threshold =
10790 wmi_tdls->tdls_peer_kickout_threshold;
10791
Govind Singhb53420c2016-03-09 14:32:57 +053010792 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010793 "notification_interval_ms: %d, "
10794 "tx_discovery_threshold: %d, "
10795 "tx_teardown_threshold: %d, "
10796 "rssi_teardown_threshold: %d, "
10797 "rssi_delta: %d, "
10798 "tdls_options: 0x%x, "
10799 "tdls_peer_traffic_ind_window: %d, "
10800 "tdls_peer_traffic_response_timeout: %d, "
10801 "tdls_puapsd_mask: 0x%x, "
10802 "tdls_puapsd_inactivity_time: %d, "
10803 "tdls_puapsd_rx_frame_threshold: %d, "
10804 "teardown_notification_ms: %d, "
10805 "tdls_peer_kickout_threshold: %d",
10806 __func__, tdls_state, cmd->state,
10807 cmd->notification_interval_ms,
10808 cmd->tx_discovery_threshold,
10809 cmd->tx_teardown_threshold,
10810 cmd->rssi_teardown_threshold,
10811 cmd->rssi_delta,
10812 cmd->tdls_options,
10813 cmd->tdls_peer_traffic_ind_window,
10814 cmd->tdls_peer_traffic_response_timeout_ms,
10815 cmd->tdls_puapsd_mask,
10816 cmd->tdls_puapsd_inactivity_time_ms,
10817 cmd->tdls_puapsd_rx_frame_threshold,
10818 cmd->teardown_notification_ms,
10819 cmd->tdls_peer_kickout_threshold);
10820
10821 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10822 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010823 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010824 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010825 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010826 }
Govind Singhb53420c2016-03-09 14:32:57 +053010827 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010828
Govind Singhb53420c2016-03-09 14:32:57 +053010829 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010830}
10831
10832/**
10833 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10834 * @wmi_handle: wmi handle
10835 * @peerStateParams: TDLS peer state params
10836 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010837 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010838 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010839static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010840 struct tdls_peer_state_params *peerStateParams,
10841 uint32_t *ch_mhz)
10842{
10843 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10844 wmi_tdls_peer_capabilities *peer_cap;
10845 wmi_channel *chan_info;
10846 wmi_buf_t wmi_buf;
10847 uint8_t *buf_ptr;
10848 uint32_t i;
10849 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10850 sizeof(wmi_tdls_peer_capabilities);
10851
10852
10853 len += WMI_TLV_HDR_SIZE +
10854 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10855
10856 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10857 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010858 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10859 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010860 }
10861
10862 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10863 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10864 WMITLV_SET_HDR(&cmd->tlv_header,
10865 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10866 WMITLV_GET_STRUCT_TLVLEN
10867 (wmi_tdls_peer_update_cmd_fixed_param));
10868
10869 cmd->vdev_id = peerStateParams->vdevId;
10870 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10871 &cmd->peer_macaddr);
10872
10873
10874 cmd->peer_state = peerStateParams->peerState;
10875
Govind Singhb53420c2016-03-09 14:32:57 +053010876 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010877 "peer_macaddr.mac_addr31to0: 0x%x, "
10878 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10879 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10880 cmd->peer_macaddr.mac_addr31to0,
10881 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10882
10883 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10884 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10885 WMITLV_SET_HDR(&peer_cap->tlv_header,
10886 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10887 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10888
10889 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10890 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10891 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10892 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10893 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10894 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10895 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10896 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10897
10898 /* Ack and More Data Ack are sent as 0, so no need to set
10899 * but fill SP
10900 */
10901 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10902 peerStateParams->peerCap.peerMaxSp);
10903
10904 peer_cap->buff_sta_support =
10905 peerStateParams->peerCap.peerBuffStaSupport;
10906 peer_cap->off_chan_support =
10907 peerStateParams->peerCap.peerOffChanSupport;
10908 peer_cap->peer_curr_operclass =
10909 peerStateParams->peerCap.peerCurrOperClass;
10910 /* self curr operclass is not being used and so pass op class for
10911 * preferred off chan in it.
10912 */
10913 peer_cap->self_curr_operclass =
10914 peerStateParams->peerCap.opClassForPrefOffChan;
10915 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10916 peer_cap->peer_operclass_len =
10917 peerStateParams->peerCap.peerOperClassLen;
10918
Govind Singhb53420c2016-03-09 14:32:57 +053010919 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010920 __func__, peer_cap->peer_operclass_len);
10921 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10922 peer_cap->peer_operclass[i] =
10923 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010924 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010925 __func__, i, peer_cap->peer_operclass[i]);
10926 }
10927
10928 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10929 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10930 peer_cap->pref_offchan_bw =
10931 peerStateParams->peerCap.prefOffChanBandwidth;
10932
Govind Singhb53420c2016-03-09 14:32:57 +053010933 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010934 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10935 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10936 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10937 " %d, pref_offchan_bw: %d",
10938 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10939 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10940 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10941 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10942 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10943
10944 /* next fill variable size array of peer chan info */
10945 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10946 WMITLV_SET_HDR(buf_ptr,
10947 WMITLV_TAG_ARRAY_STRUC,
10948 sizeof(wmi_channel) *
10949 peerStateParams->peerCap.peerChanLen);
10950 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10951
10952 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10953 WMITLV_SET_HDR(&chan_info->tlv_header,
10954 WMITLV_TAG_STRUC_wmi_channel,
10955 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10956 chan_info->mhz = ch_mhz[i];
10957 chan_info->band_center_freq1 = chan_info->mhz;
10958 chan_info->band_center_freq2 = 0;
10959
Govind Singhb53420c2016-03-09 14:32:57 +053010960 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010961
10962 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10963 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010964 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010965 peerStateParams->peerCap.peerChan[i].chanId,
10966 peerStateParams->peerCap.peerChan[i].dfsSet);
10967 }
10968
10969 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10970 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10971 else
10972 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10973
10974 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10975 peerStateParams->peerCap.
10976 peerChan[i].pwr);
10977
10978 WMI_SET_CHANNEL_REG_POWER(chan_info,
10979 peerStateParams->peerCap.peerChan[i].
10980 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010981 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010982 peerStateParams->peerCap.peerChan[i].pwr);
10983
10984 chan_info++;
10985 }
10986
10987 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10988 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010989 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010990 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010991 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010992 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010993 }
10994
10995
Govind Singhb53420c2016-03-09 14:32:57 +053010996 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010997}
10998
10999/*
Govind Singh20c5dac2016-03-07 15:33:31 +053011000 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
11001 * @wmi_handle: Pointer to WMi handle
11002 * @ie_data: Pointer for ie data
11003 *
11004 * This function sends IE information to firmware
11005 *
Govind Singhb53420c2016-03-09 14:32:57 +053011006 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011007 *
11008 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011009static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011010 struct vdev_ie_info_param *ie_info)
11011{
11012 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11013 wmi_buf_t buf;
11014 uint8_t *buf_ptr;
11015 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011016 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011017
11018
11019 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11020 /* Allocate memory for the WMI command */
11021 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11022
11023 buf = wmi_buf_alloc(wmi_handle, len);
11024 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011025 WMI_LOGE(FL("wmi_buf_alloc failed"));
11026 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011027 }
11028
11029 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011030 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011031
11032 /* Populate the WMI command */
11033 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11034
11035 WMITLV_SET_HDR(&cmd->tlv_header,
11036 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11037 WMITLV_GET_STRUCT_TLVLEN(
11038 wmi_vdev_set_ie_cmd_fixed_param));
11039 cmd->vdev_id = ie_info->vdev_id;
11040 cmd->ie_id = ie_info->ie_id;
11041 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011042 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011043
Govind Singhb53420c2016-03-09 14:32:57 +053011044 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011045 ie_info->length, ie_info->vdev_id);
11046
11047 buf_ptr += sizeof(*cmd);
11048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11049 buf_ptr += WMI_TLV_HDR_SIZE;
11050
Govind Singhb53420c2016-03-09 14:32:57 +053011051 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011052
11053 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11054 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011055 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011056 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011057 wmi_buf_free(buf);
11058 }
11059
11060 return ret;
11061}
11062
Sathish Kumar497bef42017-03-01 14:02:36 +053011063/**
11064 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11065 *
11066 * @param wmi_handle : handle to WMI.
11067 * @param param : pointer to antenna param
11068 *
11069 * This function sends smart antenna enable command to FW
11070 *
11071 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11072 */
11073static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11074 struct smart_ant_enable_params *param)
11075{
11076 /* Send WMI COMMAND to Enable */
11077 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11078 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11079 wmi_buf_t buf;
11080 uint8_t *buf_ptr;
11081 int len = 0;
11082 QDF_STATUS ret;
11083 int loop = 0;
11084
11085 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11086 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11087 buf = wmi_buf_alloc(wmi_handle, len);
11088
11089 if (!buf) {
11090 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11091 return QDF_STATUS_E_NOMEM;
11092 }
11093
11094 buf_ptr = wmi_buf_data(buf);
11095 qdf_mem_zero(buf_ptr, len);
11096 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11097
11098 WMITLV_SET_HDR(&cmd->tlv_header,
11099 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11100 WMITLV_GET_STRUCT_TLVLEN(
11101 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11102
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011103 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11104 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011105 cmd->enable = param->enable;
11106 cmd->mode = param->mode;
11107 cmd->rx_antenna = param->rx_antenna;
11108 cmd->tx_default_antenna = param->rx_antenna;
11109
11110 /* TLV indicating array of structures to follow */
11111 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11112 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11113 WMI_HAL_MAX_SANTENNA *
11114 sizeof(wmi_pdev_smart_ant_gpio_handle));
11115
11116 buf_ptr += WMI_TLV_HDR_SIZE;
11117 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11118
11119 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11120 WMITLV_SET_HDR(&gpio_param->tlv_header,
11121 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11122 WMITLV_GET_STRUCT_TLVLEN(
11123 wmi_pdev_smart_ant_gpio_handle));
11124 if (param->mode == SMART_ANT_MODE_SERIAL) {
11125 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11126 gpio_param->gpio_pin = param->gpio_pin[loop];
11127 gpio_param->gpio_func = param->gpio_func[loop];
11128 } else {
11129 gpio_param->gpio_pin = 0;
11130 gpio_param->gpio_func = 0;
11131 }
11132 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11133 gpio_param->gpio_pin = param->gpio_pin[loop];
11134 gpio_param->gpio_func = param->gpio_func[loop];
11135 }
11136 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011137 gpio_param->pdev_id =
11138 wmi_handle->ops->convert_pdev_id_host_to_target(
11139 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011140 gpio_param++;
11141 }
11142
11143 ret = wmi_unified_cmd_send(wmi_handle,
11144 buf,
11145 len,
11146 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11147
11148 if (ret != 0) {
11149 WMI_LOGE(" %s :WMI Failed\n", __func__);
11150 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11151 cmd->enable,
11152 cmd->mode,
11153 cmd->rx_antenna,
11154 param->gpio_pin[0], param->gpio_pin[1],
11155 param->gpio_pin[2], param->gpio_pin[3],
11156 param->gpio_func[0], param->gpio_func[1],
11157 param->gpio_func[2], param->gpio_func[3],
11158 ret);
11159 wmi_buf_free(buf);
11160 }
11161
11162 return ret;
11163}
11164
11165/**
11166 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11167 *
11168 * @param wmi_handle : handle to WMI.
11169 * @param param : pointer to rx antenna param
11170 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11171 */
11172static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11173 struct smart_ant_rx_ant_params *param)
11174{
11175 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11176 wmi_buf_t buf;
11177 uint8_t *buf_ptr;
11178 uint32_t len;
11179 QDF_STATUS ret;
11180
11181 len = sizeof(*cmd);
11182 buf = wmi_buf_alloc(wmi_handle, len);
11183 WMI_LOGD("%s:\n", __func__);
11184 if (!buf) {
11185 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11186 return QDF_STATUS_E_NOMEM;
11187 }
11188
11189 buf_ptr = wmi_buf_data(buf);
11190 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11191 WMITLV_SET_HDR(&cmd->tlv_header,
11192 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11193 WMITLV_GET_STRUCT_TLVLEN(
11194 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11195 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011196 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11197 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011198
11199 ret = wmi_unified_cmd_send(wmi_handle,
11200 buf,
11201 len,
11202 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11203
11204 if (ret != 0) {
11205 WMI_LOGE(" %s :WMI Failed\n", __func__);
11206 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11207 __func__,
11208 cmd->rx_antenna,
11209 ret);
11210 wmi_buf_free(buf);
11211 }
11212
11213 return ret;
11214}
11215
11216/**
11217 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11218 * @wmi_handle: wmi handle
11219 * @param: pointer to hold ctl table param
11220 *
11221 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11222 */
11223static QDF_STATUS
11224send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11225 struct ctl_table_params *param)
11226{
11227 uint16_t len, ctl_tlv_len;
11228 uint8_t *buf_ptr;
11229 wmi_buf_t buf;
11230 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11231 uint32_t *ctl_array;
11232
11233 if (!param->ctl_array)
11234 return QDF_STATUS_E_FAILURE;
11235
Sathish Kumar497bef42017-03-01 14:02:36 +053011236 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053011237 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053011238 len = sizeof(*cmd) + ctl_tlv_len;
11239
11240 buf = wmi_buf_alloc(wmi_handle, len);
11241 if (!buf) {
11242 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11243 return QDF_STATUS_E_FAILURE;
11244 }
11245
11246 buf_ptr = wmi_buf_data(buf);
11247 qdf_mem_zero(buf_ptr, len);
11248
11249 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11250
11251 WMITLV_SET_HDR(&cmd->tlv_header,
11252 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11253 WMITLV_GET_STRUCT_TLVLEN(
11254 wmi_pdev_set_ctl_table_cmd_fixed_param));
11255 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011256 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11257 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011258
11259 buf_ptr += sizeof(*cmd);
11260 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11261 (cmd->ctl_len));
11262 buf_ptr += WMI_TLV_HDR_SIZE;
11263 ctl_array = (uint32_t *)buf_ptr;
11264
11265 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11266 sizeof(param->ctl_band));
11267 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11268 param->ctl_cmd_len -
11269 sizeof(param->ctl_band));
11270
11271 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11272 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11273 WMI_LOGE("%s:Failed to send command\n", __func__);
11274 wmi_buf_free(buf);
11275 return QDF_STATUS_E_FAILURE;
11276 }
11277
11278 return QDF_STATUS_SUCCESS;
11279}
11280
11281/**
11282 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11283 * @wmi_handle: wmi handle
11284 * @param: pointer to hold mimogain table param
11285 *
11286 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11287 */
11288static QDF_STATUS
11289send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11290 struct mimogain_table_params *param)
11291{
11292 uint16_t len, table_tlv_len;
11293 wmi_buf_t buf;
11294 uint8_t *buf_ptr;
11295 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11296 uint32_t *gain_table;
11297
11298 if (!param->array_gain)
11299 return QDF_STATUS_E_FAILURE;
11300
11301 /* len must be multiple of a single array gain table */
11302 if (param->tbl_len %
11303 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11304 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11305 WMI_LOGE("Array gain table len not correct\n");
11306 return QDF_STATUS_E_FAILURE;
11307 }
11308
11309 table_tlv_len = WMI_TLV_HDR_SIZE +
11310 roundup(param->tbl_len, sizeof(uint32_t));
11311 len = sizeof(*cmd) + table_tlv_len;
11312
11313 buf = wmi_buf_alloc(wmi_handle, len);
11314 if (!buf) {
11315 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11316 return QDF_STATUS_E_FAILURE;
11317 }
11318
11319 buf_ptr = wmi_buf_data(buf);
11320 qdf_mem_zero(buf_ptr, len);
11321
11322 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11323
11324 WMITLV_SET_HDR(&cmd->tlv_header,
11325 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11326 WMITLV_GET_STRUCT_TLVLEN(
11327 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11328
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011329 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11330 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011331 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11332 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11333 param->multichain_gain_bypass);
11334
11335 buf_ptr += sizeof(*cmd);
11336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11337 (param->tbl_len));
11338 buf_ptr += WMI_TLV_HDR_SIZE;
11339 gain_table = (uint32_t *)buf_ptr;
11340
11341 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11342 param->array_gain,
11343 param->tbl_len);
11344
11345 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11346 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11347 return QDF_STATUS_E_FAILURE;
11348 }
11349
11350 return QDF_STATUS_SUCCESS;
11351}
11352
11353/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011354 * enum packet_power_tlv_flags: target defined
11355 * packet power rate flags for TLV
11356 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11357 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11358 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11359 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11360 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11361 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11362 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11363 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11364 * @WMI_TLV_FLAG_STBC: STBC is set
11365 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11366 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11367 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11368 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11369 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11370 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11371 * @WMI_TLV_FLAG_LDPC: LDPC is set
11372 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11373 * @WMI_TLV_FLAG_SU: SU Data
11374 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11375 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11376 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11377 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11378 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11379 *
11380 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11381 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11382 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11383 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11384 */
11385enum packet_power_tlv_flags {
11386 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11387 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11388 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11389 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11390 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11391 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11392 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11393 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11394 WMI_TLV_FLAG_STBC = 0x00000100,
11395 WMI_TLV_FLAG_40MHZ = 0x00000200,
11396 WMI_TLV_FLAG_80MHZ = 0x00000300,
11397 WMI_TLV_FLAG_160MHZ = 0x00000400,
11398 WMI_TLV_FLAG_TXBF = 0x00000800,
11399 WMI_TLV_FLAG_RTSENA = 0x00001000,
11400 WMI_TLV_FLAG_CTSENA = 0x00002000,
11401 WMI_TLV_FLAG_LDPC = 0x00004000,
11402 WMI_TLV_FLAG_SGI = 0x00008000,
11403 WMI_TLV_FLAG_SU = 0x00100000,
11404 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11405 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11406 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11407 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11408 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11409
11410 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11411 WMI_TLV_FLAG_BW_MASK = 0x3,
11412 WMI_TLV_FLAG_BW_SHIFT = 9,
11413 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11414 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11415};
11416
11417/**
11418 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11419 * to FW understandable format
11420 * @param: pointer to hold packet power info param
11421 *
11422 * @return FW understandable 32 bit rate flags
11423 */
11424static uint32_t
11425convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11426{
11427 uint32_t rateflags = 0;
11428
11429 if (param->chainmask)
11430 rateflags |=
11431 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11432 if (param->chan_width)
11433 rateflags |=
11434 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11435 << WMI_TLV_FLAG_BW_SHIFT);
11436 if (param->su_mu_ofdma)
11437 rateflags |=
11438 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11439 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11440 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11441 rateflags |= WMI_TLV_FLAG_STBC;
11442 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11443 rateflags |= WMI_TLV_FLAG_LDPC;
11444 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11445 rateflags |= WMI_TLV_FLAG_TXBF;
11446 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11447 rateflags |= WMI_TLV_FLAG_RTSENA;
11448 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11449 rateflags |= WMI_TLV_FLAG_CTSENA;
11450 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11451 rateflags |= WMI_TLV_FLAG_SGI;
11452
11453 return rateflags;
11454}
11455
11456/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011457 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11458 * info to fw
11459 * @wmi_handle: wmi handle
11460 * @param: pointer to hold packet power info param
11461 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011462 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011463 */
11464static QDF_STATUS
11465send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11466 struct packet_power_info_params *param)
11467{
11468 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11469 wmi_buf_t wmibuf;
11470 uint8_t *buf_ptr;
11471 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11472
11473 wmibuf = wmi_buf_alloc(wmi_handle, len);
11474 if (wmibuf == NULL)
11475 return QDF_STATUS_E_NOMEM;
11476
11477 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11478
11479 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11480 WMITLV_SET_HDR(&cmd->tlv_header,
11481 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11482 WMITLV_GET_STRUCT_TLVLEN(
11483 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011484 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11485 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011486 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011487 cmd->nss = param->nss;
11488 cmd->preamble = param->preamble;
11489 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011490
11491 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11492 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11493 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11494 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11495
Sathish Kumar497bef42017-03-01 14:02:36 +053011496 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11497 WMI_PDEV_GET_TPC_CMDID)) {
11498 WMI_LOGE(FL("Failed to get tpc command\n"));
11499 wmi_buf_free(wmibuf);
11500 return QDF_STATUS_E_FAILURE;
11501 }
11502
11503 return QDF_STATUS_SUCCESS;
11504}
11505
11506/**
11507 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11508 * @wmi_handle: wmi handle
11509 * @param: pointer to hold config ratemask params
11510 *
11511 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11512 */
11513static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11514 struct config_ratemask_params *param)
11515{
11516 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11517 wmi_buf_t buf;
11518 int32_t len = sizeof(*cmd);
11519
11520 buf = wmi_buf_alloc(wmi_handle, len);
11521 if (!buf) {
11522 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11523 return QDF_STATUS_E_FAILURE;
11524 }
11525 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11526 WMITLV_SET_HDR(&cmd->tlv_header,
11527 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11528 WMITLV_GET_STRUCT_TLVLEN(
11529 wmi_vdev_config_ratemask_cmd_fixed_param));
11530 cmd->vdev_id = param->vdev_id;
11531 cmd->type = param->type;
11532 cmd->mask_lower32 = param->lower32;
11533 cmd->mask_higher32 = param->higher32;
11534 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11535 param->vdev_id, param->type, param->lower32, param->higher32);
11536
11537 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11538 WMI_VDEV_RATEMASK_CMDID)) {
11539 WMI_LOGE("Seting vdev ratemask failed\n");
11540 wmi_buf_free(buf);
11541 return QDF_STATUS_E_FAILURE;
11542 }
11543
11544 return QDF_STATUS_SUCCESS;
11545}
11546
11547/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011548 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11549 * @param: param sent from the host side
11550 * @cmd: param to be sent to the fw side
11551 */
11552static inline void copy_custom_aggr_bitmap(
11553 struct set_custom_aggr_size_params *param,
11554 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11555{
11556 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11557 param->ac);
11558 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11559 param->aggr_type);
11560 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11561 param->tx_aggr_size_disable);
11562 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11563 param->rx_aggr_size_disable);
11564 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11565 param->tx_ac_enable);
11566}
11567
11568/**
11569 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11570 * @wmi_handle: wmi handle
11571 * @param: pointer to hold custom aggr size params
11572 *
11573 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11574 */
11575static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11576 wmi_unified_t wmi_handle,
11577 struct set_custom_aggr_size_params *param)
11578{
11579 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11580 wmi_buf_t buf;
11581 int32_t len = sizeof(*cmd);
11582
11583 buf = wmi_buf_alloc(wmi_handle, len);
11584 if (!buf) {
11585 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11586 return QDF_STATUS_E_FAILURE;
11587 }
11588 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11589 wmi_buf_data(buf);
11590 WMITLV_SET_HDR(&cmd->tlv_header,
11591 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11592 WMITLV_GET_STRUCT_TLVLEN(
11593 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11594 cmd->vdev_id = param->vdev_id;
11595 cmd->tx_aggr_size = param->tx_aggr_size;
11596 cmd->rx_aggr_size = param->rx_aggr_size;
11597 copy_custom_aggr_bitmap(param, cmd);
11598
11599 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11600 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11601 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11602 "tx_ac_enable=0x%X\n",
11603 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11604 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11605 param->rx_aggr_size_disable, param->tx_ac_enable);
11606
11607 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11608 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11609 WMI_LOGE("Seting custom aggregation size failed\n");
11610 wmi_buf_free(buf);
11611 return QDF_STATUS_E_FAILURE;
11612 }
11613
11614 return QDF_STATUS_SUCCESS;
11615}
11616
11617/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011618 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11619 * @param wmi_handle : handle to WMI.
11620 * @param param : pointer to tx antenna param
11621 *
11622 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11623 */
11624
11625static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11626 struct set_qdepth_thresh_params *param)
11627{
11628 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11629 wmi_msduq_qdepth_thresh_update *cmd_update;
11630 wmi_buf_t buf;
11631 int32_t len = 0;
11632 int i;
11633 uint8_t *buf_ptr;
11634 QDF_STATUS ret;
11635
11636 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11637 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11638 return QDF_STATUS_E_INVAL;
11639 }
11640
11641 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11642 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11643 param->num_of_msduq_updates);
11644 buf = wmi_buf_alloc(wmi_handle, len);
11645
11646 if (!buf) {
11647 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11648 return QDF_STATUS_E_NOMEM;
11649 }
11650
11651 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11652 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11653 buf_ptr;
11654
11655 WMITLV_SET_HDR(&cmd->tlv_header,
11656 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11657 , WMITLV_GET_STRUCT_TLVLEN(
11658 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11659
11660 cmd->pdev_id =
11661 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11662 cmd->vdev_id = param->vdev_id;
11663 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11664 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11665
11666 buf_ptr += sizeof(
11667 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11669 param->num_of_msduq_updates *
11670 sizeof(wmi_msduq_qdepth_thresh_update));
11671 buf_ptr += WMI_TLV_HDR_SIZE;
11672 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11673
11674 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11675 WMITLV_SET_HDR(&cmd_update->tlv_header,
11676 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11677 WMITLV_GET_STRUCT_TLVLEN(
11678 wmi_msduq_qdepth_thresh_update));
11679 cmd_update->tid_num = param->update_params[i].tid_num;
11680 cmd_update->msduq_update_mask =
11681 param->update_params[i].msduq_update_mask;
11682 cmd_update->qdepth_thresh_value =
11683 param->update_params[i].qdepth_thresh_value;
11684 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11685 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11686 " update mask=0x%X thresh val=0x%X\n",
11687 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11688 cmd->peer_mac_address.mac_addr31to0,
11689 cmd->peer_mac_address.mac_addr47to32,
11690 cmd_update->msduq_update_mask,
11691 cmd_update->qdepth_thresh_value);
11692 cmd_update++;
11693 }
11694
11695 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11696 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11697
11698 if (ret != 0) {
11699 WMI_LOGE(" %s :WMI Failed\n", __func__);
11700 wmi_buf_free(buf);
11701 }
11702
11703 return ret;
11704}
11705
11706/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011707 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11708 * @wmi_handle: wmi handle
11709 * @param: pointer to hold vap dscp tid map param
11710 *
11711 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11712 */
11713static QDF_STATUS
11714send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11715 struct vap_dscp_tid_map_params *param)
11716{
11717 wmi_buf_t buf;
11718 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11719 int32_t len = sizeof(*cmd);
11720
11721 buf = wmi_buf_alloc(wmi_handle, len);
11722 if (!buf) {
11723 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11724 return QDF_STATUS_E_FAILURE;
11725 }
11726
11727 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11728 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011729 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011730
11731 cmd->vdev_id = param->vdev_id;
11732 cmd->enable_override = 0;
11733
11734 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11735 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11736 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11737 WMI_LOGE("Failed to set dscp cmd\n");
11738 wmi_buf_free(buf);
11739 return QDF_STATUS_E_FAILURE;
11740 }
11741
11742 return QDF_STATUS_SUCCESS;
11743}
11744
11745/**
11746 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11747 * @wmi_handle: wmi handle
11748 * @macaddr: vdev mac address
11749 * @param: pointer to hold neigbour rx param
11750 *
11751 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11752 */
11753static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11754 uint8_t macaddr[IEEE80211_ADDR_LEN],
11755 struct set_neighbour_rx_params *param)
11756{
11757 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11758 wmi_buf_t buf;
11759 int32_t len = sizeof(*cmd);
11760
11761 buf = wmi_buf_alloc(wmi_handle, len);
11762 if (!buf) {
11763 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11764 return QDF_STATUS_E_FAILURE;
11765 }
11766 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11767 WMITLV_SET_HDR(&cmd->tlv_header,
11768 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11769 WMITLV_GET_STRUCT_TLVLEN(
11770 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11771 cmd->vdev_id = param->vdev_id;
11772 cmd->bssid_idx = param->idx;
11773 cmd->action = param->action;
11774 cmd->type = param->type;
11775 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11776 cmd->flag = 0;
11777
11778 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11779 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11780 WMI_LOGE("Failed to set neighbour rx param\n");
11781 wmi_buf_free(buf);
11782 return QDF_STATUS_E_FAILURE;
11783 }
11784
11785 return QDF_STATUS_SUCCESS;
11786}
11787
11788/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011789 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011790 * @param wmi_handle : handle to WMI.
11791 * @param macaddr : vdev mac address
11792 * @param param : pointer to tx antenna param
11793 *
11794 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11795 */
11796static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11797 uint8_t macaddr[IEEE80211_ADDR_LEN],
11798 struct smart_ant_tx_ant_params *param)
11799{
11800 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11801 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11802 wmi_buf_t buf;
11803 int32_t len = 0;
11804 int i;
11805 uint8_t *buf_ptr;
11806 QDF_STATUS ret;
11807
11808 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11809 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11810 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11811 buf = wmi_buf_alloc(wmi_handle, len);
11812
11813 if (!buf) {
11814 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11815 return QDF_STATUS_E_NOMEM;
11816 }
11817
11818 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11819 qdf_mem_zero(buf_ptr, len);
11820 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11821
11822 WMITLV_SET_HDR(&cmd->tlv_header,
11823 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11824 WMITLV_GET_STRUCT_TLVLEN(
11825 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11826
11827 cmd->vdev_id = param->vdev_id;
11828 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11829
11830 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11831 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11832 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11833 buf_ptr += WMI_TLV_HDR_SIZE;
11834 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11835
11836 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11837 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11838 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11839 WMITLV_GET_STRUCT_TLVLEN(
11840 wmi_peer_smart_ant_set_tx_antenna_series));
11841 ant_tx_series->antenna_series = param->antenna_array[i];
11842 ant_tx_series++;
11843 }
11844
11845 ret = wmi_unified_cmd_send(wmi_handle,
11846 buf,
11847 len,
11848 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11849
11850 if (ret != 0) {
11851 WMI_LOGE(" %s :WMI Failed\n", __func__);
11852 wmi_buf_free(buf);
11853 }
11854
11855 return ret;
11856}
11857
Sathish Kumar02c3b542017-02-22 17:24:45 +053011858/**
11859 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11860 * @wmi_handle: wmi handle
11861 * @param: pointer to hold ant switch tbl param
11862 *
11863 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11864 */
11865static QDF_STATUS
11866send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11867 struct ant_switch_tbl_params *param)
11868{
11869 uint8_t len;
11870 wmi_buf_t buf;
11871 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11872 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11873 uint8_t *buf_ptr;
11874
11875 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11876 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11877 buf = wmi_buf_alloc(wmi_handle, len);
11878
11879 if (!buf) {
11880 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11881 return QDF_STATUS_E_NOMEM;
11882 }
11883
11884 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11885 qdf_mem_zero(buf_ptr, len);
11886 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11887
11888 WMITLV_SET_HDR(&cmd->tlv_header,
11889 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11890 WMITLV_GET_STRUCT_TLVLEN(
11891 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11892
11893 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11894 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011895 cmd->mac_id =
11896 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011897
11898 /* TLV indicating array of structures to follow */
11899 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11900 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11901 sizeof(wmi_pdev_set_ant_ctrl_chain));
11902 buf_ptr += WMI_TLV_HDR_SIZE;
11903 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11904
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011905 ctrl_chain->pdev_id =
11906 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011907 ctrl_chain->antCtrlChain = param->antCtrlChain;
11908
11909 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11910 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11911 wmi_buf_free(buf);
11912 return QDF_STATUS_E_FAILURE;
11913 }
11914
11915 return QDF_STATUS_SUCCESS;
11916}
11917
11918/**
11919 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11920 * training information function
11921 * @param wmi_handle : handle to WMI.
11922 * @macaddr : vdev mac address
11923 * @param param : pointer to tx antenna param
11924 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11925 */
11926static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11927 wmi_unified_t wmi_handle,
11928 uint8_t macaddr[IEEE80211_ADDR_LEN],
11929 struct smart_ant_training_info_params *param)
11930{
11931 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11932 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11933 wmi_buf_t buf;
11934 uint8_t *buf_ptr;
11935 int32_t len = 0;
11936 QDF_STATUS ret;
11937 int loop;
11938
11939 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11940 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11941 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11942 buf = wmi_buf_alloc(wmi_handle, len);
11943
11944 if (!buf) {
11945 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11946 return QDF_STATUS_E_NOMEM;
11947 }
11948
11949 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11950 qdf_mem_zero(buf_ptr, len);
11951 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11952
11953 WMITLV_SET_HDR(&cmd->tlv_header,
11954 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11955 WMITLV_GET_STRUCT_TLVLEN(
11956 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11957
11958 cmd->vdev_id = param->vdev_id;
11959 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11960 cmd->num_pkts = param->numpkts;
11961
11962 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11963 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11964 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11965 WMI_SMART_ANT_MAX_RATE_SERIES);
11966
11967 buf_ptr += WMI_TLV_HDR_SIZE;
11968 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11969
11970 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11971 WMITLV_SET_HDR(&train_param->tlv_header,
11972 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11973 WMITLV_GET_STRUCT_TLVLEN(
11974 wmi_peer_smart_ant_set_train_antenna_param));
11975 train_param->train_rate_series = param->rate_array[loop];
11976 train_param->train_antenna_series = param->antenna_array[loop];
11977 train_param->rc_flags = 0;
11978 WMI_LOGI(FL("Series number:%d\n"), loop);
11979 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11980 train_param->train_rate_series,
11981 train_param->train_antenna_series);
11982 train_param++;
11983 }
11984
11985 ret = wmi_unified_cmd_send(wmi_handle,
11986 buf,
11987 len,
11988 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11989
11990 if (ret != 0) {
11991 WMI_LOGE(" %s :WMI Failed\n", __func__);
11992 wmi_buf_free(buf);
11993 return QDF_STATUS_E_FAILURE;
11994 }
11995
11996 return ret;
11997}
11998
11999/**
12000 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
12001 * configuration function
12002 * @param wmi_handle : handle to WMI.
12003 * @macaddr : vdev mad address
12004 * @param param : pointer to tx antenna param
12005 *
12006 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12007 */
12008static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12009 wmi_unified_t wmi_handle,
12010 uint8_t macaddr[IEEE80211_ADDR_LEN],
12011 struct smart_ant_node_config_params *param)
12012{
12013 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12014 wmi_buf_t buf;
12015 uint8_t *buf_ptr;
12016 int32_t len = 0, args_tlv_len;
12017 int ret;
12018 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053012019 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012020
Vivekc5823092018-03-22 23:27:21 +053012021 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012022 len = sizeof(*cmd) + args_tlv_len;
12023
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070012024 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053012025 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12026 __func__, param->args_count);
12027 return QDF_STATUS_E_FAILURE;
12028 }
12029
12030 buf = wmi_buf_alloc(wmi_handle, len);
12031 if (!buf) {
12032 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12033 return QDF_STATUS_E_NOMEM;
12034 }
12035
12036 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12037 wmi_buf_data(buf);
12038 buf_ptr = (uint8_t *)cmd;
12039 WMITLV_SET_HDR(&cmd->tlv_header,
12040 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12041 WMITLV_GET_STRUCT_TLVLEN(
12042 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12043 cmd->vdev_id = param->vdev_id;
12044 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12045 cmd->cmd_id = param->cmd_id;
12046 cmd->args_count = param->args_count;
12047 buf_ptr += sizeof(
12048 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12049 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053012050 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012051 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053012052 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012053
12054 for (i = 0; i < param->args_count; i++) {
12055 node_config_args[i] = param->args_arr[i];
12056 WMI_LOGI("%d", param->args_arr[i]);
12057 }
12058
12059 ret = wmi_unified_cmd_send(wmi_handle,
12060 buf,
12061 len,
12062 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12063
12064 if (ret != 0) {
12065 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12066 __func__, param->cmd_id, macaddr[0],
12067 macaddr[1], macaddr[2], macaddr[3],
12068 macaddr[4], macaddr[5], ret);
12069 wmi_buf_free(buf);
12070 }
12071
12072 return ret;
12073}
12074
12075/**
12076 * send_set_atf_cmd_tlv() - send set atf command to fw
12077 * @wmi_handle: wmi handle
12078 * @param: pointer to set atf param
12079 *
12080 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12081 */
12082static QDF_STATUS
12083send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12084 struct set_atf_params *param)
12085{
12086 wmi_atf_peer_info *peer_info;
12087 wmi_peer_atf_request_fixed_param *cmd;
12088 wmi_buf_t buf;
12089 uint8_t *buf_ptr;
12090 int i;
12091 int32_t len = 0;
12092 QDF_STATUS retval;
12093
12094 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12095 len += param->num_peers * sizeof(wmi_atf_peer_info);
12096 buf = wmi_buf_alloc(wmi_handle, len);
12097 if (!buf) {
12098 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12099 return QDF_STATUS_E_FAILURE;
12100 }
12101 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12102 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12103 WMITLV_SET_HDR(&cmd->tlv_header,
12104 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12105 WMITLV_GET_STRUCT_TLVLEN(
12106 wmi_peer_atf_request_fixed_param));
12107 cmd->num_peers = param->num_peers;
12108
12109 buf_ptr += sizeof(*cmd);
12110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12111 sizeof(wmi_atf_peer_info) *
12112 cmd->num_peers);
12113 buf_ptr += WMI_TLV_HDR_SIZE;
12114 peer_info = (wmi_atf_peer_info *)buf_ptr;
12115
12116 for (i = 0; i < cmd->num_peers; i++) {
12117 WMITLV_SET_HDR(&peer_info->tlv_header,
12118 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12119 WMITLV_GET_STRUCT_TLVLEN(
12120 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012121 qdf_mem_copy(&(peer_info->peer_macaddr),
12122 &(param->peer_info[i].peer_macaddr),
12123 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012124 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012125 peer_info->vdev_id = param->peer_info[i].vdev_id;
12126 peer_info->pdev_id =
12127 wmi_handle->ops->convert_pdev_id_host_to_target(
12128 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012129 /*
12130 * TLV definition for peer atf request fixed param combines
12131 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12132 * stats and atf extension stats as two different
12133 * implementations.
12134 * Need to discuss with FW on this.
12135 *
12136 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12137 * peer_info->atf_units_reserved =
12138 * param->peer_ext_info[i].atf_index_reserved;
12139 */
12140 peer_info++;
12141 }
12142
12143 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12144 WMI_PEER_ATF_REQUEST_CMDID);
12145
12146 if (retval != QDF_STATUS_SUCCESS) {
12147 WMI_LOGE("%s : WMI Failed\n", __func__);
12148 wmi_buf_free(buf);
12149 }
12150
12151 return retval;
12152}
12153
12154/**
12155 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12156 * @wmi_handle: wmi handle
12157 * @param: pointer to hold fwtest param
12158 *
12159 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12160 */
12161static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12162 struct set_fwtest_params *param)
12163{
12164 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12165 wmi_buf_t buf;
12166 int32_t len = sizeof(*cmd);
12167
12168 buf = wmi_buf_alloc(wmi_handle, len);
12169
12170 if (!buf) {
12171 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12172 return QDF_STATUS_E_FAILURE;
12173 }
12174
12175 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12176 WMITLV_SET_HDR(&cmd->tlv_header,
12177 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12178 WMITLV_GET_STRUCT_TLVLEN(
12179 wmi_fwtest_set_param_cmd_fixed_param));
12180 cmd->param_id = param->arg;
12181 cmd->param_value = param->value;
12182
12183 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12184 WMI_LOGE("Setting FW test param failed\n");
12185 wmi_buf_free(buf);
12186 return QDF_STATUS_E_FAILURE;
12187 }
12188
12189 return QDF_STATUS_SUCCESS;
12190}
12191
12192/**
12193 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12194 * @wmi_handle: wmi handle
12195 * @param: pointer to qboost params
12196 * @macaddr: vdev mac address
12197 *
12198 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12199 */
12200static QDF_STATUS
12201send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12202 uint8_t macaddr[IEEE80211_ADDR_LEN],
12203 struct set_qboost_params *param)
12204{
12205 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12206 wmi_buf_t buf;
12207 int32_t len;
12208 QDF_STATUS ret;
12209
12210 len = sizeof(*cmd);
12211
12212 buf = wmi_buf_alloc(wmi_handle, len);
12213 if (!buf) {
12214 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12215 return QDF_STATUS_E_FAILURE;
12216 }
12217
12218 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12219 WMITLV_SET_HDR(&cmd->tlv_header,
12220 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12221 WMITLV_GET_STRUCT_TLVLEN(
12222 WMI_QBOOST_CFG_CMD_fixed_param));
12223 cmd->vdev_id = param->vdev_id;
12224 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12225 cmd->qb_enable = param->value;
12226
12227 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12228 WMI_QBOOST_CFG_CMDID);
12229
12230 if (ret != 0) {
12231 WMI_LOGE("Setting qboost cmd failed\n");
12232 wmi_buf_free(buf);
12233 }
12234
12235 return ret;
12236}
12237
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012238/**
12239 * send_gpio_config_cmd_tlv() - send gpio config to fw
12240 * @wmi_handle: wmi handle
12241 * @param: pointer to hold gpio config param
12242 *
12243 * Return: 0 for success or error code
12244 */
12245static QDF_STATUS
12246send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12247 struct gpio_config_params *param)
12248{
12249 wmi_gpio_config_cmd_fixed_param *cmd;
12250 wmi_buf_t buf;
12251 int32_t len;
12252 QDF_STATUS ret;
12253
12254 len = sizeof(*cmd);
12255
12256 /* Sanity Checks */
12257 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12258 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12259 return QDF_STATUS_E_FAILURE;
12260 }
12261
12262 buf = wmi_buf_alloc(wmi_handle, len);
12263 if (!buf) {
12264 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12265 return QDF_STATUS_E_FAILURE;
12266 }
12267
12268 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12269 WMITLV_SET_HDR(&cmd->tlv_header,
12270 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12271 WMITLV_GET_STRUCT_TLVLEN(
12272 wmi_gpio_config_cmd_fixed_param));
12273 cmd->gpio_num = param->gpio_num;
12274 cmd->input = param->input;
12275 cmd->pull_type = param->pull_type;
12276 cmd->intr_mode = param->intr_mode;
12277
12278 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12279 WMI_GPIO_CONFIG_CMDID);
12280
12281 if (ret != 0) {
12282 WMI_LOGE("Sending GPIO config cmd failed\n");
12283 wmi_buf_free(buf);
12284 }
12285
12286 return ret;
12287}
12288
12289/**
12290 * send_gpio_output_cmd_tlv() - send gpio output to fw
12291 * @wmi_handle: wmi handle
12292 * @param: pointer to hold gpio output param
12293 *
12294 * Return: 0 for success or error code
12295 */
12296static QDF_STATUS
12297send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12298 struct gpio_output_params *param)
12299{
12300 wmi_gpio_output_cmd_fixed_param *cmd;
12301 wmi_buf_t buf;
12302 int32_t len;
12303 QDF_STATUS ret;
12304
12305 len = sizeof(*cmd);
12306
12307 buf = wmi_buf_alloc(wmi_handle, len);
12308 if (!buf) {
12309 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12310 return QDF_STATUS_E_FAILURE;
12311 }
12312
12313 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12314 WMITLV_SET_HDR(&cmd->tlv_header,
12315 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12316 WMITLV_GET_STRUCT_TLVLEN(
12317 wmi_gpio_output_cmd_fixed_param));
12318 cmd->gpio_num = param->gpio_num;
12319 cmd->set = param->set;
12320
12321 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12322 WMI_GPIO_OUTPUT_CMDID);
12323
12324 if (ret != 0) {
12325 WMI_LOGE("Sending GPIO output cmd failed\n");
12326 wmi_buf_free(buf);
12327 }
12328
12329 return ret;
12330
12331}
12332
12333/**
12334 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12335 *
12336 * @param wmi_handle : handle to WMI.
12337 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12338 */
12339static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12340{
12341 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12342 wmi_buf_t buf;
12343 QDF_STATUS ret;
12344 int32_t len;
12345
12346 len = sizeof(*cmd);
12347
12348 buf = wmi_buf_alloc(wmi_handle, len);
12349 if (!buf) {
12350 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12351 return QDF_STATUS_E_FAILURE;
12352 }
12353
12354 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12355 WMITLV_SET_HDR(&cmd->tlv_header,
12356 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12357 WMITLV_GET_STRUCT_TLVLEN(
12358 wmi_pdev_dfs_disable_cmd_fixed_param));
12359 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012360 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12361 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012362
12363 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12364 WMI_PDEV_DFS_DISABLE_CMDID);
12365
12366 if (ret != 0) {
12367 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12368 wmi_buf_free(buf);
12369 }
12370
12371 return ret;
12372}
12373
12374/**
12375 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12376 *
12377 * @param wmi_handle : handle to WMI.
12378 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12379 */
12380static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12381{
12382 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12383 wmi_buf_t buf;
12384 QDF_STATUS ret;
12385 int32_t len;
12386
12387 len = sizeof(*cmd);
12388
12389 buf = wmi_buf_alloc(wmi_handle, len);
12390 if (!buf) {
12391 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12392 return QDF_STATUS_E_FAILURE;
12393 }
12394
12395 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12396 WMITLV_SET_HDR(&cmd->tlv_header,
12397 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12398 WMITLV_GET_STRUCT_TLVLEN(
12399 wmi_pdev_dfs_enable_cmd_fixed_param));
12400 /* Reserved for future use */
12401 cmd->reserved0 = 0;
12402
12403 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12404 WMI_PDEV_DFS_ENABLE_CMDID);
12405
12406 if (ret != 0) {
12407 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12408 wmi_buf_free(buf);
12409 }
12410
12411 return ret;
12412}
12413
12414/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012415 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12416 * to fw
12417 * @wmi_handle: wmi handle
12418 * @param: pointer to hold periodic chan stats param
12419 *
12420 * Return: 0 for success or error code
12421 */
12422static QDF_STATUS
12423send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12424 struct periodic_chan_stats_params *param)
12425{
12426 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12427 wmi_buf_t buf;
12428 QDF_STATUS ret;
12429 int32_t len;
12430
12431 len = sizeof(*cmd);
12432
12433 buf = wmi_buf_alloc(wmi_handle, len);
12434 if (!buf) {
12435 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12436 return QDF_STATUS_E_FAILURE;
12437 }
12438
12439 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12440 wmi_buf_data(buf);
12441 WMITLV_SET_HDR(&cmd->tlv_header,
12442 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12443 WMITLV_GET_STRUCT_TLVLEN(
12444 wmi_set_periodic_channel_stats_config_fixed_param));
12445 cmd->enable = param->enable;
12446 cmd->stats_period = param->stats_period;
12447 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12448 param->pdev_id);
12449
12450 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12451 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12452
12453 if (ret != 0) {
12454 WMI_LOGE("Sending periodic chan stats config failed");
12455 wmi_buf_free(buf);
12456 }
12457
12458 return ret;
12459}
12460
12461/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012462 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12463 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012464 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012465 *
12466 * Return: 0 for success or error code
12467 */
12468static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012469send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012470{
12471 wmi_buf_t buf;
12472 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012473 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12474 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012475
nobeljf74583b2018-01-25 16:35:36 -080012476 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012477 if (buf == NULL)
12478 return QDF_STATUS_E_NOMEM;
12479
nobeljf74583b2018-01-25 16:35:36 -080012480 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12481 WMITLV_SET_HDR(&cmd->tlv_header,
12482 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12483 WMITLV_GET_STRUCT_TLVLEN
12484 (wmi_pdev_get_nfcal_power_fixed_param));
12485 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12486
12487 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012488 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12489 if (ret != 0) {
12490 WMI_LOGE("Sending get nfcal power cmd failed\n");
12491 wmi_buf_free(buf);
12492 }
12493
12494 return ret;
12495}
12496
12497/**
12498 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12499 * @wmi_handle: wmi handle
12500 * @param: pointer to ht ie param
12501 *
12502 * Return: 0 for success or error code
12503 */
12504static QDF_STATUS
12505send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12506 struct ht_ie_params *param)
12507{
12508 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12509 wmi_buf_t buf;
12510 QDF_STATUS ret;
12511 int32_t len;
12512 uint8_t *buf_ptr;
12513
12514 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12515 roundup(param->ie_len, sizeof(uint32_t));
12516
12517 buf = wmi_buf_alloc(wmi_handle, len);
12518 if (!buf) {
12519 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12520 return QDF_STATUS_E_FAILURE;
12521 }
12522
12523 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12524 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12525 WMITLV_SET_HDR(&cmd->tlv_header,
12526 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12527 WMITLV_GET_STRUCT_TLVLEN(
12528 wmi_pdev_set_ht_ie_cmd_fixed_param));
12529 cmd->reserved0 = 0;
12530 cmd->ie_len = param->ie_len;
12531 cmd->tx_streams = param->tx_streams;
12532 cmd->rx_streams = param->rx_streams;
12533
12534 buf_ptr += sizeof(*cmd);
12535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12536 buf_ptr += WMI_TLV_HDR_SIZE;
12537 if (param->ie_len)
12538 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12539 cmd->ie_len);
12540
12541 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12542 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12543
12544 if (ret != 0) {
12545 WMI_LOGE("Sending set ht ie cmd failed\n");
12546 wmi_buf_free(buf);
12547 }
12548
12549 return ret;
12550}
12551
12552/**
12553 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12554 * @wmi_handle: wmi handle
12555 * @param: pointer to vht ie param
12556 *
12557 * Return: 0 for success or error code
12558 */
12559static QDF_STATUS
12560send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12561 struct vht_ie_params *param)
12562{
12563 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12564 wmi_buf_t buf;
12565 QDF_STATUS ret;
12566 int32_t len;
12567 uint8_t *buf_ptr;
12568
12569 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12570 roundup(param->ie_len, sizeof(uint32_t));
12571
12572 buf = wmi_buf_alloc(wmi_handle, len);
12573 if (!buf) {
12574 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12575 return QDF_STATUS_E_FAILURE;
12576 }
12577
12578 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12579 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12580 WMITLV_SET_HDR(&cmd->tlv_header,
12581 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12582 WMITLV_GET_STRUCT_TLVLEN(
12583 wmi_pdev_set_vht_ie_cmd_fixed_param));
12584 cmd->reserved0 = 0;
12585 cmd->ie_len = param->ie_len;
12586 cmd->tx_streams = param->tx_streams;
12587 cmd->rx_streams = param->rx_streams;
12588
12589 buf_ptr += sizeof(*cmd);
12590 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12591 buf_ptr += WMI_TLV_HDR_SIZE;
12592 if (param->ie_len)
12593 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12594 cmd->ie_len);
12595
12596 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12597 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12598
12599 if (ret != 0) {
12600 WMI_LOGE("Sending set vht ie cmd failed\n");
12601 wmi_buf_free(buf);
12602 }
12603
12604 return ret;
12605}
12606
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012607/**
12608 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12609 * @wmi_handle: wmi handle
12610 * @param: pointer to quiet mode params
12611 *
12612 * Return: 0 for success or error code
12613 */
12614static QDF_STATUS
12615send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12616 struct set_quiet_mode_params *param)
12617{
12618 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12619 wmi_buf_t buf;
12620 QDF_STATUS ret;
12621 int32_t len;
12622
12623 len = sizeof(*quiet_cmd);
12624 buf = wmi_buf_alloc(wmi_handle, len);
12625 if (!buf) {
12626 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12627 return QDF_STATUS_E_FAILURE;
12628 }
12629
12630 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12631 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12632 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12633 WMITLV_GET_STRUCT_TLVLEN(
12634 wmi_pdev_set_quiet_cmd_fixed_param));
12635 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12636 quiet_cmd->enabled = param->enabled;
12637 quiet_cmd->period = (param->period)*(param->intval);
12638 quiet_cmd->duration = param->duration;
12639 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012640 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12641 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012642
12643 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12644 WMI_PDEV_SET_QUIET_MODE_CMDID);
12645
12646 if (ret != 0) {
12647 WMI_LOGE("Sending set quiet cmd failed\n");
12648 wmi_buf_free(buf);
12649 }
12650
12651 return ret;
12652}
12653
12654/**
12655 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12656 * @wmi_handle: wmi handle
12657 * @param: pointer to set bwf param
12658 *
12659 * Return: 0 for success or error code
12660 */
12661static QDF_STATUS
12662send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12663 struct set_bwf_params *param)
12664{
12665 wmi_bwf_peer_info *peer_info;
12666 wmi_peer_bwf_request_fixed_param *cmd;
12667 wmi_buf_t buf;
12668 QDF_STATUS retval;
12669 int32_t len;
12670 uint8_t *buf_ptr;
12671 int i;
12672
12673 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12674 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12675 buf = wmi_buf_alloc(wmi_handle, len);
12676 if (!buf) {
12677 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12678 return QDF_STATUS_E_FAILURE;
12679 }
12680 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12681 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12682 WMITLV_SET_HDR(&cmd->tlv_header,
12683 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12684 WMITLV_GET_STRUCT_TLVLEN(
12685 wmi_peer_bwf_request_fixed_param));
12686 cmd->num_peers = param->num_peers;
12687
12688 buf_ptr += sizeof(*cmd);
12689 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12690 sizeof(wmi_bwf_peer_info) *
12691 cmd->num_peers);
12692 buf_ptr += WMI_TLV_HDR_SIZE;
12693 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12694
12695 for (i = 0; i < cmd->num_peers; i++) {
12696 WMITLV_SET_HDR(&peer_info->tlv_header,
12697 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12698 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12699 peer_info->bwf_guaranteed_bandwidth =
12700 param->peer_info[i].throughput;
12701 peer_info->bwf_max_airtime =
12702 param->peer_info[i].max_airtime;
12703 peer_info->bwf_peer_priority =
12704 param->peer_info[i].priority;
12705 qdf_mem_copy(&peer_info->peer_macaddr,
12706 &param->peer_info[i].peer_macaddr,
12707 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012708 peer_info->vdev_id =
12709 param->peer_info[i].vdev_id;
12710 peer_info->pdev_id =
12711 wmi_handle->ops->convert_pdev_id_host_to_target(
12712 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012713 peer_info++;
12714 }
12715
12716 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12717 WMI_PEER_BWF_REQUEST_CMDID);
12718
12719 if (retval != QDF_STATUS_SUCCESS) {
12720 WMI_LOGE("%s : WMI Failed\n", __func__);
12721 wmi_buf_free(buf);
12722 }
12723
12724 return retval;
12725}
12726
12727/**
12728 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12729 * @wmi_handle: wmi handle
12730 * @param: pointer to hold mcast update param
12731 *
12732 * Return: 0 for success or error code
12733 */
12734static QDF_STATUS
12735send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12736 struct mcast_group_update_params *param)
12737{
12738 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12739 wmi_buf_t buf;
12740 QDF_STATUS ret;
12741 int32_t len;
12742 int offset = 0;
12743 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12744
12745 len = sizeof(*cmd);
12746 buf = wmi_buf_alloc(wmi_handle, len);
12747 if (!buf) {
12748 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12749 return QDF_STATUS_E_FAILURE;
12750 }
12751 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12752 WMITLV_SET_HDR(&cmd->tlv_header,
12753 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12754 WMITLV_GET_STRUCT_TLVLEN(
12755 wmi_peer_mcast_group_cmd_fixed_param));
12756 /* confirm the buffer is 4-byte aligned */
12757 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12758 qdf_mem_zero(cmd, sizeof(*cmd));
12759
12760 cmd->vdev_id = param->vap_id;
12761 /* construct the message assuming our endianness matches the target */
12762 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12763 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12764 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12765 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12766 if (param->is_action_delete)
12767 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12768
12769 if (param->is_mcast_addr_len)
12770 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12771
12772 if (param->is_filter_mode_snoop)
12773 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12774
12775 /* unicast address spec only applies for non-wildcard cases */
12776 if (!param->wildcard && param->ucast_mac_addr) {
12777 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12778 &cmd->ucast_mac_addr);
12779 }
Amar Singhal5593c902017-10-03 13:00:29 -070012780
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012781 if (param->mcast_ip_addr) {
12782 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12783 sizeof(cmd->mcast_ip_addr));
12784 offset = sizeof(cmd->mcast_ip_addr) -
12785 param->mcast_ip_addr_bytes;
12786 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12787 param->mcast_ip_addr,
12788 param->mcast_ip_addr_bytes);
12789 }
12790 if (!param->mask)
12791 param->mask = &dummymask[0];
12792
12793 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12794 param->mask,
12795 param->mcast_ip_addr_bytes);
12796
12797 if (param->srcs && param->nsrcs) {
12798 cmd->num_filter_addr = param->nsrcs;
12799 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12800 sizeof(cmd->filter_addr));
12801
12802 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12803 param->nsrcs * param->mcast_ip_addr_bytes);
12804 }
12805
12806 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12807 WMI_PEER_MCAST_GROUP_CMDID);
12808
12809 if (ret != QDF_STATUS_SUCCESS) {
12810 WMI_LOGE("%s : WMI Failed\n", __func__);
12811 wmi_buf_free(buf);
12812 }
12813
12814 return ret;
12815}
12816
12817/**
12818 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12819 * command to fw
12820 * @wmi_handle: wmi handle
12821 * @param: pointer to hold spectral config parameter
12822 *
12823 * Return: 0 for success or error code
12824 */
12825static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12826 struct vdev_spectral_configure_params *param)
12827{
12828 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12829 wmi_buf_t buf;
12830 QDF_STATUS ret;
12831 int32_t len;
12832
12833 len = sizeof(*cmd);
12834 buf = wmi_buf_alloc(wmi_handle, len);
12835 if (!buf) {
12836 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12837 return QDF_STATUS_E_FAILURE;
12838 }
12839
12840 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12841 WMITLV_SET_HDR(&cmd->tlv_header,
12842 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12843 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012844 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012845
12846 cmd->vdev_id = param->vdev_id;
12847 cmd->spectral_scan_count = param->count;
12848 cmd->spectral_scan_period = param->period;
12849 cmd->spectral_scan_priority = param->spectral_pri;
12850 cmd->spectral_scan_fft_size = param->fft_size;
12851 cmd->spectral_scan_gc_ena = param->gc_enable;
12852 cmd->spectral_scan_restart_ena = param->restart_enable;
12853 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12854 cmd->spectral_scan_init_delay = param->init_delay;
12855 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12856 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12857 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12858 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12859 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12860 cmd->spectral_scan_pwr_format = param->pwr_format;
12861 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12862 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012863 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012864 cmd->spectral_scan_chn_mask = param->chn_mask;
12865
12866 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12867 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12868
12869 if (ret != 0) {
12870 WMI_LOGE("Sending set quiet cmd failed\n");
12871 wmi_buf_free(buf);
12872 }
12873
12874 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12875 __func__);
12876
12877 WMI_LOGI("vdev_id = %u\n"
12878 "spectral_scan_count = %u\n"
12879 "spectral_scan_period = %u\n"
12880 "spectral_scan_priority = %u\n"
12881 "spectral_scan_fft_size = %u\n"
12882 "spectral_scan_gc_ena = %u\n"
12883 "spectral_scan_restart_ena = %u\n"
12884 "spectral_scan_noise_floor_ref = %u\n"
12885 "spectral_scan_init_delay = %u\n"
12886 "spectral_scan_nb_tone_thr = %u\n"
12887 "spectral_scan_str_bin_thr = %u\n"
12888 "spectral_scan_wb_rpt_mode = %u\n"
12889 "spectral_scan_rssi_rpt_mode = %u\n"
12890 "spectral_scan_rssi_thr = %u\n"
12891 "spectral_scan_pwr_format = %u\n"
12892 "spectral_scan_rpt_mode = %u\n"
12893 "spectral_scan_bin_scale = %u\n"
12894 "spectral_scan_dBm_adj = %u\n"
12895 "spectral_scan_chn_mask = %u\n",
12896 param->vdev_id,
12897 param->count,
12898 param->period,
12899 param->spectral_pri,
12900 param->fft_size,
12901 param->gc_enable,
12902 param->restart_enable,
12903 param->noise_floor_ref,
12904 param->init_delay,
12905 param->nb_tone_thr,
12906 param->str_bin_thr,
12907 param->wb_rpt_mode,
12908 param->rssi_rpt_mode,
12909 param->rssi_thr,
12910 param->pwr_format,
12911 param->rpt_mode,
12912 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012913 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012914 param->chn_mask);
12915 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12916
12917 return ret;
12918}
12919
12920/**
12921 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12922 * command to fw
12923 * @wmi_handle: wmi handle
12924 * @param: pointer to hold spectral enable parameter
12925 *
12926 * Return: 0 for success or error code
12927 */
12928static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12929 struct vdev_spectral_enable_params *param)
12930{
12931 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12932 wmi_buf_t buf;
12933 QDF_STATUS ret;
12934 int32_t len;
12935
12936 len = sizeof(*cmd);
12937 buf = wmi_buf_alloc(wmi_handle, len);
12938 if (!buf) {
12939 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12940 return QDF_STATUS_E_FAILURE;
12941 }
12942
12943 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12944 WMITLV_SET_HDR(&cmd->tlv_header,
12945 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12946 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012947 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012948
12949 cmd->vdev_id = param->vdev_id;
12950
12951 if (param->active_valid) {
12952 cmd->trigger_cmd = param->active ? 1 : 2;
12953 /* 1: Trigger, 2: Clear Trigger */
12954 } else {
12955 cmd->trigger_cmd = 0; /* 0: Ignore */
12956 }
12957
12958 if (param->enabled_valid) {
12959 cmd->enable_cmd = param->enabled ? 1 : 2;
12960 /* 1: Enable 2: Disable */
12961 } else {
12962 cmd->enable_cmd = 0; /* 0: Ignore */
12963 }
12964
12965 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12966 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12967
12968 if (ret != 0) {
12969 WMI_LOGE("Sending scan enable CMD failed\n");
12970 wmi_buf_free(buf);
12971 }
12972
12973 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12974
12975 WMI_LOGI("vdev_id = %u\n"
12976 "trigger_cmd = %u\n"
12977 "enable_cmd = %u\n",
12978 cmd->vdev_id,
12979 cmd->trigger_cmd,
12980 cmd->enable_cmd);
12981
12982 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12983
12984 return ret;
12985}
12986
12987/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012988 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12989 * @param wmi_handle : handle to WMI.
12990 * @param param : pointer to hold thermal mitigation param
12991 *
12992 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12993 */
12994static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12995 wmi_unified_t wmi_handle,
12996 struct thermal_mitigation_params *param)
12997{
12998 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12999 wmi_therm_throt_level_config_info *lvl_conf = NULL;
13000 wmi_buf_t buf = NULL;
13001 uint8_t *buf_ptr = NULL;
13002 int error;
13003 int32_t len;
13004 int i;
13005
13006 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13007 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13008
13009 buf = wmi_buf_alloc(wmi_handle, len);
13010 if (!buf) {
13011 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13012 return QDF_STATUS_E_NOMEM;
13013 }
13014 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13015
13016 /* init fixed params */
13017 WMITLV_SET_HDR(tt_conf,
13018 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13019 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13020
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013021 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13022 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013023 tt_conf->enable = param->enable;
13024 tt_conf->dc = param->dc;
13025 tt_conf->dc_per_event = param->dc_per_event;
13026 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13027
13028 buf_ptr = (uint8_t *) ++tt_conf;
13029 /* init TLV params */
13030 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13031 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13032
13033 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13034 for (i = 0; i < THERMAL_LEVELS; i++) {
13035 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13036 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13037 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13038 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13039 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13040 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13041 lvl_conf->prio = param->levelconf[i].priority;
13042 lvl_conf++;
13043 }
13044
13045 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13046 WMI_THERM_THROT_SET_CONF_CMDID);
13047 if (QDF_IS_STATUS_ERROR(error)) {
13048 wmi_buf_free(buf);
13049 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13050 }
13051
13052 return error;
13053}
13054
13055/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013056 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13057 * @wmi_handle: wmi handle
13058 * @param: pointer to pdev_qvit_params
13059 *
13060 * Return: 0 for success or error code
13061 */
13062static QDF_STATUS
13063send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13064 struct pdev_qvit_params *param)
13065{
13066 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013067 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013068 uint8_t *cmd;
13069 static uint8_t msgref = 1;
13070 uint8_t segnumber = 0, seginfo, numsegments;
13071 uint16_t chunk_len, total_bytes;
13072 uint8_t *bufpos;
13073 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13074
13075 bufpos = param->utf_payload;
13076 total_bytes = param->len;
13077 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13078 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13079 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13080
13081 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13082 numsegments++;
13083
13084 while (param->len) {
13085 if (param->len > MAX_WMI_QVIT_LEN)
13086 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
13087 else
13088 chunk_len = param->len;
13089
13090 buf = wmi_buf_alloc(wmi_handle,
13091 (chunk_len + sizeof(seghdrinfo) +
13092 WMI_TLV_HDR_SIZE));
13093 if (!buf) {
13094 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13095 return QDF_STATUS_E_NOMEM;
13096 }
13097
13098 cmd = (uint8_t *) wmi_buf_data(buf);
13099
13100 seghdrinfo.len = total_bytes;
13101 seghdrinfo.msgref = msgref;
13102 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13103 seghdrinfo.segmentInfo = seginfo;
13104
13105 segnumber++;
13106
13107 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13108 (chunk_len + sizeof(seghdrinfo)));
13109 cmd += WMI_TLV_HDR_SIZE;
13110 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13111 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13112
13113 ret = wmi_unified_cmd_send(wmi_handle, buf,
13114 (chunk_len + sizeof(seghdrinfo) +
13115 WMI_TLV_HDR_SIZE),
13116 WMI_PDEV_QVIT_CMDID);
13117
13118 if (ret != 0) {
13119 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13120 wmi_buf_free(buf);
13121 break;
13122 }
13123
13124 param->len -= chunk_len;
13125 bufpos += chunk_len;
13126 }
13127 msgref++;
13128
13129 return ret;
13130}
13131
13132/**
13133 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13134 * @wmi_handle: wmi handle
13135 * @param: pointer to wmm update param
13136 *
13137 * Return: 0 for success or error code
13138 */
13139static QDF_STATUS
13140send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13141 struct wmm_update_params *param)
13142{
13143 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13144 wmi_wmm_params *wmm_param;
13145 wmi_buf_t buf;
13146 QDF_STATUS ret;
13147 int32_t len;
13148 int ac = 0;
13149 struct wmi_host_wmeParams *wmep;
13150 uint8_t *buf_ptr;
13151
13152 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13153 buf = wmi_buf_alloc(wmi_handle, len);
13154 if (!buf) {
13155 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13156 return QDF_STATUS_E_FAILURE;
13157 }
13158
13159 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13160 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13161 WMITLV_SET_HDR(&cmd->tlv_header,
13162 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13163 WMITLV_GET_STRUCT_TLVLEN
13164 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13165
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013166 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013167
13168 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13169
13170 for (ac = 0; ac < WME_NUM_AC; ac++) {
13171 wmep = &param->wmep_array[ac];
13172 wmm_param = (wmi_wmm_params *)buf_ptr;
13173 WMITLV_SET_HDR(&wmm_param->tlv_header,
13174 WMITLV_TAG_STRUC_wmi_wmm_params,
13175 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13176 wmm_param->aifs = wmep->wmep_aifsn;
13177 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13178 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13179 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13180 wmm_param->acm = wmep->wmep_acm;
13181 wmm_param->no_ack = wmep->wmep_noackPolicy;
13182 buf_ptr += sizeof(wmi_wmm_params);
13183 }
13184 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13185 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13186
13187 if (ret != 0) {
13188 WMI_LOGE("Sending WMM update CMD failed\n");
13189 wmi_buf_free(buf);
13190 }
13191
13192 return ret;
13193}
13194
Sathish Kumar80f4f382017-04-24 11:36:00 +053013195/**
13196 * send_coex_config_cmd_tlv() - send coex config command to fw
13197 * @wmi_handle: wmi handle
13198 * @param: pointer to coex config param
13199 *
13200 * Return: 0 for success or error code
13201 */
13202static QDF_STATUS
13203send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13204 struct coex_config_params *param)
13205{
13206 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13207 wmi_buf_t buf;
13208 QDF_STATUS ret;
13209 int32_t len;
13210
13211 len = sizeof(*cmd);
13212 buf = wmi_buf_alloc(wmi_handle, len);
13213 if (!buf) {
13214 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13215 return QDF_STATUS_E_FAILURE;
13216 }
13217
13218 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13219 WMITLV_SET_HDR(&cmd->tlv_header,
13220 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13221 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013222 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013223
13224 cmd->vdev_id = param->vdev_id;
13225 cmd->config_type = param->config_type;
13226 cmd->config_arg1 = param->config_arg1;
13227 cmd->config_arg2 = param->config_arg2;
13228 cmd->config_arg3 = param->config_arg3;
13229 cmd->config_arg4 = param->config_arg4;
13230 cmd->config_arg5 = param->config_arg5;
13231 cmd->config_arg6 = param->config_arg6;
13232
13233 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13234 WMI_COEX_CONFIG_CMDID);
13235
13236 if (ret != 0) {
13237 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13238 wmi_buf_free(buf);
13239 }
13240
13241 return ret;
13242}
13243
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013244
13245#ifdef WLAN_SUPPORT_TWT
13246static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13247 target_resource_config *tgt_res_cfg)
13248{
13249 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
13250 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
13251}
13252#else
13253static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13254 target_resource_config *tgt_res_cfg)
13255{
13256 resource_cfg->twt_ap_pdev_count = 0;
13257 resource_cfg->twt_ap_sta_count = 0;
13258}
13259#endif
13260
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013261static
Govind Singh9ddd5162016-03-07 16:30:32 +053013262void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013263 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013264{
Govind Singhe7f2f342016-05-23 12:12:52 +053013265 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013266 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13267 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13268 resource_cfg->num_offload_reorder_buffs =
13269 tgt_res_cfg->num_offload_reorder_buffs;
13270 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13271 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13272 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13273 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13274 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13275 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13276 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13277 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13278 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13279 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13280 resource_cfg->scan_max_pending_req =
13281 tgt_res_cfg->scan_max_pending_req;
13282 resource_cfg->bmiss_offload_max_vdev =
13283 tgt_res_cfg->bmiss_offload_max_vdev;
13284 resource_cfg->roam_offload_max_vdev =
13285 tgt_res_cfg->roam_offload_max_vdev;
13286 resource_cfg->roam_offload_max_ap_profiles =
13287 tgt_res_cfg->roam_offload_max_ap_profiles;
13288 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13289 resource_cfg->num_mcast_table_elems =
13290 tgt_res_cfg->num_mcast_table_elems;
13291 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13292 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13293 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13294 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13295 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13296 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13297 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13298 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13299 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13300 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13301 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13302 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13303 resource_cfg->num_tdls_conn_table_entries =
13304 tgt_res_cfg->num_tdls_conn_table_entries;
13305 resource_cfg->beacon_tx_offload_max_vdev =
13306 tgt_res_cfg->beacon_tx_offload_max_vdev;
13307 resource_cfg->num_multicast_filter_entries =
13308 tgt_res_cfg->num_multicast_filter_entries;
13309 resource_cfg->num_wow_filters =
13310 tgt_res_cfg->num_wow_filters;
13311 resource_cfg->num_keep_alive_pattern =
13312 tgt_res_cfg->num_keep_alive_pattern;
13313 resource_cfg->keep_alive_pattern_size =
13314 tgt_res_cfg->keep_alive_pattern_size;
13315 resource_cfg->max_tdls_concurrent_sleep_sta =
13316 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13317 resource_cfg->max_tdls_concurrent_buffer_sta =
13318 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13319 resource_cfg->wmi_send_separate =
13320 tgt_res_cfg->wmi_send_separate;
13321 resource_cfg->num_ocb_vdevs =
13322 tgt_res_cfg->num_ocb_vdevs;
13323 resource_cfg->num_ocb_channels =
13324 tgt_res_cfg->num_ocb_channels;
13325 resource_cfg->num_ocb_schedules =
13326 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013327 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13328 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13329 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013330 resource_cfg->max_num_dbs_scan_duty_cycle =
13331 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013332 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080013333 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
13334 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013335
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013336 if (tgt_res_cfg->atf_config)
13337 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13338 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13339 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13340 resource_cfg->flag1, 1);
13341 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13342 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13343 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013344 if (tgt_res_cfg->cce_disable)
13345 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013346
13347 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053013348}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013349
13350/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13351 * @wmi_handle: pointer to wmi handle
13352 * @buf_ptr: pointer to current position in init command buffer
13353 * @len: pointer to length. This will be updated with current lenght of cmd
13354 * @param: point host parameters for init command
13355 *
13356 * Return: Updated pointer of buf_ptr.
13357 */
13358static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13359 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13360{
13361 uint16_t idx;
13362
13363 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13364 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13365 wmi_pdev_band_to_mac *band_to_mac;
13366
13367 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13368 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13369 sizeof(wmi_resource_config) +
13370 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13371 sizeof(wlan_host_memory_chunk)));
13372
13373 WMITLV_SET_HDR(&hw_mode->tlv_header,
13374 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13375 (WMITLV_GET_STRUCT_TLVLEN
13376 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13377
13378 hw_mode->hw_mode_index = param->hw_mode_id;
13379 hw_mode->num_band_to_mac = param->num_band_to_mac;
13380
13381 buf_ptr = (uint8_t *) (hw_mode + 1);
13382 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13383 WMI_TLV_HDR_SIZE);
13384 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13385 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13386 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13387 WMITLV_GET_STRUCT_TLVLEN
13388 (wmi_pdev_band_to_mac));
13389 band_to_mac[idx].pdev_id =
13390 wmi_handle->ops->convert_pdev_id_host_to_target(
13391 param->band_to_mac[idx].pdev_id);
13392 band_to_mac[idx].start_freq =
13393 param->band_to_mac[idx].start_freq;
13394 band_to_mac[idx].end_freq =
13395 param->band_to_mac[idx].end_freq;
13396 }
13397 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13398 (param->num_band_to_mac *
13399 sizeof(wmi_pdev_band_to_mac)) +
13400 WMI_TLV_HDR_SIZE;
13401
13402 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13403 (param->num_band_to_mac *
13404 sizeof(wmi_pdev_band_to_mac)));
13405 }
13406
13407 return buf_ptr;
13408}
13409
13410static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13411 wmi_init_cmd_fixed_param *cmd)
13412{
13413 int num_whitelist;
13414 wmi_abi_version my_vers;
13415
13416 num_whitelist = sizeof(version_whitelist) /
13417 sizeof(wmi_whitelist_version_info);
13418 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13419 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13420 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13421 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13422 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13423 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13424
13425 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13426 &my_vers,
13427 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13428 &cmd->host_abi_vers);
13429
13430 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13431 __func__,
13432 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13433 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13434 cmd->host_abi_vers.abi_version_ns_0,
13435 cmd->host_abi_vers.abi_version_ns_1,
13436 cmd->host_abi_vers.abi_version_ns_2,
13437 cmd->host_abi_vers.abi_version_ns_3);
13438
13439 /* Save version sent from host -
13440 * Will be used to check ready event
13441 */
13442 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13443 sizeof(wmi_abi_version));
13444}
13445
Sathish Kumarfd347372017-02-13 12:29:09 +053013446static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013447{
13448 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13449 wmi_service_ready_event_fixed_param *ev;
13450
13451
13452 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13453
13454 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13455 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013456 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013457
13458 /*Save fw version from service ready message */
13459 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013460 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013461 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013462
Govind Singhb53420c2016-03-09 14:32:57 +053013463 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013464}
13465
13466/**
13467 * wmi_unified_save_fw_version_cmd() - save fw version
13468 * @wmi_handle: pointer to wmi handle
13469 * @res_cfg: resource config
13470 * @num_mem_chunks: no of mem chunck
13471 * @mem_chunk: pointer to mem chunck structure
13472 *
13473 * This function sends IE information to firmware
13474 *
Govind Singhb53420c2016-03-09 14:32:57 +053013475 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013476 *
13477 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013478static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013479 void *evt_buf)
13480{
13481 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13482 wmi_ready_event_fixed_param *ev = NULL;
13483
13484 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13485 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013486 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13487 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013488 &ev->fw_abi_vers)) {
13489 /*
13490 * Error: Our host version and the given firmware version
13491 * are incompatible.
13492 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013493 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013494 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13495 __func__,
13496 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13497 abi_version_0),
13498 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13499 abi_version_0),
13500 wmi_handle->final_abi_vers.abi_version_ns_0,
13501 wmi_handle->final_abi_vers.abi_version_ns_1,
13502 wmi_handle->final_abi_vers.abi_version_ns_2,
13503 wmi_handle->final_abi_vers.abi_version_ns_3,
13504 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13505 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13506 ev->fw_abi_vers.abi_version_ns_0,
13507 ev->fw_abi_vers.abi_version_ns_1,
13508 ev->fw_abi_vers.abi_version_ns_2,
13509 ev->fw_abi_vers.abi_version_ns_3);
13510
Govind Singhb53420c2016-03-09 14:32:57 +053013511 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013512 }
Govind Singhb53420c2016-03-09 14:32:57 +053013513 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013514 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013515 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013516 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013517
Govind Singhb53420c2016-03-09 14:32:57 +053013518 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013519}
Govind Singha4836fd2016-03-07 16:45:38 +053013520
13521/**
13522 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13523 * @wmi_handle: wmi handle
13524 * @custom_addr: base mac address
13525 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013526 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013527 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013528static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013529 uint8_t *custom_addr)
13530{
13531 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13532 wmi_buf_t buf;
13533 int err;
13534
13535 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13536 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013537 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013538 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013539 }
13540
13541 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013542 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013543
13544 WMITLV_SET_HDR(&cmd->tlv_header,
13545 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13546 WMITLV_GET_STRUCT_TLVLEN
13547 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13548 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013549 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13550 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013551 err = wmi_unified_cmd_send(wmi_handle, buf,
13552 sizeof(*cmd),
13553 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13554 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013555 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013556 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013557 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013558 }
13559
13560 return 0;
13561}
13562
13563/**
13564 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13565 * @handle: wmi handle
13566 * @event: Event received from FW
13567 * @len: Length of the event
13568 *
13569 * Enables the low frequency events and disables the high frequency
13570 * events. Bit 17 indicates if the event if low/high frequency.
13571 * 1 - high frequency, 0 - low frequency
13572 *
13573 * Return: 0 on successfully enabling/disabling the events
13574 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013575static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013576 uint8_t *event,
13577 uint32_t len)
13578{
13579 uint32_t num_of_diag_events_logs;
13580 wmi_diag_event_log_config_fixed_param *cmd;
13581 wmi_buf_t buf;
13582 uint8_t *buf_ptr;
13583 uint32_t *cmd_args, *evt_args;
13584 uint32_t buf_len, i;
13585
13586 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13587 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13588
Govind Singhb53420c2016-03-09 14:32:57 +053013589 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013590
13591 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13592 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013593 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013594 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013595 }
13596 wmi_event = param_buf->fixed_param;
13597 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013598
13599 if (num_of_diag_events_logs >
13600 param_buf->num_diag_events_logs_list) {
13601 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13602 num_of_diag_events_logs,
13603 param_buf->num_diag_events_logs_list);
13604 return QDF_STATUS_E_INVAL;
13605 }
13606
Govind Singha4836fd2016-03-07 16:45:38 +053013607 evt_args = param_buf->diag_events_logs_list;
13608 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013609 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013610 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013611 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013612 }
13613
Govind Singhb53420c2016-03-09 14:32:57 +053013614 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013615 __func__, num_of_diag_events_logs);
13616
13617 /* Free any previous allocation */
13618 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013619 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013620
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013621 if (num_of_diag_events_logs >
13622 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13623 WMI_LOGE("%s: excess num of logs:%d", __func__,
13624 num_of_diag_events_logs);
13625 QDF_ASSERT(0);
13626 return QDF_STATUS_E_INVAL;
13627 }
Govind Singha4836fd2016-03-07 16:45:38 +053013628 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013629 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013630 sizeof(uint32_t));
13631 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013632 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013633 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013634 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013635 }
13636 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13637
13638 /* Prepare the send buffer */
13639 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13640 (num_of_diag_events_logs * sizeof(uint32_t));
13641
13642 buf = wmi_buf_alloc(wmi_handle, buf_len);
13643 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013644 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13645 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013646 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013647 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013648 }
13649
13650 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13651 buf_ptr = (uint8_t *) cmd;
13652
13653 WMITLV_SET_HDR(&cmd->tlv_header,
13654 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13655 WMITLV_GET_STRUCT_TLVLEN(
13656 wmi_diag_event_log_config_fixed_param));
13657
13658 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13659
13660 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13661
13662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13663 (num_of_diag_events_logs * sizeof(uint32_t)));
13664
13665 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13666
13667 /* Populate the events */
13668 for (i = 0; i < num_of_diag_events_logs; i++) {
13669 /* Low freq (0) - Enable (1) the event
13670 * High freq (1) - Disable (0) the event
13671 */
13672 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13673 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13674 /* Set the event ID */
13675 WMI_DIAG_ID_SET(cmd_args[i],
13676 WMI_DIAG_ID_GET(evt_args[i]));
13677 /* Set the type */
13678 WMI_DIAG_TYPE_SET(cmd_args[i],
13679 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013680 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013681 wmi_handle->events_logs_list[i] = evt_args[i];
13682 }
13683
13684 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13685 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013686 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013687 __func__);
13688 wmi_buf_free(buf);
13689 /* Not clearing events_logs_list, though wmi cmd failed.
13690 * Host can still have this list
13691 */
Govind Singh67922e82016-04-01 16:48:57 +053013692 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013693 }
13694
13695 return 0;
13696}
13697
13698/**
13699 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13700 * @wmi_handle: wmi handle
13701 * @start_log: Start logging related parameters
13702 *
13703 * Send the command to the FW based on which specific logging of diag
13704 * event/log id can be started/stopped
13705 *
13706 * Return: None
13707 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013708static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013709 struct wmi_wifi_start_log *start_log)
13710{
13711 wmi_diag_event_log_config_fixed_param *cmd;
13712 wmi_buf_t buf;
13713 uint8_t *buf_ptr;
13714 uint32_t len, count, log_level, i;
13715 uint32_t *cmd_args;
13716 uint32_t total_len;
13717 count = 0;
13718
13719 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013720 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013721 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013722 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013723 }
13724 /* total_len stores the number of events where BITS 17 and 18 are set.
13725 * i.e., events of high frequency (17) and for extended debugging (18)
13726 */
13727 total_len = 0;
13728 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13729 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13730 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13731 total_len++;
13732 }
13733
13734 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13735 (total_len * sizeof(uint32_t));
13736
13737 buf = wmi_buf_alloc(wmi_handle, len);
13738 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013739 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013740 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013741 }
13742 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13743 buf_ptr = (uint8_t *) cmd;
13744
13745 WMITLV_SET_HDR(&cmd->tlv_header,
13746 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13747 WMITLV_GET_STRUCT_TLVLEN(
13748 wmi_diag_event_log_config_fixed_param));
13749
13750 cmd->num_of_diag_events_logs = total_len;
13751
13752 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13753
13754 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13755 (total_len * sizeof(uint32_t)));
13756
13757 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13758
Govind Singh224a7312016-06-21 14:33:26 +053013759 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013760 log_level = 1;
13761 else
13762 log_level = 0;
13763
Govind Singhb53420c2016-03-09 14:32:57 +053013764 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013765 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13766 uint32_t val = wmi_handle->events_logs_list[i];
13767 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13768 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13769
13770 WMI_DIAG_ID_SET(cmd_args[count],
13771 WMI_DIAG_ID_GET(val));
13772 WMI_DIAG_TYPE_SET(cmd_args[count],
13773 WMI_DIAG_TYPE_GET(val));
13774 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13775 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013776 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013777 count++;
13778 }
13779 }
13780
13781 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13782 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013783 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013784 __func__);
13785 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013786 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013787 }
13788
Govind Singhb53420c2016-03-09 14:32:57 +053013789 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013790}
13791
13792/**
13793 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13794 * @wmi_handle: WMI handle
13795 *
13796 * This function is used to send the flush command to the FW,
13797 * that will flush the fw logs that are residue in the FW
13798 *
13799 * Return: None
13800 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013801static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013802{
13803 wmi_debug_mesg_flush_fixed_param *cmd;
13804 wmi_buf_t buf;
13805 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013806 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013807
13808 buf = wmi_buf_alloc(wmi_handle, len);
13809 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013810 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013811 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013812 }
13813
13814 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13815 WMITLV_SET_HDR(&cmd->tlv_header,
13816 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13817 WMITLV_GET_STRUCT_TLVLEN(
13818 wmi_debug_mesg_flush_fixed_param));
13819 cmd->reserved0 = 0;
13820
13821 ret = wmi_unified_cmd_send(wmi_handle,
13822 buf,
13823 len,
13824 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013825 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013826 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013827 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013828 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013829 }
Govind Singhb53420c2016-03-09 14:32:57 +053013830 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013831
Govind Singh67922e82016-04-01 16:48:57 +053013832 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013833}
13834
13835/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013836 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013837 * @wmi_handle: wmi handle
13838 * @msg: PCL structure containing the PCL and the number of channels
13839 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013840 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013841 * firmware. The DBS Manager is the consumer of this information in the WLAN
13842 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13843 * to migrate to a new channel without host driver involvement. An example of
13844 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13845 * manage the channel selection without firmware involvement.
13846 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013847 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13848 * channel list. The weights corresponds to the channels sent in
13849 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13850 * weightage compared to the non PCL channels.
13851 *
Govind Singha4836fd2016-03-07 16:45:38 +053013852 * Return: Success if the cmd is sent successfully to the firmware
13853 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013854static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013855 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013856{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013857 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013858 wmi_buf_t buf;
13859 uint8_t *buf_ptr;
13860 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013861 uint32_t chan_len;
13862
13863 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013864
13865 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013866 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013867
13868 buf = wmi_buf_alloc(wmi_handle, len);
13869 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013870 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13871 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013872 }
13873
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013874 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013875 buf_ptr = (uint8_t *) cmd;
13876 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013877 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13878 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013879
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013880 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13881 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013882 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013883 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013884
13885 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013886 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013887 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013888 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013889 for (i = 0; i < chan_len ; i++) {
13890 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013891 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013892 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013893 }
13894 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013895 WMI_PDEV_SET_PCL_CMDID)) {
13896 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013897 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013898 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013899 }
Govind Singhb53420c2016-03-09 14:32:57 +053013900 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013901}
13902
13903/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013904 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013905 * @wmi_handle: wmi handle
13906 * @msg: Structure containing the following parameters
13907 *
13908 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13909 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13910 *
13911 * Provides notification to the WLAN firmware that host driver is requesting a
13912 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13913 * configurations that include the Dual Band Simultaneous (DBS) feature.
13914 *
13915 * Return: Success if the cmd is sent successfully to the firmware
13916 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013917static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013918 uint32_t hw_mode_index)
13919{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013920 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013921 wmi_buf_t buf;
13922 uint32_t len;
13923
13924 len = sizeof(*cmd);
13925
13926 buf = wmi_buf_alloc(wmi_handle, len);
13927 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013928 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13929 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013930 }
13931
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013932 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013933 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013934 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13935 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13936
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013937 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13938 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013939 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013940 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013941
13942 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013943 WMI_PDEV_SET_HW_MODE_CMDID)) {
13944 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013945 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013946 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013947 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013948 }
13949
Govind Singhb53420c2016-03-09 14:32:57 +053013950 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013951}
13952
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013953#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013954/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013955 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013956 * @wmi_handle: wmi handle
13957 * @msg: Dual MAC config parameters
13958 *
13959 * Configures WLAN firmware with the dual MAC features
13960 *
Govind Singhb53420c2016-03-09 14:32:57 +053013961 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013962 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013963static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013964QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013965 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013966{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013967 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013968 wmi_buf_t buf;
13969 uint32_t len;
13970
13971 len = sizeof(*cmd);
13972
13973 buf = wmi_buf_alloc(wmi_handle, len);
13974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013975 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13976 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013977 }
13978
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013979 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013980 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013981 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013982 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013983 wmi_pdev_set_mac_config_cmd_fixed_param));
13984
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013985 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13986 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013987 cmd->concurrent_scan_config_bits = msg->scan_config;
13988 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013989 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013990 __func__, msg->scan_config, msg->fw_mode_config);
13991
13992 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013993 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13994 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013995 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013996 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013997 }
Govind Singhb53420c2016-03-09 14:32:57 +053013998 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013999}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080014000#endif
Govind Singha4836fd2016-03-07 16:45:38 +053014001
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014002#ifdef BIG_ENDIAN_HOST
14003/**
14004* fips_conv_data_be() - LE to BE conversion of FIPS ev data
14005* @param data_len - data length
14006* @param data - pointer to data
14007*
14008* Return: QDF_STATUS - success or error status
14009*/
14010static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14011 struct fips_params *param)
14012{
14013 unsigned char *key_unaligned, *data_unaligned;
14014 int c;
14015 u_int8_t *key_aligned = NULL;
14016 u_int8_t *data_aligned = NULL;
14017
14018 /* Assigning unaligned space to copy the key */
14019 key_unaligned = qdf_mem_malloc(
14020 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
14021 data_unaligned = qdf_mem_malloc(
14022 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
14023
14024 /* Checking if kmalloc is succesful to allocate space */
14025 if (key_unaligned == NULL)
14026 return QDF_STATUS_SUCCESS;
14027 /* Checking if space is aligned */
14028 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14029 /* align to 4 */
14030 key_aligned =
14031 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14032 FIPS_ALIGN);
14033 } else {
14034 key_aligned = (u_int8_t *)key_unaligned;
14035 }
14036
14037 /* memset and copy content from key to key aligned */
14038 OS_MEMSET(key_aligned, 0, param->key_len);
14039 OS_MEMCPY(key_aligned, param->key, param->key_len);
14040
14041 /* print a hexdump for host debug */
14042 print_hex_dump(KERN_DEBUG,
14043 "\t Aligned and Copied Key:@@@@ ",
14044 DUMP_PREFIX_NONE,
14045 16, 1, key_aligned, param->key_len, true);
14046
14047 /* Checking if kmalloc is succesful to allocate space */
14048 if (data_unaligned == NULL)
14049 return QDF_STATUS_SUCCESS;
14050 /* Checking of space is aligned */
14051 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14052 /* align to 4 */
14053 data_aligned =
14054 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14055 FIPS_ALIGN);
14056 } else {
14057 data_aligned = (u_int8_t *)data_unaligned;
14058 }
14059
14060 /* memset and copy content from data to data aligned */
14061 OS_MEMSET(data_aligned, 0, param->data_len);
14062 OS_MEMCPY(data_aligned, param->data, param->data_len);
14063
14064 /* print a hexdump for host debug */
14065 print_hex_dump(KERN_DEBUG,
14066 "\t Properly Aligned and Copied Data:@@@@ ",
14067 DUMP_PREFIX_NONE,
14068 16, 1, data_aligned, param->data_len, true);
14069
14070 /* converting to little Endian both key_aligned and
14071 * data_aligned*/
14072 for (c = 0; c < param->key_len/4; c++) {
14073 *((u_int32_t *)key_aligned+c) =
14074 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14075 }
14076 for (c = 0; c < param->data_len/4; c++) {
14077 *((u_int32_t *)data_aligned+c) =
14078 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14079 }
14080
14081 /* update endian data to key and data vectors */
14082 OS_MEMCPY(param->key, key_aligned, param->key_len);
14083 OS_MEMCPY(param->data, data_aligned, param->data_len);
14084
14085 /* clean up allocated spaces */
14086 qdf_mem_free(key_unaligned);
14087 key_unaligned = NULL;
14088 key_aligned = NULL;
14089
14090 qdf_mem_free(data_unaligned);
14091 data_unaligned = NULL;
14092 data_aligned = NULL;
14093
14094 return QDF_STATUS_SUCCESS;
14095}
14096#else
14097/**
14098* fips_align_data_be() - DUMMY for LE platform
14099*
14100* Return: QDF_STATUS - success
14101*/
14102static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14103 struct fips_params *param)
14104{
14105 return QDF_STATUS_SUCCESS;
14106}
14107#endif
14108
14109
14110/**
14111 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14112 * @wmi_handle: wmi handle
14113 * @param: pointer to hold pdev fips param
14114 *
14115 * Return: 0 for success or error code
14116 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014117static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014118send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14119 struct fips_params *param)
14120{
14121 wmi_pdev_fips_cmd_fixed_param *cmd;
14122 wmi_buf_t buf;
14123 uint8_t *buf_ptr;
14124 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14125 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14126
14127 /* Length TLV placeholder for array of bytes */
14128 len += WMI_TLV_HDR_SIZE;
14129 if (param->data_len)
14130 len += (param->data_len*sizeof(uint8_t));
14131
14132 /*
14133 * Data length must be multiples of 16 bytes - checked against 0xF -
14134 * and must be less than WMI_SVC_MSG_SIZE - static size of
14135 * wmi_pdev_fips_cmd structure
14136 */
14137
14138 /* do sanity on the input */
14139 if (!(((param->data_len & 0xF) == 0) &&
14140 ((param->data_len > 0) &&
14141 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14142 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14143 return QDF_STATUS_E_INVAL;
14144 }
14145
14146 buf = wmi_buf_alloc(wmi_handle, len);
14147 if (!buf) {
14148 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14149 return QDF_STATUS_E_FAILURE;
14150 }
14151
14152 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14153 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14154 WMITLV_SET_HDR(&cmd->tlv_header,
14155 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14156 WMITLV_GET_STRUCT_TLVLEN
14157 (wmi_pdev_fips_cmd_fixed_param));
14158
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014159 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14160 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014161 if (param->key != NULL && param->data != NULL) {
14162 cmd->key_len = param->key_len;
14163 cmd->data_len = param->data_len;
14164 cmd->fips_cmd = !!(param->op);
14165
14166 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14167 return QDF_STATUS_E_FAILURE;
14168
14169 qdf_mem_copy(cmd->key, param->key, param->key_len);
14170
14171 if (param->mode == FIPS_ENGINE_AES_CTR ||
14172 param->mode == FIPS_ENGINE_AES_MIC) {
14173 cmd->mode = param->mode;
14174 } else {
14175 cmd->mode = FIPS_ENGINE_AES_CTR;
14176 }
14177 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14178 cmd->key_len, cmd->data_len);
14179
14180 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14181 cmd->key, cmd->key_len, true);
14182 buf_ptr += sizeof(*cmd);
14183
14184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14185
14186 buf_ptr += WMI_TLV_HDR_SIZE;
14187 if (param->data_len)
14188 qdf_mem_copy(buf_ptr,
14189 (uint8_t *) param->data, param->data_len);
14190
14191 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14192 16, 1, buf_ptr, cmd->data_len, true);
14193
14194 buf_ptr += param->data_len;
14195
14196 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14197 WMI_PDEV_FIPS_CMDID);
14198 qdf_print("%s return value %d\n", __func__, retval);
14199 } else {
14200 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14201 wmi_buf_free(buf);
14202 retval = -QDF_STATUS_E_BADMSG;
14203 }
14204
14205 return retval;
14206}
14207
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014208#ifdef WLAN_PMO_ENABLE
14209/**
14210 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14211 * @wmi_handle: wmi handle
14212 * @vdev_id: vdev id
14213 * @bitmap: Event bitmap
14214 * @enable: enable/disable
14215 *
14216 * Return: CDF status
14217 */
14218static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14219 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014220 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014221 bool enable)
14222{
14223 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14224 uint16_t len;
14225 wmi_buf_t buf;
14226 int ret;
14227
14228 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14229 buf = wmi_buf_alloc(wmi_handle, len);
14230 if (!buf) {
14231 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14232 return QDF_STATUS_E_NOMEM;
14233 }
14234 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14235 WMITLV_SET_HDR(&cmd->tlv_header,
14236 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14237 WMITLV_GET_STRUCT_TLVLEN
14238 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14239 cmd->vdev_id = vdev_id;
14240 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014241 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14242 WMI_WOW_MAX_EVENT_BM_LEN);
14243
14244 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14245 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14246 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014247
14248 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14249 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14250 if (ret) {
14251 WMI_LOGE("Failed to config wow wakeup event");
14252 wmi_buf_free(buf);
14253 return QDF_STATUS_E_FAILURE;
14254 }
14255
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014256 return QDF_STATUS_SUCCESS;
14257}
14258
14259/**
14260 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14261 * @wmi_handle: wmi handle
14262 * @vdev_id: vdev id
14263 * @ptrn_id: pattern id
14264 * @ptrn: pattern
14265 * @ptrn_len: pattern length
14266 * @ptrn_offset: pattern offset
14267 * @mask: mask
14268 * @mask_len: mask length
14269 * @user: true for user configured pattern and false for default pattern
14270 * @default_patterns: default patterns
14271 *
14272 * Return: CDF status
14273 */
14274static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14275 uint8_t vdev_id, uint8_t ptrn_id,
14276 const uint8_t *ptrn, uint8_t ptrn_len,
14277 uint8_t ptrn_offset, const uint8_t *mask,
14278 uint8_t mask_len, bool user,
14279 uint8_t default_patterns)
14280{
14281 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14282 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14283 wmi_buf_t buf;
14284 uint8_t *buf_ptr;
14285 int32_t len;
14286 int ret;
14287
14288 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14289 WMI_TLV_HDR_SIZE +
14290 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14291 WMI_TLV_HDR_SIZE +
14292 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14293 WMI_TLV_HDR_SIZE +
14294 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14295 WMI_TLV_HDR_SIZE +
14296 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14297 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014298 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014299
14300 buf = wmi_buf_alloc(wmi_handle, len);
14301 if (!buf) {
14302 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14303 return QDF_STATUS_E_NOMEM;
14304 }
14305
14306 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14307 buf_ptr = (uint8_t *) cmd;
14308
14309 WMITLV_SET_HDR(&cmd->tlv_header,
14310 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14311 WMITLV_GET_STRUCT_TLVLEN
14312 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14313 cmd->vdev_id = vdev_id;
14314 cmd->pattern_id = ptrn_id;
14315
14316 cmd->pattern_type = WOW_BITMAP_PATTERN;
14317 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14318
14319 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14320 sizeof(WOW_BITMAP_PATTERN_T));
14321 buf_ptr += WMI_TLV_HDR_SIZE;
14322 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14323
14324 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14325 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14326 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14327
14328 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14329 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14330
14331 bitmap_pattern->pattern_offset = ptrn_offset;
14332 bitmap_pattern->pattern_len = ptrn_len;
14333
14334 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14335 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14336
14337 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14338 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14339
14340 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14341 bitmap_pattern->pattern_id = ptrn_id;
14342
14343 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14344 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14345 bitmap_pattern->pattern_offset, user);
14346 WMI_LOGI("Pattern : ");
14347 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14348 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14349
14350 WMI_LOGI("Mask : ");
14351 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14352 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14353
14354 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14355
14356 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14358 buf_ptr += WMI_TLV_HDR_SIZE;
14359
14360 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14362 buf_ptr += WMI_TLV_HDR_SIZE;
14363
14364 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14366 buf_ptr += WMI_TLV_HDR_SIZE;
14367
14368 /* Fill TLV for pattern_info_timeout but no data. */
14369 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14370 buf_ptr += WMI_TLV_HDR_SIZE;
14371
14372 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053014373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014374 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053014375 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014376
14377 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14378 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14379 if (ret) {
14380 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14381 wmi_buf_free(buf);
14382 return QDF_STATUS_E_FAILURE;
14383 }
14384
14385 return QDF_STATUS_SUCCESS;
14386}
14387
Govind Singha4836fd2016-03-07 16:45:38 +053014388/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014389 * fill_arp_offload_params_tlv() - Fill ARP offload data
14390 * @wmi_handle: wmi handle
14391 * @offload_req: offload request
14392 * @buf_ptr: buffer pointer
14393 *
14394 * To fill ARP offload data to firmware
14395 * when target goes to wow mode.
14396 *
14397 * Return: None
14398 */
14399static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014400 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014401{
14402
14403 int i;
14404 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014405 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014406
14407 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14408 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14409 *buf_ptr += WMI_TLV_HDR_SIZE;
14410 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14411 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14412 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14413 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14414 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14415
14416 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014417 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014418 /* Copy the target ip addr and flags */
14419 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14420 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014421 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014422 WMI_IPV4_ADDR_LEN);
14423 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014424 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014425 }
14426 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14427 }
14428}
14429
14430#ifdef WLAN_NS_OFFLOAD
14431/**
14432 * fill_ns_offload_params_tlv() - Fill NS offload data
14433 * @wmi|_handle: wmi handle
14434 * @offload_req: offload request
14435 * @buf_ptr: buffer pointer
14436 *
14437 * To fill NS offload data to firmware
14438 * when target goes to wow mode.
14439 *
14440 * Return: None
14441 */
14442static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014443 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014444{
14445
14446 int i;
14447 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014448
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014449 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14450 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14451 *buf_ptr += WMI_TLV_HDR_SIZE;
14452 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14453 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14454 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14455 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14456 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14457
14458 /*
14459 * Fill data only for NS offload in the first ARP tuple for LA
14460 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014461 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014462 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14463 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014464 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014465 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014466 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014467 sizeof(WMI_IPV6_ADDR));
14468 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014469 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014470 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014471 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014472 ns_tuple->flags |=
14473 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14474 }
14475 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014476 i, &ns_req->self_ipv6_addr[i],
14477 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014478
14479 /* target MAC is optional, check if it is valid,
14480 * if this is not valid, the target will use the known
14481 * local MAC address rather than the tuple
14482 */
14483 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014484 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014485 &ns_tuple->target_mac);
14486 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14487 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14488 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14489 }
14490 }
14491 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14492 }
14493}
14494
14495
14496/**
14497 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14498 * @wmi: wmi handle
14499 * @offload_req: offload request
14500 * @buf_ptr: buffer pointer
14501 *
14502 * To fill extended NS offload extended data to firmware
14503 * when target goes to wow mode.
14504 *
14505 * Return: None
14506 */
14507static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014508 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014509{
14510 int i;
14511 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14512 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014513
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014514 count = ns_req->num_ns_offload_count;
14515 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014516 WMI_MAX_NS_OFFLOADS;
14517
14518 /* Populate extended NS offload tuples */
14519 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14520 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14521 *buf_ptr += WMI_TLV_HDR_SIZE;
14522 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14523 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14524 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14525 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14526 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14527
14528 /*
14529 * Fill data only for NS offload in the first ARP tuple for LA
14530 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014531 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014532 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14533 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014534 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014535 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014536 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014537 sizeof(WMI_IPV6_ADDR));
14538 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014539 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014540 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014541 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014542 ns_tuple->flags |=
14543 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14544 }
14545 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014546 i, &ns_req->self_ipv6_addr[i],
14547 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014548
14549 /* target MAC is optional, check if it is valid,
14550 * if this is not valid, the target will use the
14551 * known local MAC address rather than the tuple
14552 */
14553 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014554 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014555 &ns_tuple->target_mac);
14556 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14557 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14558 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14559 }
14560 }
14561 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14562 }
14563}
14564#else
14565static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014566 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014567{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014568}
14569
14570static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014571 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014572{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014573}
14574#endif
14575
14576/**
Govind Singha4836fd2016-03-07 16:45:38 +053014577 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14578 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014579 * @arp_offload_req: arp offload request
14580 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014581 * @arp_only: flag
14582 *
14583 * To configure ARP NS off load data to firmware
14584 * when target goes to wow mode.
14585 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014586 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014587 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014588static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014589 struct pmo_arp_offload_params *arp_offload_req,
14590 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014591 uint8_t vdev_id)
14592{
Govind Singha4836fd2016-03-07 16:45:38 +053014593 int32_t res;
14594 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053014595 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053014596 wmi_buf_t buf;
14597 int32_t len;
14598 uint32_t count = 0, num_ns_ext_tuples = 0;
14599
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014600 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014601
Govind Singha4836fd2016-03-07 16:45:38 +053014602 /*
14603 * TLV place holder size for array of NS tuples
14604 * TLV place holder size for array of ARP tuples
14605 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014606 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14607 WMI_TLV_HDR_SIZE +
14608 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14609 WMI_TLV_HDR_SIZE +
14610 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014611
14612 /*
14613 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14614 * extra length for extended NS offload tuples which follows ARP offload
14615 * tuples. Host needs to fill this structure in following format:
14616 * 2 NS ofload tuples
14617 * 2 ARP offload tuples
14618 * N numbers of extended NS offload tuples if HDD has given more than
14619 * 2 NS offload addresses
14620 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014621 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014622 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014623 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14624 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014625 }
14626
14627 buf = wmi_buf_alloc(wmi_handle, len);
14628 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014629 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014630 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014631 }
14632
Vivekc5823092018-03-22 23:27:21 +053014633 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014634 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14635 WMITLV_SET_HDR(&cmd->tlv_header,
14636 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14637 WMITLV_GET_STRUCT_TLVLEN
14638 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14639 cmd->flags = 0;
14640 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014641 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014642
Govind Singhb53420c2016-03-09 14:32:57 +053014643 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014644
Govind Singha4836fd2016-03-07 16:45:38 +053014645 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014646 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14647 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14648 if (num_ns_ext_tuples)
14649 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014650
14651 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14652 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14653 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014654 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014655 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014656 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014657 }
14658
Govind Singhb53420c2016-03-09 14:32:57 +053014659 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014660}
14661
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014662/**
14663 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14664 * @wmi_handle: wmi handle
14665 * @vdev_id: vdev id
14666 * @action: true for enable else false
14667 *
14668 * To enable enhance multicast offload to firmware
14669 * when target goes to wow mode.
14670 *
14671 * Return: QDF Status
14672 */
14673
14674static
14675QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14676 wmi_unified_t wmi_handle,
14677 uint8_t vdev_id, bool action)
14678{
14679 QDF_STATUS status;
14680 wmi_buf_t buf;
14681 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14682
14683 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14684 if (!buf) {
14685 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14686 return QDF_STATUS_E_NOMEM;
14687 }
14688
14689 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14690 wmi_buf_data(buf);
14691
14692 WMITLV_SET_HDR(&cmd->tlv_header,
14693 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14694 WMITLV_GET_STRUCT_TLVLEN(
14695 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14696
14697 cmd->vdev_id = vdev_id;
14698 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14699 ENHANCED_MCAST_FILTER_ENABLED);
14700 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14701 __func__, action, vdev_id);
14702 status = wmi_unified_cmd_send(wmi_handle, buf,
14703 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14704 if (status != QDF_STATUS_SUCCESS) {
14705 qdf_nbuf_free(buf);
14706 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14707 __func__);
14708 }
14709
14710 return status;
14711}
14712
14713/**
14714 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14715 * @wmi_handle: wmi handle
14716 * @param evt_buf: pointer to event buffer
14717 * @param hdr: Pointer to hold header
14718 * @param bufp: Pointer to hold pointer to rx param buffer
14719 *
14720 * Return: QDF_STATUS_SUCCESS for success or error code
14721 */
14722static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14723 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14724{
14725 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14726 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14727
14728 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14729 if (!param_buf) {
14730 WMI_LOGE("gtk param_buf is NULL");
14731 return QDF_STATUS_E_INVAL;
14732 }
14733
14734 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14735 WMI_LOGE("Invalid length for GTK status");
14736 return QDF_STATUS_E_INVAL;
14737 }
14738
14739 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14740 param_buf->fixed_param;
14741 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14742 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14743 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14744 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14745 &fixed_param->replay_counter,
14746 GTK_REPLAY_COUNTER_BYTES);
14747
14748 return QDF_STATUS_SUCCESS;
14749
14750}
14751
14752#ifdef FEATURE_WLAN_RA_FILTERING
14753/**
14754 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14755 * @wmi_handle: wmi handle
14756 * @vdev_id: vdev id
14757 *
14758 * Return: CDF status
14759 */
14760static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14761 uint8_t vdev_id, uint8_t default_pattern,
14762 uint16_t rate_limit_interval)
14763{
14764
14765 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14766 wmi_buf_t buf;
14767 uint8_t *buf_ptr;
14768 int32_t len;
14769 int ret;
14770
14771 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14772 WMI_TLV_HDR_SIZE +
14773 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14774 WMI_TLV_HDR_SIZE +
14775 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14776 WMI_TLV_HDR_SIZE +
14777 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14778 WMI_TLV_HDR_SIZE +
14779 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14780 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014781 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014782
14783 buf = wmi_buf_alloc(wmi_handle, len);
14784 if (!buf) {
14785 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14786 return QDF_STATUS_E_NOMEM;
14787 }
14788
14789 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14790 buf_ptr = (uint8_t *) cmd;
14791
14792 WMITLV_SET_HDR(&cmd->tlv_header,
14793 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14794 WMITLV_GET_STRUCT_TLVLEN
14795 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14796 cmd->vdev_id = vdev_id;
14797 cmd->pattern_id = default_pattern,
14798 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14799 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14800
14801 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14802 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14803 buf_ptr += WMI_TLV_HDR_SIZE;
14804
14805 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14807 buf_ptr += WMI_TLV_HDR_SIZE;
14808
14809 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14810 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14811 buf_ptr += WMI_TLV_HDR_SIZE;
14812
14813 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14814 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14815 buf_ptr += WMI_TLV_HDR_SIZE;
14816
14817 /* Fill TLV for pattern_info_timeout but no data. */
14818 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14819 buf_ptr += WMI_TLV_HDR_SIZE;
14820
14821 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014822 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014823 buf_ptr += WMI_TLV_HDR_SIZE;
14824
Vivekc5823092018-03-22 23:27:21 +053014825 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014826
14827 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14828 rate_limit_interval, vdev_id);
14829
14830 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14831 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14832 if (ret) {
14833 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14834 wmi_buf_free(buf);
14835 return QDF_STATUS_E_FAILURE;
14836 }
14837
14838 return QDF_STATUS_SUCCESS;
14839
14840}
14841#endif /* FEATURE_WLAN_RA_FILTERING */
14842
14843/**
14844 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14845 * @wmi_handle: wmi handle
14846 * @vdev_id: vdev id
14847 * @multicastAddr: mcast address
14848 * @clearList: clear list flag
14849 *
14850 * Return: QDF_STATUS_SUCCESS for success or error code
14851 */
14852static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14853 uint8_t vdev_id,
14854 struct qdf_mac_addr multicast_addr,
14855 bool clearList)
14856{
14857 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14858 wmi_buf_t buf;
14859 int err;
14860
14861 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14862 if (!buf) {
14863 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14864 return QDF_STATUS_E_NOMEM;
14865 }
14866
14867 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14868 qdf_mem_zero(cmd, sizeof(*cmd));
14869
14870 WMITLV_SET_HDR(&cmd->tlv_header,
14871 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14872 WMITLV_GET_STRUCT_TLVLEN
14873 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14874 cmd->action =
14875 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14876 cmd->vdev_id = vdev_id;
14877 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14878
14879 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14880 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14881
14882 err = wmi_unified_cmd_send(wmi_handle, buf,
14883 sizeof(*cmd),
14884 WMI_SET_MCASTBCAST_FILTER_CMDID);
14885 if (err) {
14886 WMI_LOGE("Failed to send set_param cmd");
14887 wmi_buf_free(buf);
14888 return QDF_STATUS_E_FAILURE;
14889 }
14890
14891 return QDF_STATUS_SUCCESS;
14892}
14893
14894/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014895 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14896 * command to fw
14897 * @wmi_handle: wmi handle
14898 * @vdev_id: vdev id
14899 * @mcast_filter_params: mcast filter params
14900 *
14901 * Return: QDF_STATUS_SUCCESS for success or error code
14902 */
14903static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14904 wmi_unified_t wmi_handle,
14905 uint8_t vdev_id,
14906 struct pmo_mcast_filter_params *filter_param)
14907
14908{
14909 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14910 uint8_t *buf_ptr;
14911 wmi_buf_t buf;
14912 int err;
14913 int i;
14914 uint8_t *mac_addr_src_ptr = NULL;
14915 wmi_mac_addr *mac_addr_dst_ptr;
14916 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14917 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14918
14919 buf = wmi_buf_alloc(wmi_handle, len);
14920 if (!buf) {
14921 WMI_LOGE("Failed to allocate memory");
14922 return QDF_STATUS_E_NOMEM;
14923 }
14924
Vivekc5823092018-03-22 23:27:21 +053014925 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014926 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14927 wmi_buf_data(buf);
14928 qdf_mem_zero(cmd, sizeof(*cmd));
14929
14930 WMITLV_SET_HDR(&cmd->tlv_header,
14931 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14932 WMITLV_GET_STRUCT_TLVLEN
14933 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14934 cmd->operation =
14935 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14936 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14937 cmd->vdev_id = vdev_id;
14938 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14939
14940 buf_ptr += sizeof(*cmd);
14941 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14942 sizeof(wmi_mac_addr) *
14943 filter_param->multicast_addr_cnt);
14944
14945 if (filter_param->multicast_addr_cnt == 0)
14946 goto send_cmd;
14947
14948 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14949 mac_addr_dst_ptr = (wmi_mac_addr *)
14950 (buf_ptr + WMI_TLV_HDR_SIZE);
14951
14952 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14953 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14954 mac_addr_src_ptr += ATH_MAC_LEN;
14955 mac_addr_dst_ptr++;
14956 }
14957
14958send_cmd:
14959 err = wmi_unified_cmd_send(wmi_handle, buf,
14960 len,
14961 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14962 if (err) {
14963 WMI_LOGE("Failed to send set_param cmd");
14964 wmi_buf_free(buf);
14965 return QDF_STATUS_E_FAILURE;
14966 }
14967
14968 return QDF_STATUS_SUCCESS;
14969}
14970
14971
14972/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014973 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14974 * @wmi_handle: wmi handle
14975 * @vdev_id: vdev id
14976 * @params: GTK offload parameters
14977 *
14978 * Return: CDF status
14979 */
14980static
14981QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14982 struct pmo_gtk_req *params,
14983 bool enable_offload,
14984 uint32_t gtk_offload_opcode)
14985{
14986 int len;
14987 wmi_buf_t buf;
14988 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014989 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014990 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014991 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014992
14993 WMI_LOGD("%s Enter", __func__);
14994
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014995 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014996
14997 /* alloc wmi buffer */
14998 buf = wmi_buf_alloc(wmi_handle, len);
14999 if (!buf) {
15000 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15001 status = QDF_STATUS_E_NOMEM;
15002 goto out;
15003 }
15004
15005 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015006 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015007 WMITLV_SET_HDR(&cmd->tlv_header,
15008 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15009 WMITLV_GET_STRUCT_TLVLEN
15010 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15011
15012 cmd->vdev_id = vdev_id;
15013
15014 /* Request target to enable GTK offload */
15015 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
15016 cmd->flags = gtk_offload_opcode;
15017
15018 /* Copy the keys and replay counter */
15019 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015020 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015021 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
15022 GTK_REPLAY_COUNTER_BYTES);
15023 } else {
15024 cmd->flags = gtk_offload_opcode;
15025 }
15026
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015027 buf_ptr += sizeof(*cmd);
15028 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15029 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015030
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015031 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15032 WMITLV_SET_HDR(&ext_param->tlv_header,
15033 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15034 WMITLV_GET_STRUCT_TLVLEN(
15035 wmi_gtk_offload_fils_tlv_param));
15036 ext_param->vdev_id = vdev_id;
15037 ext_param->flags = cmd->flags;
15038 ext_param->kek_len = params->kek_len;
15039 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15040 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15041 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15042 GTK_REPLAY_COUNTER_BYTES);
15043
15044 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x kek len %d", vdev_id, cmd->flags, params->kek_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015045 /* send the wmi command */
15046 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15047 WMI_GTK_OFFLOAD_CMDID)) {
15048 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15049 wmi_buf_free(buf);
15050 status = QDF_STATUS_E_FAILURE;
15051 }
15052
15053out:
15054 WMI_LOGD("%s Exit", __func__);
15055 return status;
15056}
15057
15058/**
15059 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15060 * @wmi_handle: wmi handle
15061 * @params: GTK offload params
15062 *
15063 * Return: CDF status
15064 */
15065static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15066 wmi_unified_t wmi_handle,
15067 uint8_t vdev_id,
15068 uint64_t offload_req_opcode)
15069{
15070 int len;
15071 wmi_buf_t buf;
15072 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15073 QDF_STATUS status = QDF_STATUS_SUCCESS;
15074
15075 len = sizeof(*cmd);
15076
15077 /* alloc wmi buffer */
15078 buf = wmi_buf_alloc(wmi_handle, len);
15079 if (!buf) {
15080 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15081 status = QDF_STATUS_E_NOMEM;
15082 goto out;
15083 }
15084
15085 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15086 WMITLV_SET_HDR(&cmd->tlv_header,
15087 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15088 WMITLV_GET_STRUCT_TLVLEN
15089 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15090
15091 /* Request for GTK offload status */
15092 cmd->flags = offload_req_opcode;
15093 cmd->vdev_id = vdev_id;
15094
15095 /* send the wmi command */
15096 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15097 WMI_GTK_OFFLOAD_CMDID)) {
15098 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15099 wmi_buf_free(buf);
15100 status = QDF_STATUS_E_FAILURE;
15101 }
15102
15103out:
15104 return status;
15105}
15106
15107/**
15108 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15109 * @wmi_handle: wmi handler
15110 * @action_params: pointer to action_params
15111 *
15112 * Return: 0 for success, otherwise appropriate error code
15113 */
15114static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15115 struct pmo_action_wakeup_set_params *action_params)
15116{
15117 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15118 wmi_buf_t buf;
15119 int i;
15120 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015121 uint32_t len = 0, *cmd_args;
15122 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015123
Vivekc5823092018-03-22 23:27:21 +053015124 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015125 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15126 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015127 if (!buf) {
15128 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15129 return QDF_STATUS_E_NOMEM;
15130 }
15131 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015132 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015133 WMITLV_SET_HDR(&cmd->tlv_header,
15134 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15135 WMITLV_GET_STRUCT_TLVLEN(
15136 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15137
15138 cmd->vdev_id = action_params->vdev_id;
15139 cmd->operation = action_params->operation;
15140
15141 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15142 cmd->action_category_map[i] =
15143 action_params->action_category_map[i];
15144
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015145 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015147 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015148 buf_ptr += WMI_TLV_HDR_SIZE;
15149 cmd_args = (uint32_t *) buf_ptr;
15150 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15151 cmd_args[i] = action_params->action_per_category[i];
15152
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015153 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015154 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015155 if (err) {
15156 WMI_LOGE("Failed to send ap_ps_egap cmd");
15157 wmi_buf_free(buf);
15158 return QDF_STATUS_E_FAILURE;
15159 }
15160
15161 return QDF_STATUS_SUCCESS;
15162}
15163
15164#ifdef FEATURE_WLAN_LPHB
15165
15166/**
15167 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15168 * @wmi_handle: wmi handle
15169 * @lphb_conf_req: configuration info
15170 *
15171 * Return: CDF status
15172 */
15173static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15174 wmi_hb_set_enable_cmd_fixed_param *params)
15175{
15176 QDF_STATUS status;
15177 wmi_buf_t buf = NULL;
15178 uint8_t *buf_ptr;
15179 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15180 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15181
15182
15183 buf = wmi_buf_alloc(wmi_handle, len);
15184 if (!buf) {
15185 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15186 return QDF_STATUS_E_NOMEM;
15187 }
15188
15189 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15190 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15191 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15192 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15193 WMITLV_GET_STRUCT_TLVLEN
15194 (wmi_hb_set_enable_cmd_fixed_param));
15195
15196 /* fill in values */
15197 hb_enable_fp->vdev_id = params->session;
15198 hb_enable_fp->enable = params->enable;
15199 hb_enable_fp->item = params->item;
15200 hb_enable_fp->session = params->session;
15201
15202 status = wmi_unified_cmd_send(wmi_handle, buf,
15203 len, WMI_HB_SET_ENABLE_CMDID);
15204 if (QDF_IS_STATUS_ERROR(status)) {
15205 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15206 status);
15207 wmi_buf_free(buf);
15208 }
15209
15210 return status;
15211}
15212
15213/**
15214 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15215 * @wmi_handle: wmi handle
15216 * @lphb_conf_req: lphb config request
15217 *
15218 * Return: CDF status
15219 */
15220static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15221 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15222{
15223 QDF_STATUS status;
15224 wmi_buf_t buf = NULL;
15225 uint8_t *buf_ptr;
15226 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15227 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15228
15229 buf = wmi_buf_alloc(wmi_handle, len);
15230 if (!buf) {
15231 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15232 return QDF_STATUS_E_NOMEM;
15233 }
15234
15235 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15236 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15237 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15238 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15239 WMITLV_GET_STRUCT_TLVLEN
15240 (wmi_hb_set_tcp_params_cmd_fixed_param));
15241
15242 /* fill in values */
15243 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15244 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15245 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15246 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15247 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15248 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15249 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15250 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15251 hb_tcp_params_fp->session = lphb_conf_req->session;
15252 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15253 &lphb_conf_req->gateway_mac,
15254 sizeof(hb_tcp_params_fp->gateway_mac));
15255
15256 status = wmi_unified_cmd_send(wmi_handle, buf,
15257 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15258 if (QDF_IS_STATUS_ERROR(status)) {
15259 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15260 status);
15261 wmi_buf_free(buf);
15262 }
15263
15264 return status;
15265}
15266
15267/**
15268 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15269 * @wmi_handle: wmi handle
15270 * @lphb_conf_req: lphb config request
15271 *
15272 * Return: CDF status
15273 */
15274static
15275QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15276 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15277{
15278 QDF_STATUS status;
15279 wmi_buf_t buf = NULL;
15280 uint8_t *buf_ptr;
15281 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15282 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15283
15284 buf = wmi_buf_alloc(wmi_handle, len);
15285 if (!buf) {
15286 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15287 return QDF_STATUS_E_NOMEM;
15288 }
15289
15290 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15291 hb_tcp_filter_fp =
15292 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15293 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15294 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15295 WMITLV_GET_STRUCT_TLVLEN
15296 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15297
15298 /* fill in values */
15299 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15300 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15301 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15302 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15303 memcpy((void *)&hb_tcp_filter_fp->filter,
15304 (void *)&g_hb_tcp_filter_fp->filter,
15305 WMI_WLAN_HB_MAX_FILTER_SIZE);
15306
15307 status = wmi_unified_cmd_send(wmi_handle, buf,
15308 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15309 if (QDF_IS_STATUS_ERROR(status)) {
15310 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15311 status);
15312 wmi_buf_free(buf);
15313 }
15314
15315 return status;
15316}
15317
15318/**
15319 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15320 * @wmi_handle: wmi handle
15321 * @lphb_conf_req: lphb config request
15322 *
15323 * Return: CDF status
15324 */
15325static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15326 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15327{
15328 QDF_STATUS status;
15329 wmi_buf_t buf = NULL;
15330 uint8_t *buf_ptr;
15331 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15332 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15333
15334 buf = wmi_buf_alloc(wmi_handle, len);
15335 if (!buf) {
15336 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15337 return QDF_STATUS_E_NOMEM;
15338 }
15339
15340 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15341 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15342 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15343 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15344 WMITLV_GET_STRUCT_TLVLEN
15345 (wmi_hb_set_udp_params_cmd_fixed_param));
15346
15347 /* fill in values */
15348 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15349 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15350 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15351 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15352 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15353 hb_udp_params_fp->interval = lphb_conf_req->interval;
15354 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15355 hb_udp_params_fp->session = lphb_conf_req->session;
15356 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15357 &lphb_conf_req->gateway_mac,
15358 sizeof(lphb_conf_req->gateway_mac));
15359
15360 status = wmi_unified_cmd_send(wmi_handle, buf,
15361 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15362 if (QDF_IS_STATUS_ERROR(status)) {
15363 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15364 status);
15365 wmi_buf_free(buf);
15366 }
15367
15368 return status;
15369}
15370
15371/**
15372 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15373 * @wmi_handle: wmi handle
15374 * @lphb_conf_req: lphb config request
15375 *
15376 * Return: CDF status
15377 */
15378static
15379QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15380 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15381{
15382 QDF_STATUS status;
15383 wmi_buf_t buf = NULL;
15384 uint8_t *buf_ptr;
15385 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15386 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15387
15388 buf = wmi_buf_alloc(wmi_handle, len);
15389 if (!buf) {
15390 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15391 return QDF_STATUS_E_NOMEM;
15392 }
15393
15394 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15395 hb_udp_filter_fp =
15396 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15397 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15398 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15399 WMITLV_GET_STRUCT_TLVLEN
15400 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15401
15402 /* fill in values */
15403 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15404 hb_udp_filter_fp->length = lphb_conf_req->length;
15405 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15406 hb_udp_filter_fp->session = lphb_conf_req->session;
15407 memcpy((void *)&hb_udp_filter_fp->filter,
15408 (void *)&lphb_conf_req->filter,
15409 WMI_WLAN_HB_MAX_FILTER_SIZE);
15410
15411 status = wmi_unified_cmd_send(wmi_handle, buf,
15412 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15413 if (QDF_IS_STATUS_ERROR(status)) {
15414 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15415 status);
15416 wmi_buf_free(buf);
15417 }
15418
15419 return status;
15420}
15421#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015422
Dustin Brownf31f88b2017-05-12 14:01:44 -070015423static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15424 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015425{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015426 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015427 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015428 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015429
Dustin Brownf31f88b2017-05-12 14:01:44 -070015430 if (!req) {
15431 WMI_LOGE("req is null");
15432 return QDF_STATUS_E_INVAL;
15433 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015434
Dustin Brownf31f88b2017-05-12 14:01:44 -070015435 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15436 if (!wmi_buf) {
15437 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015438 return QDF_STATUS_E_NOMEM;
15439 }
15440
Dustin Brownf31f88b2017-05-12 14:01:44 -070015441 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015442 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015443 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15444 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15445 cmd->vdev_id = req->vdev_id;
15446 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15447 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015448
Dustin Brownf31f88b2017-05-12 14:01:44 -070015449 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15450 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015451
Dustin Brownf31f88b2017-05-12 14:01:44 -070015452 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15453 WMI_HW_DATA_FILTER_CMDID);
15454 if (QDF_IS_STATUS_ERROR(status)) {
15455 WMI_LOGE("Failed to configure hw filter");
15456 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015457 }
15458
Dustin Brownf31f88b2017-05-12 14:01:44 -070015459 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015460}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015461
15462/**
15463 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15464 * @wmi_handle: wmi handle
15465 * @vdev_id: vdev id
15466 * @enable: Flag to enable/disable packet filter
15467 *
15468 * Return: QDF_STATUS_SUCCESS for success or error code
15469 */
15470static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15471 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15472{
15473 int32_t len;
15474 int ret = 0;
15475 wmi_buf_t buf;
15476 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15477
15478 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15479
15480 buf = wmi_buf_alloc(wmi_handle, len);
15481 if (!buf) {
15482 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15483 return QDF_STATUS_E_NOMEM;
15484 }
15485
15486 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15487 WMITLV_SET_HDR(&cmd->tlv_header,
15488 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15489 WMITLV_GET_STRUCT_TLVLEN(
15490 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15491
15492 cmd->vdev_id = vdev_id;
15493 if (enable)
15494 cmd->enable = PACKET_FILTER_SET_ENABLE;
15495 else
15496 cmd->enable = PACKET_FILTER_SET_DISABLE;
15497
15498 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15499 __func__, cmd->enable, vdev_id);
15500
15501 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15502 WMI_PACKET_FILTER_ENABLE_CMDID);
15503 if (ret) {
15504 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15505 wmi_buf_free(buf);
15506 }
15507
15508 return ret;
15509}
15510
15511/**
15512 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15513 * @wmi_handle: wmi handle
15514 * @vdev_id: vdev id
15515 * @rcv_filter_param: Packet filter parameters
15516 * @filter_id: Filter id
15517 * @enable: Flag to add/delete packet filter configuration
15518 *
15519 * Return: QDF_STATUS_SUCCESS for success or error code
15520 */
15521static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15522 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15523 uint8_t filter_id, bool enable)
15524{
15525 int len, i;
15526 int err = 0;
15527 wmi_buf_t buf;
15528 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15529
15530
15531 /* allocate the memory */
15532 len = sizeof(*cmd);
15533 buf = wmi_buf_alloc(wmi_handle, len);
15534 if (!buf) {
15535 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15536 return QDF_STATUS_E_NOMEM;
15537 }
15538
15539 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15540 WMITLV_SET_HDR(&cmd->tlv_header,
15541 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15542 WMITLV_GET_STRUCT_TLVLEN
15543 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15544
15545 cmd->vdev_id = vdev_id;
15546 cmd->filter_id = filter_id;
15547 if (enable)
15548 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15549 else
15550 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15551
15552 if (enable) {
15553 cmd->num_params = QDF_MIN(
15554 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15555 rcv_filter_param->num_params);
15556 cmd->filter_type = rcv_filter_param->filter_type;
15557 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15558
15559 for (i = 0; i < cmd->num_params; i++) {
15560 cmd->paramsData[i].proto_type =
15561 rcv_filter_param->params_data[i].protocol_layer;
15562 cmd->paramsData[i].cmp_type =
15563 rcv_filter_param->params_data[i].compare_flag;
15564 cmd->paramsData[i].data_length =
15565 rcv_filter_param->params_data[i].data_length;
15566 cmd->paramsData[i].data_offset =
15567 rcv_filter_param->params_data[i].data_offset;
15568 memcpy(&cmd->paramsData[i].compareData,
15569 rcv_filter_param->params_data[i].compare_data,
15570 sizeof(cmd->paramsData[i].compareData));
15571 memcpy(&cmd->paramsData[i].dataMask,
15572 rcv_filter_param->params_data[i].data_mask,
15573 sizeof(cmd->paramsData[i].dataMask));
15574 }
15575 }
15576
15577 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15578 cmd->filter_action, cmd->filter_id, cmd->num_params);
15579 /* send the command along with data */
15580 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15581 WMI_PACKET_FILTER_CONFIG_CMDID);
15582 if (err) {
15583 WMI_LOGE("Failed to send pkt_filter cmd");
15584 wmi_buf_free(buf);
15585 return QDF_STATUS_E_FAILURE;
15586 }
15587
15588 return QDF_STATUS_SUCCESS;
15589}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015590#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015591
Govind Singha4836fd2016-03-07 16:45:38 +053015592/**
15593 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15594 * @wmi_handle: wmi handle
15595 * @request: SSID hotlist set request
15596 *
Govind Singhb53420c2016-03-09 14:32:57 +053015597 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015598 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015599static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015600send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15601 struct ssid_hotlist_request_params *request)
15602{
15603 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15604 wmi_buf_t wmi_buf;
15605 uint32_t len;
15606 uint32_t array_size;
15607 uint8_t *buf_ptr;
15608
15609 /* length of fixed portion */
15610 len = sizeof(*cmd);
15611
15612 /* length of variable portion */
15613 array_size =
15614 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15615 len += WMI_TLV_HDR_SIZE + array_size;
15616
15617 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15618 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015619 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15620 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015621 }
15622
15623 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15624 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15625 buf_ptr;
15626 WMITLV_SET_HDR
15627 (&cmd->tlv_header,
15628 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15629 WMITLV_GET_STRUCT_TLVLEN
15630 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15631
15632 cmd->request_id = request->request_id;
15633 cmd->requestor_id = 0;
15634 cmd->vdev_id = request->session_id;
15635 cmd->table_id = 0;
15636 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15637 cmd->total_entries = request->ssid_count;
15638 cmd->num_entries_in_page = request->ssid_count;
15639 cmd->first_entry_index = 0;
15640
15641 buf_ptr += sizeof(*cmd);
15642 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15643
15644 if (request->ssid_count) {
15645 wmi_extscan_hotlist_ssid_entry *entry;
15646 int i;
15647
15648 buf_ptr += WMI_TLV_HDR_SIZE;
15649 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15650 for (i = 0; i < request->ssid_count; i++) {
15651 WMITLV_SET_HDR
15652 (entry,
15653 WMITLV_TAG_ARRAY_STRUC,
15654 WMITLV_GET_STRUCT_TLVLEN
15655 (wmi_extscan_hotlist_ssid_entry));
15656 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015657 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015658 request->ssids[i].ssid.mac_ssid,
15659 request->ssids[i].ssid.length);
15660 entry->band = request->ssids[i].band;
15661 entry->min_rssi = request->ssids[i].rssi_low;
15662 entry->max_rssi = request->ssids[i].rssi_high;
15663 entry++;
15664 }
15665 cmd->mode = WMI_EXTSCAN_MODE_START;
15666 } else {
15667 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15668 }
15669
15670 if (wmi_unified_cmd_send
15671 (wmi_handle, wmi_buf, len,
15672 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015673 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015674 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015675 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015676 }
15677
Govind Singhb53420c2016-03-09 14:32:57 +053015678 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015679}
15680
15681/**
15682 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15683 * @wmi_handle: wmi handle
15684 * @vdev_id: vdev id
15685 *
15686 * This function sends roam synch complete event to fw.
15687 *
15688 * Return: CDF STATUS
15689 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015690static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015691 uint8_t vdev_id)
15692{
15693 wmi_roam_synch_complete_fixed_param *cmd;
15694 wmi_buf_t wmi_buf;
15695 uint8_t *buf_ptr;
15696 uint16_t len;
15697 len = sizeof(wmi_roam_synch_complete_fixed_param);
15698
15699 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15700 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015701 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15702 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015703 }
15704 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15705 buf_ptr = (uint8_t *) cmd;
15706 WMITLV_SET_HDR(&cmd->tlv_header,
15707 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15708 WMITLV_GET_STRUCT_TLVLEN
15709 (wmi_roam_synch_complete_fixed_param));
15710 cmd->vdev_id = vdev_id;
15711 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15712 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015713 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015714 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015715 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015716 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015717 }
15718
Govind Singhb53420c2016-03-09 14:32:57 +053015719 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015720}
15721
15722/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015723 * send_fw_test_cmd_tlv() - send fw test command to fw.
15724 * @wmi_handle: wmi handle
15725 * @wmi_fwtest: fw test command
15726 *
15727 * This function sends fw test command to fw.
15728 *
15729 * Return: CDF STATUS
15730 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015731static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015732QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15733 struct set_fwtest_params *wmi_fwtest)
15734{
15735 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15736 wmi_buf_t wmi_buf;
15737 uint16_t len;
15738
15739 len = sizeof(*cmd);
15740
15741 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15742 if (!wmi_buf) {
15743 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15744 return QDF_STATUS_E_NOMEM;
15745 }
15746
15747 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15748 WMITLV_SET_HDR(&cmd->tlv_header,
15749 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15750 WMITLV_GET_STRUCT_TLVLEN(
15751 wmi_fwtest_set_param_cmd_fixed_param));
15752 cmd->param_id = wmi_fwtest->arg;
15753 cmd->param_value = wmi_fwtest->value;
15754
15755 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15756 WMI_FWTEST_CMDID)) {
15757 WMI_LOGP("%s: failed to send fw test command", __func__);
15758 qdf_nbuf_free(wmi_buf);
15759 return QDF_STATUS_E_FAILURE;
15760 }
15761
15762 return QDF_STATUS_SUCCESS;
15763}
15764
15765/**
Govind Singha4836fd2016-03-07 16:45:38 +053015766 * send_unit_test_cmd_tlv() - send unit test command to fw.
15767 * @wmi_handle: wmi handle
15768 * @wmi_utest: unit test command
15769 *
15770 * This function send unit test command to fw.
15771 *
15772 * Return: CDF STATUS
15773 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015774static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015775 struct wmi_unit_test_cmd *wmi_utest)
15776{
15777 wmi_unit_test_cmd_fixed_param *cmd;
15778 wmi_buf_t wmi_buf;
15779 uint8_t *buf_ptr;
15780 int i;
15781 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015782 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015783
15784 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015785 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015786 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15787
15788 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15789 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015790 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15791 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015792 }
15793
15794 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15795 buf_ptr = (uint8_t *) cmd;
15796 WMITLV_SET_HDR(&cmd->tlv_header,
15797 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15798 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15799 cmd->vdev_id = wmi_utest->vdev_id;
15800 cmd->module_id = wmi_utest->module_id;
15801 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015802 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015803 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15804 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15805 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015806 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015807 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15808 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15809 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015810 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015811 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015812 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015813 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015814 }
15815 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15816 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015817 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015818 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015819 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015820 }
15821
Govind Singhb53420c2016-03-09 14:32:57 +053015822 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015823}
15824
15825/**
15826 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15827 * @wmi_handle: wma handle
15828 * @roaminvoke: roam invoke command
15829 *
15830 * Send roam invoke command to fw for fastreassoc.
15831 *
15832 * Return: CDF STATUS
15833 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015834static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015835 struct wmi_roam_invoke_cmd *roaminvoke,
15836 uint32_t ch_hz)
15837{
15838 wmi_roam_invoke_cmd_fixed_param *cmd;
15839 wmi_buf_t wmi_buf;
15840 u_int8_t *buf_ptr;
15841 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015842 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015843 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015844 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015845
15846 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015847 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015848 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15849 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015850 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15851 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15852 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015853 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15854 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015855 }
15856
15857 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15858 buf_ptr = (u_int8_t *) cmd;
15859 WMITLV_SET_HDR(&cmd->tlv_header,
15860 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15861 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15862 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015863 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015864 if (roaminvoke->is_same_bssid)
15865 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15866 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015867
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015868 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015869 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015870 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15871 cmd->num_buf = 1;
15872 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015873 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015874 cmd->num_buf = 0;
15875 }
Naveen Rawat77797922017-01-20 17:00:07 -080015876
Govind Singha4836fd2016-03-07 16:45:38 +053015877 cmd->roam_ap_sel_mode = 0;
15878 cmd->roam_delay = 0;
15879 cmd->num_chan = 1;
15880 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015881
Govind Singha4836fd2016-03-07 16:45:38 +053015882 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15883 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15884 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015885 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015886 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015887 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15889 (sizeof(wmi_mac_addr)));
15890 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15891 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015892
15893 /* move to next tlv i.e. bcn_prb_buf_list */
15894 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15895
15896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15897 sizeof(wmi_tlv_buf_len_param));
15898
15899 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15900 buf_len_tlv->buf_len = roaminvoke->frame_len;
15901
15902 /* move to next tlv i.e. bcn_prb_frm */
15903 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15905 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15906
15907 /* copy frame after the header */
15908 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15909 roaminvoke->frame_buf,
15910 roaminvoke->frame_len);
15911
15912 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15913 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15914 buf_ptr + WMI_TLV_HDR_SIZE,
15915 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015916 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15917 cmd->flags, cmd->roam_scan_mode,
15918 cmd->roam_ap_sel_mode, cmd->roam_delay,
15919 cmd->num_chan, cmd->num_bssid);
15920 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015921
Govind Singha4836fd2016-03-07 16:45:38 +053015922 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15923 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015924 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015925 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015926 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015927 }
15928
Govind Singhb53420c2016-03-09 14:32:57 +053015929 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015930}
15931
15932/**
15933 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15934 * @wmi_handle: wmi handle
15935 * @command: command
15936 * @vdev_id: vdev id
15937 *
15938 * This function set roam offload command to fw.
15939 *
15940 * Return: CDF status
15941 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015942static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015943 uint32_t command, uint32_t vdev_id)
15944{
Govind Singh67922e82016-04-01 16:48:57 +053015945 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015946 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15947 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015948 int len;
15949 uint8_t *buf_ptr;
15950
15951 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15952 buf = wmi_buf_alloc(wmi_handle, len);
15953 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015954 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15955 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015956 }
15957
15958 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15959
15960 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15961 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15962 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15963 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15964 cmd_fp->vdev_id = vdev_id;
15965 cmd_fp->command_arg = command;
15966
15967 status = wmi_unified_cmd_send(wmi_handle, buf,
15968 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015969 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015970 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015971 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015972 goto error;
15973 }
15974
Govind Singhb53420c2016-03-09 14:32:57 +053015975 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15976 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015977
15978error:
15979 wmi_buf_free(buf);
15980
Govind Singh67922e82016-04-01 16:48:57 +053015981 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015982}
15983
15984/**
15985 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15986 * @wmi_handle: wmi handle
15987 * @ap_profile_p: ap profile
15988 * @vdev_id: vdev id
15989 *
15990 * Send WMI_ROAM_AP_PROFILE to firmware
15991 *
15992 * Return: CDF status
15993 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015994static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015995 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015996{
Govind Singha4836fd2016-03-07 16:45:38 +053015997 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015998 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015999 int len;
16000 uint8_t *buf_ptr;
16001 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016002 wmi_roam_cnd_scoring_param *score_param;
16003 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053016004
16005 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016006 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053016007 buf = wmi_buf_alloc(wmi_handle, len);
16008 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016009 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16010 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016011 }
16012
16013 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16014 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
16015 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
16016 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
16017 WMITLV_GET_STRUCT_TLVLEN
16018 (wmi_roam_ap_profile_fixed_param));
16019 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016020 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053016021 roam_ap_profile_fp->id = 0;
16022 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
16023
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016024 profile = (wmi_ap_profile *)buf_ptr;
16025 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016026 WMITLV_TAG_STRUC_wmi_ap_profile,
16027 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016028 profile->flags = ap_profile->profile.flags;
16029 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16030 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16031 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16032 profile->ssid.ssid_len);
16033 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16034 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16035 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16036 profile->rsn_mcastmgmtcipherset =
16037 ap_profile->profile.rsn_mcastmgmtcipherset;
16038 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16039
16040 WMI_LOGD("AP profile: flags %x rssi_threshold %d ssid:%.*s authmode %d uc cipher %d mc cipher %d mc mgmt cipher %d rssi abs thresh %d",
16041 profile->flags, profile->rssi_threshold,
16042 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16043 profile->rsn_authmode, profile->rsn_ucastcipherset,
16044 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16045 profile->rssi_abs_thresh);
16046
16047 buf_ptr += sizeof(wmi_ap_profile);
16048
16049 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16050 WMITLV_SET_HDR(&score_param->tlv_header,
16051 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16052 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16053 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16054 score_param->rssi_weightage_pcnt =
16055 ap_profile->param.rssi_weightage;
16056 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16057 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16058 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16059 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16060 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16061 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16062 score_param->esp_qbss_weightage_pcnt =
16063 ap_profile->param.esp_qbss_weightage;
16064 score_param->beamforming_weightage_pcnt =
16065 ap_profile->param.beamforming_weightage;
16066 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16067 score_param->oce_wan_weightage_pcnt =
16068 ap_profile->param.oce_wan_weightage;
16069
16070 WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d",
16071 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16072 score_param->ht_weightage_pcnt,
16073 score_param->vht_weightage_pcnt,
16074 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16075 score_param->band_weightage_pcnt,
16076 score_param->nss_weightage_pcnt,
16077 score_param->esp_qbss_weightage_pcnt,
16078 score_param->beamforming_weightage_pcnt,
16079 score_param->pcl_weightage_pcnt,
16080 score_param->oce_wan_weightage_pcnt);
16081
16082 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16083 score_param->band_scoring.score_pcnt =
16084 ap_profile->param.band_index_score;
16085 score_param->nss_scoring.score_pcnt =
16086 ap_profile->param.nss_index_score;
16087
16088 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16089 score_param->bw_scoring.score_pcnt,
16090 score_param->band_scoring.score_pcnt,
16091 score_param->nss_scoring.score_pcnt);
16092
16093 score_param->rssi_scoring.best_rssi_threshold =
16094 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16095 score_param->rssi_scoring.good_rssi_threshold =
16096 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16097 score_param->rssi_scoring.bad_rssi_threshold =
16098 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16099 score_param->rssi_scoring.good_rssi_pcnt =
16100 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16101 score_param->rssi_scoring.bad_rssi_pcnt =
16102 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16103 score_param->rssi_scoring.good_bucket_size =
16104 ap_profile->param.rssi_scoring.good_bucket_size;
16105 score_param->rssi_scoring.bad_bucket_size =
16106 ap_profile->param.rssi_scoring.bad_bucket_size;
16107 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16108 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16109
16110 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16111 score_param->rssi_scoring.best_rssi_threshold,
16112 score_param->rssi_scoring.good_rssi_threshold,
16113 score_param->rssi_scoring.bad_rssi_threshold,
16114 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16115 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16116 score_param->rssi_scoring.good_rssi_pcnt,
16117 score_param->rssi_scoring.bad_rssi_pcnt,
16118 score_param->rssi_scoring.good_bucket_size,
16119 score_param->rssi_scoring.bad_bucket_size);
16120
16121 score_param->esp_qbss_scoring.num_slot =
16122 ap_profile->param.esp_qbss_scoring.num_slot;
16123 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16124 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16125 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16126 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16127 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16128 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16129 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16130 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16131
16132 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16133 score_param->esp_qbss_scoring.num_slot,
16134 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16135 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16136 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16137 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16138
16139 score_param->oce_wan_scoring.num_slot =
16140 ap_profile->param.oce_wan_scoring.num_slot;
16141 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16142 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16143 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16144 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16145 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16146 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16147 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16148 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16149
16150 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16151 score_param->oce_wan_scoring.num_slot,
16152 score_param->oce_wan_scoring.score_pcnt3_to_0,
16153 score_param->oce_wan_scoring.score_pcnt7_to_4,
16154 score_param->oce_wan_scoring.score_pcnt11_to_8,
16155 score_param->oce_wan_scoring.score_pcnt15_to_12);
16156
Govind Singha4836fd2016-03-07 16:45:38 +053016157 status = wmi_unified_cmd_send(wmi_handle, buf,
16158 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016159 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016160 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016161 status);
Govind Singh67922e82016-04-01 16:48:57 +053016162 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016163 }
16164
Govind Singhb53420c2016-03-09 14:32:57 +053016165 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016166
Govind Singh67922e82016-04-01 16:48:57 +053016167 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016168}
16169
16170/**
16171 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16172 * @wmi_handle: wmi handle
16173 * @scan_period: scan period
16174 * @scan_age: scan age
16175 * @vdev_id: vdev id
16176 *
16177 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16178 *
16179 * Return: CDF status
16180 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016181static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016182 uint32_t scan_period,
16183 uint32_t scan_age,
16184 uint32_t vdev_id)
16185{
Govind Singh67922e82016-04-01 16:48:57 +053016186 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016187 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016188 int len;
16189 uint8_t *buf_ptr;
16190 wmi_roam_scan_period_fixed_param *scan_period_fp;
16191
16192 /* Send scan period values */
16193 len = sizeof(wmi_roam_scan_period_fixed_param);
16194 buf = wmi_buf_alloc(wmi_handle, len);
16195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016196 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16197 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016198 }
16199
16200 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16201 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16202 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16203 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16204 WMITLV_GET_STRUCT_TLVLEN
16205 (wmi_roam_scan_period_fixed_param));
16206 /* fill in scan period values */
16207 scan_period_fp->vdev_id = vdev_id;
16208 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16209 scan_period_fp->roam_scan_age = scan_age;
16210
16211 status = wmi_unified_cmd_send(wmi_handle, buf,
16212 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016213 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016214 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016215 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016216 goto error;
16217 }
16218
Govind Singhb53420c2016-03-09 14:32:57 +053016219 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016220 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016221 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016222error:
16223 wmi_buf_free(buf);
16224
Govind Singh67922e82016-04-01 16:48:57 +053016225 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016226}
16227
16228/**
16229 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16230 * @wmi_handle: wmi handle
16231 * @chan_count: channel count
16232 * @chan_list: channel list
16233 * @list_type: list type
16234 * @vdev_id: vdev id
16235 *
16236 * Set roam offload channel list.
16237 *
16238 * Return: CDF status
16239 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016240static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016241 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016242 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016243 uint8_t list_type, uint32_t vdev_id)
16244{
Govind Singha4836fd2016-03-07 16:45:38 +053016245 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016246 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016247 int len, list_tlv_len;
16248 int i;
16249 uint8_t *buf_ptr;
16250 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053016251 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053016252
16253 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016254 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016255 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016256 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016257 }
16258 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053016259 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053016260 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16261 buf = wmi_buf_alloc(wmi_handle, len);
16262 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016263 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16264 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016265 }
16266
16267 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16268 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16269 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16270 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16271 WMITLV_GET_STRUCT_TLVLEN
16272 (wmi_roam_chan_list_fixed_param));
16273 chan_list_fp->vdev_id = vdev_id;
16274 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016275 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016276 /* external app is controlling channel list */
16277 chan_list_fp->chan_list_type =
16278 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16279 } else {
16280 /* umac supplied occupied channel list in LFR */
16281 chan_list_fp->chan_list_type =
16282 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16283 }
16284
16285 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16286 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16287 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053016288 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016289 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016290 for (i = 0; ((i < chan_list_fp->num_chan) &&
16291 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16292 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016293 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016294 }
16295
16296 status = wmi_unified_cmd_send(wmi_handle, buf,
16297 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016298 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016299 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016300 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016301 goto error;
16302 }
16303
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016304 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016305 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016306error:
16307 wmi_buf_free(buf);
16308
Govind Singh67922e82016-04-01 16:48:57 +053016309 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016310}
16311
16312/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016313 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16314 * @wmi_handle: wmi handle
16315 * @req_buf: per roam config buffer
16316 *
16317 * Return: QDF status
16318 */
16319static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16320 struct wmi_per_roam_config_req *req_buf)
16321{
16322 wmi_buf_t buf = NULL;
16323 QDF_STATUS status;
16324 int len;
16325 uint8_t *buf_ptr;
16326 wmi_roam_per_config_fixed_param *wmi_per_config;
16327
16328 len = sizeof(wmi_roam_per_config_fixed_param);
16329 buf = wmi_buf_alloc(wmi_handle, len);
16330 if (!buf) {
16331 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16332 return QDF_STATUS_E_NOMEM;
16333 }
16334
16335 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16336 wmi_per_config =
16337 (wmi_roam_per_config_fixed_param *) buf_ptr;
16338 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16339 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16340 WMITLV_GET_STRUCT_TLVLEN
16341 (wmi_roam_per_config_fixed_param));
16342
16343 /* fill in per roam config values */
16344 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016345
16346 wmi_per_config->enable = req_buf->per_config.enable;
16347 wmi_per_config->high_rate_thresh =
16348 (req_buf->per_config.tx_high_rate_thresh << 16) |
16349 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16350 wmi_per_config->low_rate_thresh =
16351 (req_buf->per_config.tx_low_rate_thresh << 16) |
16352 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16353 wmi_per_config->pkt_err_rate_thresh_pct =
16354 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16355 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16356 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016357 wmi_per_config->pkt_err_rate_mon_time =
16358 (req_buf->per_config.tx_per_mon_time << 16) |
16359 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016360 wmi_per_config->min_candidate_rssi =
16361 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016362
16363 /* Send per roam config parameters */
16364 status = wmi_unified_cmd_send(wmi_handle, buf,
16365 len, WMI_ROAM_PER_CONFIG_CMDID);
16366 if (QDF_IS_STATUS_ERROR(status)) {
16367 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16368 status);
16369 wmi_buf_free(buf);
16370 return status;
16371 }
16372
16373 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16374 req_buf->per_config.enable, req_buf->vdev_id);
16375 return QDF_STATUS_SUCCESS;
16376}
16377
16378/**
Govind Singha4836fd2016-03-07 16:45:38 +053016379 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16380 * @wmi_handle: wmi handle
16381 * @rssi_change_thresh: RSSI Change threshold
16382 * @bcn_rssi_weight: beacon RSSI weight
16383 * @vdev_id: vdev id
16384 *
16385 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16386 *
16387 * Return: CDF status
16388 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016389static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016390 uint32_t vdev_id,
16391 int32_t rssi_change_thresh,
16392 uint32_t bcn_rssi_weight,
16393 uint32_t hirssi_delay_btw_scans)
16394{
Govind Singha4836fd2016-03-07 16:45:38 +053016395 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016396 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016397 int len;
16398 uint8_t *buf_ptr;
16399 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16400
16401 /* Send rssi change parameters */
16402 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16403 buf = wmi_buf_alloc(wmi_handle, len);
16404 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016405 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16406 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016407 }
16408
16409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16410 rssi_change_fp =
16411 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16412 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16413 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16414 WMITLV_GET_STRUCT_TLVLEN
16415 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16416 /* fill in rssi change threshold (hysteresis) values */
16417 rssi_change_fp->vdev_id = vdev_id;
16418 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16419 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16420 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16421
16422 status = wmi_unified_cmd_send(wmi_handle, buf,
16423 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016424 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016425 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016426 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016427 goto error;
16428 }
16429
Govind Singhb53420c2016-03-09 14:32:57 +053016430 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016431 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016432 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16433 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016434error:
16435 wmi_buf_free(buf);
16436
Govind Singh67922e82016-04-01 16:48:57 +053016437 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016438}
16439
16440/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16441 * @wmi_handle: wmi handle.
16442 * @cmd: size of command structure.
16443 * @per_entry_size: per entry size.
16444 *
16445 * This utility function calculates how many hotlist entries can
16446 * fit in one page.
16447 *
16448 * Return: number of entries
16449 */
16450static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16451 size_t cmd_size,
16452 size_t per_entry_size)
16453{
16454 uint32_t avail_space = 0;
16455 int num_entries = 0;
16456 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16457
16458 /* Calculate number of hotlist entries that can
16459 * be passed in wma message request.
16460 */
16461 avail_space = max_msg_len - cmd_size;
16462 num_entries = avail_space / per_entry_size;
16463 return num_entries;
16464}
16465
16466/**
16467 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16468 * @wmi_handle: wmi handle
16469 * @photlist: hotlist command params
16470 * @buf_len: buffer length
16471 *
16472 * This function fills individual elements for hotlist request and
16473 * TLV for bssid entries
16474 *
16475 * Return: CDF Status.
16476 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016477static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016478 struct ext_scan_setbssi_hotlist_params *
16479 photlist, int *buf_len)
16480{
16481 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16482 wmi_extscan_hotlist_entry *dest_hotlist;
16483 struct ap_threshold_params *src_ap = photlist->ap;
16484 wmi_buf_t buf;
16485 uint8_t *buf_ptr;
16486
16487 int j, index = 0;
16488 int cmd_len = 0;
16489 int num_entries;
16490 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016491 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016492 int len = sizeof(*cmd);
16493
16494 len += WMI_TLV_HDR_SIZE;
16495 cmd_len = len;
16496
16497 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16498 cmd_len,
16499 sizeof(*dest_hotlist));
16500 /* setbssid hotlist expects the bssid list
16501 * to be non zero value
16502 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016503 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016504 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016505 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016506 }
16507
16508 /* Split the hot list entry pages and send multiple command
16509 * requests if the buffer reaches the maximum request size
16510 */
16511 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016512 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016513 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16514 buf = wmi_buf_alloc(wmi_handle, len);
16515 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016516 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16517 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016518 }
16519 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16520 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16521 buf_ptr;
16522 WMITLV_SET_HDR(&cmd->tlv_header,
16523 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16524 WMITLV_GET_STRUCT_TLVLEN
16525 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16526
16527 /* Multiple requests are sent until the num_entries_in_page
16528 * matches the total_entries
16529 */
16530 cmd->request_id = photlist->requestId;
16531 cmd->vdev_id = photlist->sessionId;
16532 cmd->total_entries = numap;
16533 cmd->mode = 1;
16534 cmd->num_entries_in_page = min_entries;
16535 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16536 cmd->first_entry_index = index;
16537
Govind Singhb53420c2016-03-09 14:32:57 +053016538 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016539 __func__, cmd->vdev_id, cmd->total_entries,
16540 cmd->num_entries_in_page,
16541 cmd->lost_ap_scan_count);
16542
16543 buf_ptr += sizeof(*cmd);
16544 WMITLV_SET_HDR(buf_ptr,
16545 WMITLV_TAG_ARRAY_STRUC,
16546 min_entries * sizeof(wmi_extscan_hotlist_entry));
16547 dest_hotlist = (wmi_extscan_hotlist_entry *)
16548 (buf_ptr + WMI_TLV_HDR_SIZE);
16549
16550 /* Populate bssid, channel info and rssi
16551 * for the bssid's that are sent as hotlists.
16552 */
16553 for (j = 0; j < min_entries; j++) {
16554 WMITLV_SET_HDR(dest_hotlist,
16555 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16556 WMITLV_GET_STRUCT_TLVLEN
16557 (wmi_extscan_hotlist_entry));
16558
16559 dest_hotlist->min_rssi = src_ap->low;
16560 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16561 &dest_hotlist->bssid);
16562
Govind Singhb53420c2016-03-09 14:32:57 +053016563 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016564 __func__, dest_hotlist->channel,
16565 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016566 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016567 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16568 __func__, dest_hotlist->bssid.mac_addr31to0,
16569 dest_hotlist->bssid.mac_addr47to32);
16570 dest_hotlist++;
16571 src_ap++;
16572 }
16573 buf_ptr += WMI_TLV_HDR_SIZE +
16574 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16575
16576 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16577 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016578 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016579 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016580 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016581 }
16582 index = index + min_entries;
16583 num_entries = numap - min_entries;
16584 len = cmd_len;
16585 }
Govind Singhb53420c2016-03-09 14:32:57 +053016586 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016587}
16588
Govind Singhbca3b1b2016-05-02 17:59:24 +053016589/**
Dustin Brown4423f632017-01-13 15:24:07 -080016590 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16591 * @wmi_handle: the WMI handle
16592 * @vdev_id: the Id of the vdev to apply the configuration to
16593 * @ucast_mode: the active BPF mode to configure for unicast packets
16594 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16595 * packets
16596 *
16597 * Return: QDF status
16598 */
16599static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16600 uint8_t vdev_id,
16601 enum wmi_host_active_bpf_mode ucast_mode,
16602 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16603{
16604 const WMITLV_TAG_ID tag_id =
16605 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16606 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16607 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16608 QDF_STATUS status;
16609 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16610 wmi_buf_t buf;
16611
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016612 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016613 vdev_id, ucast_mode, mcast_bcast_mode);
16614
16615 /* allocate command buffer */
16616 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16617 if (!buf) {
16618 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16619 return QDF_STATUS_E_NOMEM;
16620 }
16621
16622 /* set TLV header */
16623 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16624 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16625
16626 /* populate data */
16627 cmd->vdev_id = vdev_id;
16628 cmd->uc_mode = ucast_mode;
16629 cmd->mcbc_mode = mcast_bcast_mode;
16630
16631 /* send to FW */
16632 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16633 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16634 if (QDF_IS_STATUS_ERROR(status)) {
16635 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16636 status);
16637 wmi_buf_free(buf);
16638 return status;
16639 }
16640
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016641 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016642
16643 return QDF_STATUS_SUCCESS;
16644}
16645
16646/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016647 * send_power_dbg_cmd_tlv() - send power debug commands
16648 * @wmi_handle: wmi handle
16649 * @param: wmi power debug parameter
16650 *
16651 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16652 *
16653 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16654 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016655static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16656 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016657{
16658 wmi_buf_t buf = NULL;
16659 QDF_STATUS status;
16660 int len, args_tlv_len;
16661 uint8_t *buf_ptr;
16662 uint8_t i;
16663 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16664 uint32_t *cmd_args;
16665
16666 /* Prepare and send power debug cmd parameters */
16667 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16668 len = sizeof(*cmd) + args_tlv_len;
16669 buf = wmi_buf_alloc(wmi_handle, len);
16670 if (!buf) {
16671 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16672 return QDF_STATUS_E_NOMEM;
16673 }
16674
16675 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16676 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16677 WMITLV_SET_HDR(&cmd->tlv_header,
16678 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16679 WMITLV_GET_STRUCT_TLVLEN
16680 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16681
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016682 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16683 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016684 cmd->module_id = param->module_id;
16685 cmd->num_args = param->num_args;
16686 buf_ptr += sizeof(*cmd);
16687 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16688 (param->num_args * sizeof(uint32_t)));
16689 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16690 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016691 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016692 cmd_args[i] = param->args[i];
16693 WMI_LOGI("%d,", param->args[i]);
16694 }
16695
16696 status = wmi_unified_cmd_send(wmi_handle, buf,
16697 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16698 if (QDF_IS_STATUS_ERROR(status)) {
16699 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16700 status);
16701 goto error;
16702 }
16703
16704 return QDF_STATUS_SUCCESS;
16705error:
16706 wmi_buf_free(buf);
16707
16708 return status;
16709}
16710
Govind Singhe7f2f342016-05-23 12:12:52 +053016711/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016712 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16713 * @wmi_handle: wmi handle
16714 * @param: wmi multiple vdev restart req param
16715 *
16716 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16717 *
16718 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16719 */
16720static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16721 wmi_unified_t wmi_handle,
16722 struct multiple_vdev_restart_params *param)
16723{
16724 wmi_buf_t buf;
16725 QDF_STATUS qdf_status;
16726 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16727 int i;
16728 uint8_t *buf_ptr;
16729 uint32_t *vdev_ids;
16730 wmi_channel *chan_info;
16731 struct channel_param *tchan_info;
16732 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16733
16734 len += sizeof(wmi_channel);
16735 if (param->num_vdevs)
16736 len += sizeof(uint32_t) * param->num_vdevs;
16737
16738 buf = wmi_buf_alloc(wmi_handle, len);
16739 if (!buf) {
16740 WMI_LOGE("Failed to allocate memory\n");
16741 qdf_status = QDF_STATUS_E_NOMEM;
16742 goto end;
16743 }
16744
16745 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16746 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16747 buf_ptr;
16748
16749 WMITLV_SET_HDR(&cmd->tlv_header,
16750 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16751 WMITLV_GET_STRUCT_TLVLEN
16752 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016753 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16754 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016755 cmd->requestor_id = param->requestor_id;
16756 cmd->disable_hw_ack = param->disable_hw_ack;
16757 cmd->cac_duration_ms = param->cac_duration_ms;
16758 cmd->num_vdevs = param->num_vdevs;
16759
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016760 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16761 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16762 " cmd->num_vdevs: %d ",
16763 __func__, cmd->pdev_id, cmd->requestor_id,
16764 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016765 buf_ptr += sizeof(*cmd);
16766
16767 WMITLV_SET_HDR(buf_ptr,
16768 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053016769 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016770 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16771 for (i = 0; i < param->num_vdevs; i++) {
16772 vdev_ids[i] = param->vdev_ids[i];
16773 }
16774
Vivekc5823092018-03-22 23:27:21 +053016775 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016776
16777 WMITLV_SET_HDR(buf_ptr,
16778 WMITLV_TAG_STRUC_wmi_channel,
16779 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016780 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016781 tchan_info = &(param->ch_param);
16782 chan_info->mhz = tchan_info->mhz;
16783 chan_info->band_center_freq1 = tchan_info->cfreq1;
16784 chan_info->band_center_freq2 = tchan_info->cfreq2;
16785 if (tchan_info->is_chan_passive)
16786 WMI_SET_CHANNEL_FLAG(chan_info,
16787 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016788 if (tchan_info->dfs_set)
16789 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16790
Sathish Kumar45e991b2017-02-27 10:35:40 +053016791 if (tchan_info->allow_vht)
16792 WMI_SET_CHANNEL_FLAG(chan_info,
16793 WMI_CHAN_FLAG_ALLOW_VHT);
16794 else if (tchan_info->allow_ht)
16795 WMI_SET_CHANNEL_FLAG(chan_info,
16796 WMI_CHAN_FLAG_ALLOW_HT);
16797 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16798 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16799 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16800 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16801 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16802 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016803 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016804
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016805 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16806 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16807 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16808 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16809 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16810 "tchan_info->reg_class_id: %d ,"
16811 "tchan_info->maxregpower : %d ", __func__,
16812 tchan_info->is_chan_passive, tchan_info->dfs_set,
16813 tchan_info->allow_vht, tchan_info->allow_ht,
16814 tchan_info->antennamax, tchan_info->phy_mode,
16815 tchan_info->minpower, tchan_info->maxpower,
16816 tchan_info->maxregpower, tchan_info->reg_class_id,
16817 tchan_info->maxregpower);
16818
Sathish Kumar45e991b2017-02-27 10:35:40 +053016819 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16820 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16821
16822 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16823 WMI_LOGE("%s: Failed to send\n", __func__);
16824 wmi_buf_free(buf);
16825 }
16826
16827end:
16828 return qdf_status;
16829}
16830
16831/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016832 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16833 * @wmi_handle: wmi handle
16834 * @pdev_id: pdev id
16835 *
16836 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16837 *
16838 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16839 */
16840static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16841 uint32_t pdev_id)
16842{
16843 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16844 wmi_buf_t buf;
16845 uint16_t len;
16846 QDF_STATUS ret;
16847
16848 len = sizeof(*cmd);
16849 buf = wmi_buf_alloc(wmi_handle, len);
16850
16851 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16852
16853 if (!buf) {
16854 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16855 return QDF_STATUS_E_NOMEM;
16856 }
16857
16858 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16859 wmi_buf_data(buf);
16860
16861 WMITLV_SET_HDR(&cmd->tlv_header,
16862 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16863 WMITLV_GET_STRUCT_TLVLEN(
16864 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16865
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016866 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016867 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16868 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16869 if (QDF_IS_STATUS_ERROR(ret)) {
16870 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16871 __func__, ret, pdev_id);
16872 wmi_buf_free(buf);
16873 return QDF_STATUS_E_FAILURE;
16874 }
16875
16876 return QDF_STATUS_SUCCESS;
16877}
16878
16879/**
16880 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16881 * @wmi_handle: wmi handle
16882 * @pdev_id: pdev id
16883 *
16884 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16885 *
16886 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16887 */
16888static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16889 uint32_t pdev_id)
16890{
16891 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16892 wmi_buf_t buf;
16893 uint16_t len;
16894 QDF_STATUS ret;
16895
16896 len = sizeof(*cmd);
16897 buf = wmi_buf_alloc(wmi_handle, len);
16898
16899 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16900
16901 if (!buf) {
16902 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16903 return QDF_STATUS_E_NOMEM;
16904 }
16905
16906 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16907 wmi_buf_data(buf);
16908
16909 WMITLV_SET_HDR(&cmd->tlv_header,
16910 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16911 WMITLV_GET_STRUCT_TLVLEN(
16912 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16913
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016914 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016915 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16916 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16917 if (QDF_IS_STATUS_ERROR(ret)) {
16918 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16919 __func__, ret, pdev_id);
16920 wmi_buf_free(buf);
16921 return QDF_STATUS_E_FAILURE;
16922 }
16923
16924 return QDF_STATUS_SUCCESS;
16925}
16926
16927/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016928 * init_cmd_send_tlv() - send initialization cmd to fw
16929 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016930 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016931 *
16932 * Return: QDF_STATUS_SUCCESS for success or error code
16933 */
16934static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016935 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016936{
16937 wmi_buf_t buf;
16938 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016939 uint8_t *buf_ptr;
16940 wmi_resource_config *resource_cfg;
16941 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016942 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016943 uint16_t idx;
16944 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016945 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016946
Kiran Venkatappa26117052016-12-23 19:58:54 +053016947 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16948 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016949 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016950
16951 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16952 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16953 WMI_TLV_HDR_SIZE +
16954 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16955
16956 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016957 if (!buf) {
16958 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16959 return QDF_STATUS_E_FAILURE;
16960 }
16961
16962 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16963 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16964 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16965
16966 host_mem_chunks = (wlan_host_memory_chunk *)
16967 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16968 + WMI_TLV_HDR_SIZE);
16969
16970 WMITLV_SET_HDR(&cmd->tlv_header,
16971 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16972 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16973
Kiran Venkatappa26117052016-12-23 19:58:54 +053016974 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016975 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16976 WMITLV_TAG_STRUC_wmi_resource_config,
16977 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16978
Kiran Venkatappa26117052016-12-23 19:58:54 +053016979 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016980 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16981 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16982 WMITLV_GET_STRUCT_TLVLEN
16983 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016984 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16985 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16986 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016987 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16988 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016989 idx, host_mem_chunks[idx].size,
16990 host_mem_chunks[idx].ptr);
16991 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016992 cmd->num_host_mem_chunks = param->num_mem_chunks;
16993 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16994
Govind Singhe7f2f342016-05-23 12:12:52 +053016995 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16996 WMITLV_TAG_ARRAY_STRUC,
16997 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016998 param->num_mem_chunks));
16999
17000 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017001 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053017002
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017003 /* Fill fw_abi_vers */
17004 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053017005
Abhishek Singh716c46c2016-05-04 16:24:07 +053017006 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
17007 if (QDF_IS_STATUS_ERROR(ret)) {
17008 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
17009 ret);
17010 wmi_buf_free(buf);
17011 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017012
Abhishek Singh716c46c2016-05-04 16:24:07 +053017013 return ret;
17014
Govind Singhe7f2f342016-05-23 12:12:52 +053017015}
17016
17017/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080017018 * send_addba_send_cmd_tlv() - send addba send command to fw
17019 * @wmi_handle: wmi handle
17020 * @param: pointer to delba send params
17021 * @macaddr: peer mac address
17022 *
17023 * Send WMI_ADDBA_SEND_CMDID command to firmware
17024 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17025 */
17026static QDF_STATUS
17027send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17028 uint8_t macaddr[IEEE80211_ADDR_LEN],
17029 struct addba_send_params *param)
17030{
17031 wmi_addba_send_cmd_fixed_param *cmd;
17032 wmi_buf_t buf;
17033 uint16_t len;
17034 QDF_STATUS ret;
17035
17036 len = sizeof(*cmd);
17037
17038 buf = wmi_buf_alloc(wmi_handle, len);
17039 if (!buf) {
17040 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17041 return QDF_STATUS_E_NOMEM;
17042 }
17043
17044 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17045
17046 WMITLV_SET_HDR(&cmd->tlv_header,
17047 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17048 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17049
17050 cmd->vdev_id = param->vdev_id;
17051 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17052 cmd->tid = param->tidno;
17053 cmd->buffersize = param->buffersize;
17054
17055 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17056 if (QDF_IS_STATUS_ERROR(ret)) {
17057 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17058 wmi_buf_free(buf);
17059 return QDF_STATUS_E_FAILURE;
17060 }
17061
17062 return QDF_STATUS_SUCCESS;
17063}
17064
17065/**
17066 * send_delba_send_cmd_tlv() - send delba send command to fw
17067 * @wmi_handle: wmi handle
17068 * @param: pointer to delba send params
17069 * @macaddr: peer mac address
17070 *
17071 * Send WMI_DELBA_SEND_CMDID command to firmware
17072 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17073 */
17074static QDF_STATUS
17075send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17076 uint8_t macaddr[IEEE80211_ADDR_LEN],
17077 struct delba_send_params *param)
17078{
17079 wmi_delba_send_cmd_fixed_param *cmd;
17080 wmi_buf_t buf;
17081 uint16_t len;
17082 QDF_STATUS ret;
17083
17084 len = sizeof(*cmd);
17085
17086 buf = wmi_buf_alloc(wmi_handle, len);
17087 if (!buf) {
17088 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17089 return QDF_STATUS_E_NOMEM;
17090 }
17091
17092 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17093
17094 WMITLV_SET_HDR(&cmd->tlv_header,
17095 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17096 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17097
17098 cmd->vdev_id = param->vdev_id;
17099 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17100 cmd->tid = param->tidno;
17101 cmd->initiator = param->initiator;
17102 cmd->reasoncode = param->reasoncode;
17103
17104 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17105 if (QDF_IS_STATUS_ERROR(ret)) {
17106 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17107 wmi_buf_free(buf);
17108 return QDF_STATUS_E_FAILURE;
17109 }
17110
17111 return QDF_STATUS_SUCCESS;
17112}
17113
17114/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017115 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17116 * to fw
17117 * @wmi_handle: wmi handle
17118 * @param: pointer to addba clearresp params
17119 * @macaddr: peer mac address
17120 * Return: 0 for success or error code
17121 */
17122static QDF_STATUS
17123send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17124 uint8_t macaddr[IEEE80211_ADDR_LEN],
17125 struct addba_clearresponse_params *param)
17126{
17127 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17128 wmi_buf_t buf;
17129 uint16_t len;
17130 QDF_STATUS ret;
17131
17132 len = sizeof(*cmd);
17133
17134 buf = wmi_buf_alloc(wmi_handle, len);
17135 if (!buf) {
17136 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17137 return QDF_STATUS_E_FAILURE;
17138 }
17139 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17140
17141 WMITLV_SET_HDR(&cmd->tlv_header,
17142 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17143 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17144
17145 cmd->vdev_id = param->vdev_id;
17146 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17147
17148 ret = wmi_unified_cmd_send(wmi_handle,
17149 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17150 if (QDF_IS_STATUS_ERROR(ret)) {
17151 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17152 wmi_buf_free(buf);
17153 return QDF_STATUS_E_FAILURE;
17154 }
17155
17156 return QDF_STATUS_SUCCESS;
17157}
17158
17159/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017160 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17161 * @wmi_handle: wmi handle
17162 * @bcn_ctrl_param: pointer to bcn_offload_control param
17163 *
17164 * Return: QDF_STATUS_SUCCESS for success or error code
17165 */
17166static
17167QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17168 struct bcn_offload_control *bcn_ctrl_param)
17169{
17170 wmi_buf_t buf;
17171 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17172 QDF_STATUS ret;
17173 uint32_t len;
17174
17175 len = sizeof(*cmd);
17176
17177 buf = wmi_buf_alloc(wmi_handle, len);
17178 if (!buf) {
17179 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17180 return QDF_STATUS_E_FAILURE;
17181 }
17182
17183 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17184 WMITLV_SET_HDR(&cmd->tlv_header,
17185 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17186 WMITLV_GET_STRUCT_TLVLEN
17187 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17188 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017189 switch (bcn_ctrl_param->bcn_ctrl_op) {
17190 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017191 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017192 break;
17193 case BCN_OFFLD_CTRL_TX_ENABLE:
17194 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17195 break;
17196 case BCN_OFFLD_CTRL_SWBA_DISABLE:
17197 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
17198 break;
17199 case BCN_OFFLD_CTRL_SWBA_ENABLE:
17200 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
17201 break;
17202 default:
17203 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
17204 bcn_ctrl_param->bcn_ctrl_op);
17205 wmi_buf_free(buf);
17206 return QDF_STATUS_E_FAILURE;
17207 break;
17208 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017209 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17210 WMI_BCN_OFFLOAD_CTRL_CMDID);
17211
17212 if (QDF_IS_STATUS_ERROR(ret)) {
17213 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17214 ret);
17215 wmi_buf_free(buf);
17216 }
17217
17218 return ret;
17219}
17220
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017221#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17222static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17223 struct nan_datapath_initiator_req *ndp_req)
17224{
17225 uint16_t len;
17226 wmi_buf_t buf;
17227 uint8_t *tlv_ptr;
17228 QDF_STATUS status;
17229 wmi_channel *ch_tlv;
17230 wmi_ndp_initiator_req_fixed_param *cmd;
17231 uint32_t passphrase_len, service_name_len;
17232 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17233
17234 /*
17235 * WMI command expects 4 byte alligned len:
17236 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17237 */
17238 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17239 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17240 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17241 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17242 service_name_len =
17243 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17244 /* allocated memory for fixed params as well as variable size data */
17245 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17246 + ndp_cfg_len + ndp_app_info_len + pmk_len
17247 + passphrase_len + service_name_len;
17248
17249 buf = wmi_buf_alloc(wmi_handle, len);
17250 if (!buf) {
17251 WMI_LOGE("wmi_buf_alloc failed");
17252 return QDF_STATUS_E_NOMEM;
17253 }
17254
17255 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17256 WMITLV_SET_HDR(&cmd->tlv_header,
17257 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17258 WMITLV_GET_STRUCT_TLVLEN(
17259 wmi_ndp_initiator_req_fixed_param));
17260 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17261 cmd->transaction_id = ndp_req->transaction_id;
17262 cmd->service_instance_id = ndp_req->service_instance_id;
17263 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17264 &cmd->peer_discovery_mac_addr);
17265
17266 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17267 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17268 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17269 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17270 cmd->nan_csid = ndp_req->ncs_sk_type;
17271 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17272 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17273
17274 ch_tlv = (wmi_channel *)&cmd[1];
17275 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17276 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17277 ch_tlv->mhz = ndp_req->channel;
17278 tlv_ptr = (uint8_t *)&ch_tlv[1];
17279
17280 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17281 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17282 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17283 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17284
17285 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17286 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17287 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17288 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17289
17290 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17291 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17292 cmd->nan_pmk_len);
17293 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17294
17295 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17296 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17297 cmd->nan_passphrase_len);
17298 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17299
17300 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17301 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17302 ndp_req->service_name.service_name,
17303 cmd->nan_servicename_len);
17304 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17305
17306 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17307 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17308 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17309 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17310 cmd->peer_discovery_mac_addr.mac_addr31to0,
17311 cmd->peer_discovery_mac_addr.mac_addr47to32);
17312
17313 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17314 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17315 ndp_req->ndp_config.ndp_cfg,
17316 ndp_req->ndp_config.ndp_cfg_len);
17317
17318 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17319 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17320 ndp_req->ndp_info.ndp_app_info,
17321 ndp_req->ndp_info.ndp_app_info_len);
17322
17323 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17324 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17325 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17326
17327 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17328 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17329 ndp_req->passphrase.passphrase,
17330 cmd->nan_passphrase_len);
17331
17332 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17333 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17334 ndp_req->service_name.service_name,
17335 cmd->nan_servicename_len);
17336
17337 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17338 WMI_NDP_INITIATOR_REQ_CMDID);
17339
17340 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17341 WMI_NDP_INITIATOR_REQ_CMDID);
17342 if (QDF_IS_STATUS_ERROR(status)) {
17343 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17344 wmi_buf_free(buf);
17345 }
17346
17347 return status;
17348}
17349
17350static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17351 struct nan_datapath_responder_req *req)
17352{
17353 uint16_t len;
17354 wmi_buf_t buf;
17355 uint8_t *tlv_ptr;
17356 QDF_STATUS status;
17357 wmi_ndp_responder_req_fixed_param *cmd;
17358 uint32_t passphrase_len, service_name_len;
17359 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17360
17361 vdev_id = wlan_vdev_get_id(req->vdev);
17362 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17363 vdev_id, req->transaction_id,
17364 req->ndp_rsp,
17365 req->ndp_instance_id,
17366 req->ndp_info.ndp_app_info_len);
17367
17368 /*
17369 * WMI command expects 4 byte alligned len:
17370 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17371 */
17372 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17373 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17374 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17375 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17376 service_name_len =
17377 qdf_roundup(req->service_name.service_name_len, 4);
17378
17379 /* allocated memory for fixed params as well as variable size data */
17380 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17381 + pmk_len + passphrase_len + service_name_len;
17382
17383 buf = wmi_buf_alloc(wmi_handle, len);
17384 if (!buf) {
17385 WMI_LOGE("wmi_buf_alloc failed");
17386 return QDF_STATUS_E_NOMEM;
17387 }
17388 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17389 WMITLV_SET_HDR(&cmd->tlv_header,
17390 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17391 WMITLV_GET_STRUCT_TLVLEN(
17392 wmi_ndp_responder_req_fixed_param));
17393 cmd->vdev_id = vdev_id;
17394 cmd->transaction_id = req->transaction_id;
17395 cmd->ndp_instance_id = req->ndp_instance_id;
17396 cmd->rsp_code = req->ndp_rsp;
17397 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17398 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17399 cmd->nan_pmk_len = req->pmk.pmk_len;
17400 cmd->nan_csid = req->ncs_sk_type;
17401 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17402 cmd->nan_servicename_len = req->service_name.service_name_len;
17403
17404 tlv_ptr = (uint8_t *)&cmd[1];
17405 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17406 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17407 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17408
17409 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17410 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17411 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17412 req->ndp_info.ndp_app_info,
17413 req->ndp_info.ndp_app_info_len);
17414
17415 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17416 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17417 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17418 cmd->nan_pmk_len);
17419
17420 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17421 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17422 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17423 req->passphrase.passphrase,
17424 cmd->nan_passphrase_len);
17425 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17426
17427 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17428 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17429 req->service_name.service_name,
17430 cmd->nan_servicename_len);
17431
17432 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17433
17434 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17435 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17436
17437 WMI_LOGD("ndp_config len: %d",
17438 req->ndp_config.ndp_cfg_len);
17439 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17440 req->ndp_config.ndp_cfg,
17441 req->ndp_config.ndp_cfg_len);
17442
17443 WMI_LOGD("ndp_app_info len: %d",
17444 req->ndp_info.ndp_app_info_len);
17445 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17446 req->ndp_info.ndp_app_info,
17447 req->ndp_info.ndp_app_info_len);
17448
17449 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17450 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17451 req->pmk.pmk, cmd->nan_pmk_len);
17452
17453 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17454 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17455 req->passphrase.passphrase,
17456 cmd->nan_passphrase_len);
17457
17458 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17459 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17460 req->service_name.service_name,
17461 cmd->nan_servicename_len);
17462
17463 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17464 WMI_NDP_RESPONDER_REQ_CMDID);
17465 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17466 WMI_NDP_RESPONDER_REQ_CMDID);
17467 if (QDF_IS_STATUS_ERROR(status)) {
17468 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17469 wmi_buf_free(buf);
17470 }
17471 return status;
17472}
17473
17474static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17475 struct nan_datapath_end_req *req)
17476{
17477 uint16_t len;
17478 wmi_buf_t buf;
17479 QDF_STATUS status;
17480 uint32_t ndp_end_req_len, i;
17481 wmi_ndp_end_req *ndp_end_req_lst;
17482 wmi_ndp_end_req_fixed_param *cmd;
17483
17484 /* len of tlv following fixed param */
17485 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17486 /* above comes out to 4 byte alligned already, no need of padding */
17487 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17488 buf = wmi_buf_alloc(wmi_handle, len);
17489 if (!buf) {
17490 WMI_LOGE("Malloc failed");
17491 return QDF_STATUS_E_NOMEM;
17492 }
17493
17494 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17495 WMITLV_SET_HDR(&cmd->tlv_header,
17496 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17497 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17498
17499 cmd->transaction_id = req->transaction_id;
17500
17501 /* set tlv pointer to end of fixed param */
17502 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17503 ndp_end_req_len);
17504
17505 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17506 WMI_TLV_HDR_SIZE);
17507 for (i = 0; i < req->num_ndp_instances; i++) {
17508 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17509 WMITLV_TAG_ARRAY_FIXED_STRUC,
17510 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17511
17512 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17513 }
17514
17515 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17516 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17517 WMI_NDP_END_REQ_CMDID);
17518 if (QDF_IS_STATUS_ERROR(status)) {
17519 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17520 wmi_buf_free(buf);
17521 }
17522
17523 return status;
17524}
17525
17526static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017527 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017528{
17529 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17530 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17531
17532 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17533 fixed_params = event->fixed_param;
17534
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017535 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017536 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17537 fixed_params->vdev_id,
17538 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017539 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017540 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017541 return QDF_STATUS_E_INVAL;
17542 }
17543
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017544 rsp->transaction_id = fixed_params->transaction_id;
17545 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17546 rsp->status = fixed_params->rsp_status;
17547 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017548
17549 return QDF_STATUS_SUCCESS;
17550}
17551
17552static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017553 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017554{
17555 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17556 wmi_ndp_indication_event_fixed_param *fixed_params;
17557
17558 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17559 fixed_params =
17560 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17561
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017562 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17563 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17564 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17565 return QDF_STATUS_E_INVAL;
17566 }
17567
17568 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17569 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17570 fixed_params->ndp_app_info_len,
17571 event->num_ndp_app_info);
17572 return QDF_STATUS_E_INVAL;
17573 }
17574
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017575 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017576 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17577 fixed_params->vdev_id,
17578 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017579 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017580 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017581 return QDF_STATUS_E_INVAL;
17582 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017583 rsp->service_instance_id = fixed_params->service_instance_id;
17584 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17585 rsp->role = fixed_params->self_ndp_role;
17586 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017587
17588 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017589 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017590 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017591 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017592
17593 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17594 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17595 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17596 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17597 fixed_params->service_instance_id,
17598 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17599 fixed_params->accept_policy,
17600 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017601 rsp->peer_mac_addr.bytes,
17602 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017603
17604 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17605 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17606 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17607
17608 WMI_LOGD("ndp_app_info - %d bytes",
17609 fixed_params->ndp_app_info_len);
17610 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17611 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17612
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017613 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17614 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17615 rsp->ncs_sk_type = fixed_params->nan_csid;
17616 rsp->scid.scid_len = fixed_params->nan_scid_len;
17617 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
17618 rsp->ndp_config.ndp_cfg_len);
17619 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17620 rsp->ndp_info.ndp_app_info_len);
17621 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017622 WMI_LOGD("scid hex dump:");
17623 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017624 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017625
17626 return QDF_STATUS_SUCCESS;
17627}
17628
17629static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017630 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017631{
17632 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17633 wmi_ndp_confirm_event_fixed_param *fixed_params;
17634
17635 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17636 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17637 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) recieved. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
17638 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17639 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17640 fixed_params->reason_code,
17641 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017642
17643 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17644 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17645 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17646 return QDF_STATUS_E_INVAL;
17647 }
17648
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017649 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17650 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17651 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17652
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017653 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17654 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17655 fixed_params->ndp_app_info_len,
17656 event->num_ndp_app_info);
17657 return QDF_STATUS_E_INVAL;
17658 }
17659
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017660 WMI_LOGD("ndp_app_info - %d bytes",
17661 fixed_params->ndp_app_info_len);
17662 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17663 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17664
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017665 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017666 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17667 fixed_params->vdev_id,
17668 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017669 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017670 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017671 return QDF_STATUS_E_INVAL;
17672 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017673 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17674 rsp->rsp_code = fixed_params->rsp_code;
17675 rsp->reason_code = fixed_params->reason_code;
17676 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017677 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017678 rsp->peer_ndi_mac_addr.bytes);
17679 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17680 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17681 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017682
17683 return QDF_STATUS_SUCCESS;
17684}
17685
17686static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017687 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017688{
17689 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17690 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17691
17692 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17693 fixed_params = event->fixed_param;
17694
17695 WMI_LOGD("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: %pM,transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
17696 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017697 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17698 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017699
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017700 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017701 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17702 fixed_params->vdev_id,
17703 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017704 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017705 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017706 return QDF_STATUS_E_INVAL;
17707 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017708 rsp->transaction_id = fixed_params->transaction_id;
17709 rsp->reason = fixed_params->reason_code;
17710 rsp->status = fixed_params->rsp_status;
17711 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017712 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017713 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017714
17715 return QDF_STATUS_SUCCESS;
17716}
17717
17718static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017719 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017720{
17721 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17722 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17723
17724 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17725 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17726 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17727 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17728 fixed_params->rsp_status, fixed_params->reason_code);
17729
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017730 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017731 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017732 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017733 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017734 return QDF_STATUS_E_INVAL;
17735 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017736 rsp->transaction_id = fixed_params->transaction_id;
17737 rsp->reason = fixed_params->reason_code;
17738 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017739
17740 return QDF_STATUS_SUCCESS;
17741}
17742
17743static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17744 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17745{
17746 uint32_t i, buf_size;
17747 wmi_ndp_end_indication *ind;
17748 struct qdf_mac_addr peer_addr;
17749 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17750
17751 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17752 ind = event->ndp_end_indication_list;
17753
17754 if (event->num_ndp_end_indication_list == 0) {
17755 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017756 return QDF_STATUS_E_INVAL;
17757 }
17758
17759 WMI_LOGD("number of ndp instances = %d",
17760 event->num_ndp_end_indication_list);
17761
17762 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17763 sizeof((*rsp)->ndp_map[0]))) {
17764 WMI_LOGE("num_ndp_end_ind_list %d too large",
17765 event->num_ndp_end_indication_list);
17766 return QDF_STATUS_E_INVAL;
17767 }
17768
17769 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17770 sizeof((*rsp)->ndp_map[0]);
17771 *rsp = qdf_mem_malloc(buf_size);
17772 if (!(*rsp)) {
17773 WMI_LOGE("Failed to allocate memory");
17774 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017775 }
17776
17777 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17778 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17779 if (!(*rsp)->vdev) {
17780 WMI_LOGE("vdev is null");
17781 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017782 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017783 return QDF_STATUS_E_INVAL;
17784 }
17785
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017786 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17787 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17788 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17789 peer_addr.bytes);
17790 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17791 i, ind[i].type, ind[i].reason_code,
17792 ind[i].ndp_instance_id,
17793 ind[i].num_active_ndps_on_peer);
17794 /* Add each instance entry to the list */
17795 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17796 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17797 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17798 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17799 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17800 ind[i].num_active_ndps_on_peer;
17801 (*rsp)->ndp_map[i].type = ind[i].type;
17802 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17803 }
17804
17805 return QDF_STATUS_SUCCESS;
17806}
17807#endif
17808
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017809/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017810 * save_service_bitmap_tlv() - save service bitmap
17811 * @wmi_handle: wmi handle
17812 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017813 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017814 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017815 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017816 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017817static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017818QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017819 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017820{
17821 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017822 struct wmi_soc *soc = wmi_handle->soc;
17823
Govind Singhe7f2f342016-05-23 12:12:52 +053017824 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17825
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017826 /* If it is already allocated, use that buffer. This can happen
17827 * during target stop/start scenarios where host allocation is skipped.
17828 */
17829 if (!soc->wmi_service_bitmap) {
17830 soc->wmi_service_bitmap =
17831 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17832 if (!soc->wmi_service_bitmap) {
17833 WMI_LOGE("Failed memory allocation for service bitmap");
17834 return QDF_STATUS_E_NOMEM;
17835 }
17836 }
17837
17838 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017839 param_buf->wmi_service_bitmap,
17840 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017841
17842 if (bitmap_buf)
17843 qdf_mem_copy(bitmap_buf,
17844 param_buf->wmi_service_bitmap,
17845 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017846
17847 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017848}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017849
17850/**
17851 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17852 * @wmi_handle: wmi handle
17853 * @param evt_buf: pointer to event buffer
17854 * @param bitmap_buf: bitmap buffer, for converged legacy support
17855 *
17856 * Return: QDF_STATUS
17857 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017858static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017859QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017860 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017861{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017862 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17863 wmi_service_available_event_fixed_param *ev;
17864 struct wmi_soc *soc = wmi_handle->soc;
17865
17866 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17867
17868 ev = param_buf->fixed_param;
17869
17870 /* If it is already allocated, use that buffer. This can happen
17871 * during target stop/start scenarios where host allocation is skipped.
17872 */
17873 if (!soc->wmi_ext_service_bitmap) {
17874 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17875 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17876 if (!soc->wmi_ext_service_bitmap) {
17877 WMI_LOGE("Failed memory allocation for service bitmap");
17878 return QDF_STATUS_E_NOMEM;
17879 }
17880 }
17881
17882 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17883 ev->wmi_service_segment_bitmap,
17884 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017885
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017886 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17887 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17888 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17889
Rajeev Kumar77901472017-02-12 02:12:17 -080017890 if (bitmap_buf)
17891 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017892 soc->wmi_ext_service_bitmap,
17893 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017894
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017895 return QDF_STATUS_SUCCESS;
17896}
Govind Singhe7f2f342016-05-23 12:12:52 +053017897/**
17898 * is_service_enabled_tlv() - Check if service enabled
17899 * @param wmi_handle: wmi handle
17900 * @param service_id: service identifier
17901 *
17902 * Return: 1 enabled, 0 disabled
17903 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017904static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17905 uint32_t service_id)
17906{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017907 struct wmi_soc *soc = wmi_handle->soc;
17908
17909 if (!soc->wmi_service_bitmap) {
17910 WMI_LOGE("WMI service bit map is not saved yet\n");
17911 return false;
17912 }
17913
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017914 /* if wmi_service_enabled was received with extended bitmap,
17915 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017916 */
17917 if (soc->wmi_ext_service_bitmap)
17918 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17919 soc->wmi_ext_service_bitmap,
17920 service_id);
17921
17922 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17923 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017924}
Govind Singhe7f2f342016-05-23 12:12:52 +053017925
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017926static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17927 struct wlan_psoc_target_capability_info *cap)
17928{
17929 /* except LDPC all flags are common betwen legacy and here
17930 * also IBFEER is not defined for TLV
17931 */
17932 cap->ht_cap_info |= ev_target_cap & (
17933 WMI_HT_CAP_ENABLED
17934 | WMI_HT_CAP_HT20_SGI
17935 | WMI_HT_CAP_DYNAMIC_SMPS
17936 | WMI_HT_CAP_TX_STBC
17937 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17938 | WMI_HT_CAP_RX_STBC
17939 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17940 | WMI_HT_CAP_LDPC
17941 | WMI_HT_CAP_L_SIG_TXOP_PROT
17942 | WMI_HT_CAP_MPDU_DENSITY
17943 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17944 | WMI_HT_CAP_HT40_SGI);
17945 if (ev_target_cap & WMI_HT_CAP_LDPC)
17946 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17947 WMI_HOST_HT_CAP_TX_LDPC;
17948}
Govind Singhe7f2f342016-05-23 12:12:52 +053017949/**
17950 * extract_service_ready_tlv() - extract service ready event
17951 * @wmi_handle: wmi handle
17952 * @param evt_buf: pointer to received event buffer
17953 * @param cap: pointer to hold target capability information extracted from even
17954 *
17955 * Return: QDF_STATUS_SUCCESS for success or error code
17956 */
17957static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017958 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017959{
17960 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17961 wmi_service_ready_event_fixed_param *ev;
17962
17963
17964 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17965
17966 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17967 if (!ev) {
17968 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17969 return QDF_STATUS_E_FAILURE;
17970 }
17971
17972 cap->phy_capability = ev->phy_capability;
17973 cap->max_frag_entry = ev->max_frag_entry;
17974 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017975 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017976 cap->vht_cap_info = ev->vht_cap_info;
17977 cap->vht_supp_mcs = ev->vht_supp_mcs;
17978 cap->hw_min_tx_power = ev->hw_min_tx_power;
17979 cap->hw_max_tx_power = ev->hw_max_tx_power;
17980 cap->sys_cap_info = ev->sys_cap_info;
17981 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17982 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17983 cap->max_num_scan_channels = ev->max_num_scan_channels;
17984 cap->max_supported_macs = ev->max_supported_macs;
17985 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17986 cap->txrx_chainmask = ev->txrx_chainmask;
17987 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17988 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017989 cap->fw_version = ev->fw_build_vers;
17990 /* fw_version_1 is not available in TLV. */
17991 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017992
17993 return QDF_STATUS_SUCCESS;
17994}
17995
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017996/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17997 * to host internal WMI_HOST_REGDMN_MODE values.
17998 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17999 * host currently. Add this in the future if required.
18000 * 11AX (Phase II) : 11ax related values are not currently
18001 * advertised separately by FW. As part of phase II regulatory bring-up,
18002 * finalize the advertisement mechanism.
18003 * @target_wireless_mode: target wireless mode received in message
18004 *
18005 * Return: returns the host internal wireless mode.
18006 */
18007static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
18008{
18009
18010 uint32_t wireless_modes = 0;
18011
18012 if (target_wireless_mode & REGDMN_MODE_11A)
18013 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
18014
18015 if (target_wireless_mode & REGDMN_MODE_TURBO)
18016 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
18017
18018 if (target_wireless_mode & REGDMN_MODE_11B)
18019 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
18020
18021 if (target_wireless_mode & REGDMN_MODE_PUREG)
18022 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
18023
18024 if (target_wireless_mode & REGDMN_MODE_11G)
18025 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18026
18027 if (target_wireless_mode & REGDMN_MODE_108G)
18028 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18029
18030 if (target_wireless_mode & REGDMN_MODE_108A)
18031 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18032
18033 if (target_wireless_mode & REGDMN_MODE_XR)
18034 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18035
18036 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18037 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18038
18039 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18040 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18041
18042 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18043 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18044
18045 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18046 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18047
18048 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18049 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18050
18051 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18052 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18053
18054 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18055 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18056
18057 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18058 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18059
18060 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18061 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18062
18063 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18064 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18065
18066 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18067 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18068
18069 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18070 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18071
18072 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18073 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18074
18075 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18076 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18077
18078 return wireless_modes;
18079}
18080
Govind Singhe7f2f342016-05-23 12:12:52 +053018081/**
18082 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18083 * @wmi_handle: wmi handle
18084 * @param evt_buf: Pointer to event buffer
18085 * @param cap: pointer to hold HAL reg capabilities
18086 *
18087 * Return: QDF_STATUS_SUCCESS for success or error code
18088 */
18089static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018090 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018091{
18092 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18093
18094 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18095
18096 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18097 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018098 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018099
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018100 cap->wireless_modes = convert_wireless_modes_tlv(
18101 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018102
Govind Singhe7f2f342016-05-23 12:12:52 +053018103 return QDF_STATUS_SUCCESS;
18104}
18105
18106/**
18107 * extract_host_mem_req_tlv() - Extract host memory request event
18108 * @wmi_handle: wmi handle
18109 * @param evt_buf: pointer to event buffer
18110 * @param num_entries: pointer to hold number of entries requested
18111 *
18112 * Return: Number of entries requested
18113 */
18114static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18115 void *evt_buf, uint8_t *num_entries)
18116{
18117 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18118 wmi_service_ready_event_fixed_param *ev;
18119
18120 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18121
18122 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18123 if (!ev) {
18124 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18125 return NULL;
18126 }
18127
18128 *num_entries = ev->num_mem_reqs;
18129
18130 return (host_mem_req *)param_buf->mem_reqs;
18131}
18132
18133/**
18134 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18135 * ready function
18136 * @wmi_handle: wmi handle
18137 * @param evt_buf: pointer to event buffer
18138 *
18139 * Return: QDF_STATUS_SUCCESS for success or error code
18140 */
18141static QDF_STATUS
18142save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18143{
18144 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18145 wmi_service_ready_event_fixed_param *ev;
18146
18147
18148 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18149
18150 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18151 if (!ev) {
18152 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18153 return QDF_STATUS_E_FAILURE;
18154 }
18155
18156 /*Save fw version from service ready message */
18157 /*This will be used while sending INIT message */
18158 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18159 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018160
Govind Singhe7f2f342016-05-23 12:12:52 +053018161 return QDF_STATUS_SUCCESS;
18162}
18163
18164/**
18165 * ready_extract_init_status_tlv() - Extract init status from ready event
18166 * @wmi_handle: wmi handle
18167 * @param evt_buf: Pointer to event buffer
18168 *
18169 * Return: ready status
18170 */
18171static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18172 void *evt_buf)
18173{
18174 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18175 wmi_ready_event_fixed_param *ev = NULL;
18176
Govind Singhe7f2f342016-05-23 12:12:52 +053018177 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18178 ev = param_buf->fixed_param;
18179
18180 qdf_print("%s:%d\n", __func__, ev->status);
18181
18182 return ev->status;
18183}
18184
18185/**
18186 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18187 * @wmi_handle: wmi handle
18188 * @param evt_buf: pointer to event buffer
18189 * @param macaddr: Pointer to hold MAC address
18190 *
18191 * Return: QDF_STATUS_SUCCESS for success or error code
18192 */
18193static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18194 void *evt_buf, uint8_t *macaddr)
18195{
18196 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18197 wmi_ready_event_fixed_param *ev = NULL;
18198
18199
18200 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18201 ev = param_buf->fixed_param;
18202
18203 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18204
18205 return QDF_STATUS_SUCCESS;
18206}
18207
18208/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018209 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18210 * @wmi_handle: wmi handle
18211 * @param evt_buf: pointer to event buffer
18212 * @param macaddr: Pointer to hold number of MAC addresses
18213 *
18214 * Return: Pointer to addr list
18215 */
18216static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18217 void *evt_buf, uint8_t *num_mac)
18218{
18219 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18220 wmi_ready_event_fixed_param *ev = NULL;
18221
18222 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18223 ev = param_buf->fixed_param;
18224
18225 *num_mac = ev->num_extra_mac_addr;
18226
18227 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18228}
18229
18230/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018231 * extract_ready_params_tlv() - Extract data from ready event apart from
18232 * status, macaddr and version.
18233 * @wmi_handle: Pointer to WMI handle.
18234 * @evt_buf: Pointer to Ready event buffer.
18235 * @ev_param: Pointer to host defined struct to copy the data from event.
18236 *
18237 * Return: QDF_STATUS_SUCCESS on success.
18238 */
18239static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18240 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18241{
18242 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18243 wmi_ready_event_fixed_param *ev = NULL;
18244
18245 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18246 ev = param_buf->fixed_param;
18247
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018248 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018249 ev_param->num_dscp_table = ev->num_dscp_table;
18250 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18251 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018252 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018253 /* Agile_cap in ready event is not supported in TLV target */
18254 ev_param->agile_capability = false;
18255
18256 return QDF_STATUS_SUCCESS;
18257}
18258
18259/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018260 * extract_dbglog_data_len_tlv() - extract debuglog data length
18261 * @wmi_handle: wmi handle
18262 * @param evt_buf: pointer to event buffer
18263 *
18264 * Return: length
18265 */
18266static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018267 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018268{
18269 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18270
18271 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18272
18273 *len = param_buf->num_bufp;
18274
18275 return param_buf->bufp;
18276}
18277
18278/**
18279 * extract_vdev_start_resp_tlv() - extract vdev start response
18280 * @wmi_handle: wmi handle
18281 * @param evt_buf: pointer to event buffer
18282 * @param vdev_rsp: Pointer to hold vdev response
18283 *
18284 * Return: QDF_STATUS_SUCCESS for success or error code
18285 */
18286static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18287 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18288{
18289 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18290 wmi_vdev_start_response_event_fixed_param *ev;
18291
18292 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18293 if (!param_buf) {
18294 qdf_print("Invalid start response event buffer\n");
18295 return QDF_STATUS_E_INVAL;
18296 }
18297
18298 ev = param_buf->fixed_param;
18299 if (!ev) {
18300 qdf_print("Invalid start response event buffer\n");
18301 return QDF_STATUS_E_INVAL;
18302 }
18303
18304 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18305
18306 vdev_rsp->vdev_id = ev->vdev_id;
18307 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018308 switch (ev->resp_type) {
18309 case WMI_VDEV_START_RESP_EVENT:
18310 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18311 break;
18312 case WMI_VDEV_RESTART_RESP_EVENT:
18313 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18314 break;
18315 default:
18316 qdf_print("Invalid start response event buffer\n");
18317 break;
18318 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018319 vdev_rsp->status = ev->status;
18320 vdev_rsp->chain_mask = ev->chain_mask;
18321 vdev_rsp->smps_mode = ev->smps_mode;
18322 vdev_rsp->mac_id = ev->mac_id;
18323 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18324 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18325
18326 return QDF_STATUS_SUCCESS;
18327}
18328
18329/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018330 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18331 * @wmi_handle: wmi handle
18332 * @param evt_buf: pointer to event buffer
18333 * @param delete_rsp: Pointer to hold vdev delete response
18334 *
18335 * Return: QDF_STATUS_SUCCESS for success or error code
18336 */
18337static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18338 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18339{
18340 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18341 wmi_vdev_delete_resp_event_fixed_param *ev;
18342
18343 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18344 if (!param_buf) {
18345 WMI_LOGE("Invalid vdev delete response event buffer\n");
18346 return QDF_STATUS_E_INVAL;
18347 }
18348
18349 ev = param_buf->fixed_param;
18350 if (!ev) {
18351 WMI_LOGE("Invalid vdev delete response event\n");
18352 return QDF_STATUS_E_INVAL;
18353 }
18354
18355 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18356 delete_rsp->vdev_id = ev->vdev_id;
18357
18358 return QDF_STATUS_SUCCESS;
18359}
18360
18361
18362/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018363 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018364 * @wmi_handle: wmi handle
18365 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018366 * @param num_vdevs: Pointer to hold num vdev
18367 *
18368 * Return: QDF_STATUS_SUCCESS for success or error code
18369 */
18370static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18371 void *evt_buf, uint32_t *num_vdevs)
18372{
18373 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18374 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18375 uint32_t vdev_map;
18376
18377 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18378 if (!param_buf) {
18379 qdf_print("Invalid tbtt update ext event buffer\n");
18380 return QDF_STATUS_E_INVAL;
18381 }
18382 tbtt_offset_event = param_buf->fixed_param;
18383 vdev_map = tbtt_offset_event->vdev_map;
18384 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18385
18386 return QDF_STATUS_SUCCESS;
18387}
18388
18389/**
18390 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18391 * @wmi_handle: wmi handle
18392 * @param evt_buf: pointer to event buffer
18393 * @param num_vdevs: Pointer to hold num vdev
18394 *
18395 * Return: QDF_STATUS_SUCCESS for success or error code
18396 */
18397static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18398 void *evt_buf, uint32_t *num_vdevs)
18399{
18400 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18401 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18402
18403 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18404 if (!param_buf) {
18405 qdf_print("Invalid tbtt update ext event buffer\n");
18406 return QDF_STATUS_E_INVAL;
18407 }
18408 tbtt_offset_ext_event = param_buf->fixed_param;
18409
18410 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18411
18412 return QDF_STATUS_SUCCESS;
18413}
18414
18415/**
18416 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18417 * @wmi_handle: wmi handle
18418 * @param evt_buf: pointer to event buffer
18419 * @param idx: Index refering to a vdev
18420 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018421 *
18422 * Return: QDF_STATUS_SUCCESS for success or error code
18423 */
18424static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018425 void *evt_buf, uint8_t idx,
18426 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018427{
18428 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18429 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018430 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018431
18432 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18433 if (!param_buf) {
18434 qdf_print("Invalid tbtt update event buffer\n");
18435 return QDF_STATUS_E_INVAL;
18436 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018437
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018438 tbtt_offset_event = param_buf->fixed_param;
18439 vdev_map = tbtt_offset_event->vdev_map;
18440 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18441 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18442 return QDF_STATUS_E_INVAL;
18443 tbtt_param->tbttoffset =
18444 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18445
18446 return QDF_STATUS_SUCCESS;
18447}
18448
18449/**
18450 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18451 * @wmi_handle: wmi handle
18452 * @param evt_buf: pointer to event buffer
18453 * @param idx: Index refering to a vdev
18454 * @param tbtt_param: Pointer to tbttoffset event param
18455 *
18456 * Return: QDF_STATUS_SUCCESS for success or error code
18457 */
18458static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18459 void *evt_buf, uint8_t idx,
18460 struct tbttoffset_params *tbtt_param)
18461{
18462 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18463 wmi_tbtt_offset_info *tbtt_offset_info;
18464
18465 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18466 if (!param_buf) {
18467 qdf_print("Invalid tbtt update event buffer\n");
18468 return QDF_STATUS_E_INVAL;
18469 }
18470 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18471
18472 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18473 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018474
18475 return QDF_STATUS_SUCCESS;
18476}
18477
18478/**
18479 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18480 * @wmi_handle: wmi handle
18481 * @param evt_buf: pointer to event buffer
18482 * @param hdr: Pointer to hold header
18483 * @param bufp: Pointer to hold pointer to rx param buffer
18484 *
18485 * Return: QDF_STATUS_SUCCESS for success or error code
18486 */
18487static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018488 void *evt_buf, struct mgmt_rx_event_params *hdr,
18489 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018490{
18491 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18492 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018493 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018494
18495 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18496 if (!param_tlvs) {
18497 WMI_LOGE("Get NULL point message from FW");
18498 return QDF_STATUS_E_INVAL;
18499 }
18500
18501 ev_hdr = param_tlvs->hdr;
18502 if (!hdr) {
18503 WMI_LOGE("Rx event is NULL");
18504 return QDF_STATUS_E_INVAL;
18505 }
18506
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018507 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18508 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018509
18510 hdr->channel = ev_hdr->channel;
18511 hdr->snr = ev_hdr->snr;
18512 hdr->rate = ev_hdr->rate;
18513 hdr->phy_mode = ev_hdr->phy_mode;
18514 hdr->buf_len = ev_hdr->buf_len;
18515 hdr->status = ev_hdr->status;
18516 hdr->flags = ev_hdr->flags;
18517 hdr->rssi = ev_hdr->rssi;
18518 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018519 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18520 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018521
18522 *bufp = param_tlvs->bufp;
18523
18524 return QDF_STATUS_SUCCESS;
18525}
18526
18527/**
18528 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18529 * @wmi_handle: wmi handle
18530 * @param evt_buf: pointer to event buffer
18531 * @param vdev_id: Pointer to hold vdev identifier
18532 *
18533 * Return: QDF_STATUS_SUCCESS for success or error code
18534 */
18535static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18536 void *evt_buf, uint32_t *vdev_id)
18537{
18538 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18539 wmi_vdev_stopped_event_fixed_param *resp_event;
18540
18541 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18542 if (!param_buf) {
18543 WMI_LOGE("Invalid event buffer");
18544 return QDF_STATUS_E_INVAL;
18545 }
18546 resp_event = param_buf->fixed_param;
18547 *vdev_id = resp_event->vdev_id;
18548
18549 return QDF_STATUS_SUCCESS;
18550}
18551
18552/**
18553 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18554 * @wmi_handle: wmi handle
18555 * @param evt_buf: pointer to event buffer
18556 * @param param: Pointer to hold roam param
18557 *
18558 * Return: QDF_STATUS_SUCCESS for success or error code
18559 */
18560static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18561 void *evt_buf, wmi_host_roam_event *param)
18562{
18563 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18564 wmi_roam_event_fixed_param *evt;
18565
18566 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18567 if (!param_buf) {
18568 WMI_LOGE("Invalid roam event buffer");
18569 return QDF_STATUS_E_INVAL;
18570 }
18571
18572 evt = param_buf->fixed_param;
18573 qdf_mem_zero(param, sizeof(*param));
18574
18575 param->vdev_id = evt->vdev_id;
18576 param->reason = evt->reason;
18577 param->rssi = evt->rssi;
18578
18579 return QDF_STATUS_SUCCESS;
18580}
18581
18582/**
18583 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18584 * @wmi_handle: wmi handle
18585 * @param evt_buf: pointer to event buffer
18586 * @param param: Pointer to hold vdev scan param
18587 *
18588 * Return: QDF_STATUS_SUCCESS for success or error code
18589 */
18590static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018591 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018592{
18593 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18594 wmi_scan_event_fixed_param *evt = NULL;
18595
18596 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18597 evt = param_buf->fixed_param;
18598
18599 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018600
Govind Singhe7f2f342016-05-23 12:12:52 +053018601 switch (evt->event) {
18602 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018603 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018604 break;
18605 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018606 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018607 break;
18608 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018609 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018610 break;
18611 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018612 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018613 break;
18614 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018615 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018616 break;
18617 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018618 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018619 break;
18620 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018621 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018622 break;
18623 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018624 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018625 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018626 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018627 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018628 break;
18629 case WMI_SCAN_EVENT_MAX:
18630 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018631 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018632 break;
18633 };
18634
18635 switch (evt->reason) {
18636 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018637 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018638 break;
18639 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018640 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018641 break;
18642 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018643 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018644 break;
18645 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018646 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018647 break;
18648 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018649 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018650 break;
18651 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018652 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018653 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018654 case WMI_SCAN_REASON_SUSPENDED:
18655 param->reason = SCAN_REASON_SUSPENDED;
18656 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018657 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018658 param->reason = SCAN_REASON_MAX;
18659 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018660 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018661 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018662 break;
18663 };
18664
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018665 param->chan_freq = evt->channel_freq;
18666 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018667 param->scan_id = evt->scan_id;
18668 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018669 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018670
18671 return QDF_STATUS_SUCCESS;
18672}
18673
Frank Liu3d5e9992017-03-15 17:51:43 +080018674#ifdef CONVERGED_TDLS_ENABLE
18675/**
18676 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18677 * @wmi_handle: wmi handle
18678 * @param evt_buf: pointer to event buffer
18679 * @param param: Pointer to hold vdev tdls param
18680 *
18681 * Return: QDF_STATUS_SUCCESS for success or error code
18682 */
18683static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18684 void *evt_buf, struct tdls_event_info *param)
18685{
18686 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18687 wmi_tdls_peer_event_fixed_param *evt;
18688
18689 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18690 if (!param_buf) {
18691 WMI_LOGE("%s: NULL param_buf", __func__);
18692 return QDF_STATUS_E_NULL_VALUE;
18693 }
18694
18695 evt = param_buf->fixed_param;
18696
18697 qdf_mem_zero(param, sizeof(*param));
18698
18699 param->vdev_id = evt->vdev_id;
18700 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18701 param->peermac.bytes);
18702 switch (evt->peer_status) {
18703 case WMI_TDLS_SHOULD_DISCOVER:
18704 param->message_type = TDLS_SHOULD_DISCOVER;
18705 break;
18706 case WMI_TDLS_SHOULD_TEARDOWN:
18707 param->message_type = TDLS_SHOULD_TEARDOWN;
18708 break;
18709 case WMI_TDLS_PEER_DISCONNECTED:
18710 param->message_type = TDLS_PEER_DISCONNECTED;
18711 break;
18712 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18713 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18714 break;
18715 default:
18716 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18717 __func__, evt->peer_status);
18718 return QDF_STATUS_E_INVAL;
18719 };
18720
18721 switch (evt->peer_reason) {
18722 case WMI_TDLS_TEARDOWN_REASON_TX:
18723 param->peer_reason = TDLS_TEARDOWN_TX;
18724 break;
18725 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18726 param->peer_reason = TDLS_TEARDOWN_RSSI;
18727 break;
18728 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18729 param->peer_reason = TDLS_TEARDOWN_SCAN;
18730 break;
18731 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18732 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18733 break;
18734 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18735 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18736 break;
18737 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18738 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18739 break;
18740 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18741 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18742 break;
18743 case WMI_TDLS_ENTER_BUF_STA:
18744 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18745 break;
18746 case WMI_TDLS_EXIT_BUF_STA:
18747 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18748 break;
18749 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18750 param->peer_reason = TDLS_ENTER_BT_BUSY;
18751 break;
18752 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18753 param->peer_reason = TDLS_EXIT_BT_BUSY;
18754 break;
18755 case WMI_TDLS_SCAN_STARTED_EVENT:
18756 param->peer_reason = TDLS_SCAN_STARTED;
18757 break;
18758 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18759 param->peer_reason = TDLS_SCAN_COMPLETED;
18760 break;
18761
18762 default:
18763 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18764 __func__, evt->peer_reason, evt->peer_status);
18765 return QDF_STATUS_E_INVAL;
18766 };
18767
18768 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18769 __func__, param->peermac.bytes, param->message_type,
18770 param->peer_reason, param->vdev_id);
18771
18772 return QDF_STATUS_SUCCESS;
18773}
18774#endif
18775
Govind Singhe7f2f342016-05-23 12:12:52 +053018776/**
18777 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18778 * @wmi_handle: wmi handle
18779 * @param evt_buf: pointer to event buffer
18780 * @param param: Pointer to hold MGMT TX completion params
18781 *
18782 * Return: QDF_STATUS_SUCCESS for success or error code
18783 */
18784static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18785 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18786{
18787 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18788 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18789
18790 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18791 evt_buf;
18792 if (!param_buf) {
18793 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18794 return QDF_STATUS_E_INVAL;
18795 }
18796 cmpl_params = param_buf->fixed_param;
18797
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018798 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18799 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018800 param->desc_id = cmpl_params->desc_id;
18801 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018802 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018803
18804 return QDF_STATUS_SUCCESS;
18805}
18806
18807/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018808 * extract_offchan_data_tx_compl_param_tlv() -
18809 * extract Offchan data tx completion event params
18810 * @wmi_handle: wmi handle
18811 * @param evt_buf: pointer to event buffer
18812 * @param param: Pointer to hold offchan data TX completion params
18813 *
18814 * Return: QDF_STATUS_SUCCESS for success or error code
18815 */
18816static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18817 wmi_unified_t wmi_handle, void *evt_buf,
18818 struct wmi_host_offchan_data_tx_compl_event *param)
18819{
18820 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18821 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18822
18823 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18824 evt_buf;
18825 if (!param_buf) {
18826 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18827 return QDF_STATUS_E_INVAL;
18828 }
18829 cmpl_params = param_buf->fixed_param;
18830
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018831 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18832 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018833 param->desc_id = cmpl_params->desc_id;
18834 param->status = cmpl_params->status;
18835
18836 return QDF_STATUS_SUCCESS;
18837}
18838
18839/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018840 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18841 * status tlv
18842 * @wmi_handle: wmi handle
18843 * @param evt_buf: pointer to event buffer
18844 * @param param: Pointer to hold csa switch count status event param
18845 *
18846 * Return: QDF_STATUS_SUCCESS for success or error code
18847 */
18848static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18849 wmi_unified_t wmi_handle,
18850 void *evt_buf,
18851 struct pdev_csa_switch_count_status *param)
18852{
18853 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18854 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18855
18856 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18857 evt_buf;
18858 if (!param_buf) {
18859 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18860 return QDF_STATUS_E_INVAL;
18861 }
18862
18863 csa_status = param_buf->fixed_param;
18864
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018865 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18866 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018867 param->current_switch_count = csa_status->current_switch_count;
18868 param->num_vdevs = csa_status->num_vdevs;
18869 param->vdev_ids = param_buf->vdev_ids;
18870
18871 return QDF_STATUS_SUCCESS;
18872}
18873
18874/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018875 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18876 * param from event
18877 * @wmi_handle: wmi handle
18878 * @param evt_buf: pointer to event buffer
18879 * @param param: Pointer to hold tpc configuration
18880 *
18881 * Return: 0 for success or error code
18882 */
18883static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18884 void *evt_buf,
18885 wmi_host_pdev_tpc_config_event *param)
18886{
18887 wmi_pdev_tpc_config_event_fixed_param *event =
18888 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18889
18890 if (!event) {
18891 WMI_LOGE("Invalid event buffer");
18892 return QDF_STATUS_E_INVAL;
18893 }
18894
18895 param->pdev_id = event->pdev_id;
18896 param->regDomain = event->regDomain;
18897 param->chanFreq = event->chanFreq;
18898 param->phyMode = event->phyMode;
18899 param->twiceAntennaReduction = event->twiceAntennaReduction;
18900 param->twiceMaxRDPower = event->twiceMaxRDPower;
18901 param->powerLimit = event->powerLimit;
18902 param->rateMax = event->rateMax;
18903 param->numTxChain = event->numTxChain;
18904 param->ctl = event->ctl;
18905 param->flags = event->flags;
18906
18907 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18908 sizeof(param->maxRegAllowedPower));
18909 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18910 event->maxRegAllowedPowerAGCDD,
18911 sizeof(param->maxRegAllowedPowerAGCDD));
18912 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18913 event->maxRegAllowedPowerAGSTBC,
18914 sizeof(param->maxRegAllowedPowerAGSTBC));
18915 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18916 event->maxRegAllowedPowerAGTXBF,
18917 sizeof(param->maxRegAllowedPowerAGTXBF));
18918 WMI_LOGD("%s:extract success", __func__);
18919
18920 return QDF_STATUS_SUCCESS;
18921}
18922
18923/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018924 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018925 * @wmi_handle: wmi handle
18926 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018927 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018928 *
18929 * Return: QDF_STATUS_SUCCESS for success or error code
18930 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018931static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18932 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018933{
18934 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18935 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018936 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018937
18938 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18939 if (!param_buf) {
18940 WMI_LOGE("Invalid swba event buffer");
18941 return QDF_STATUS_E_INVAL;
18942 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018943
Govind Singhe7f2f342016-05-23 12:12:52 +053018944 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018945 *num_vdevs = swba_event->num_vdevs;
18946 if (!(*num_vdevs)) {
18947 vdev_map = swba_event->vdev_map;
18948 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18949 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018950
18951 return QDF_STATUS_SUCCESS;
18952}
18953
18954/**
18955 * extract_swba_tim_info_tlv() - extract swba tim info from event
18956 * @wmi_handle: wmi handle
18957 * @param evt_buf: pointer to event buffer
18958 * @param idx: Index to bcn info
18959 * @param tim_info: Pointer to hold tim info
18960 *
18961 * Return: QDF_STATUS_SUCCESS for success or error code
18962 */
18963static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18964 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18965{
18966 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18967 wmi_tim_info *tim_info_ev;
18968
18969 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18970 if (!param_buf) {
18971 WMI_LOGE("Invalid swba event buffer");
18972 return QDF_STATUS_E_INVAL;
18973 }
18974
18975 tim_info_ev = &param_buf->tim_info[idx];
18976
18977 tim_info->tim_len = tim_info_ev->tim_len;
18978 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18979 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18980 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18981 tim_info->tim_changed = tim_info_ev->tim_changed;
18982 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018983 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018984
18985 return QDF_STATUS_SUCCESS;
18986}
18987
18988/**
18989 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18990 * @wmi_handle: wmi handle
18991 * @param evt_buf: pointer to event buffer
18992 * @param idx: Index to bcn info
18993 * @param p2p_desc: Pointer to hold p2p NoA info
18994 *
18995 * Return: QDF_STATUS_SUCCESS for success or error code
18996 */
18997static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18998 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18999{
19000 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19001 wmi_p2p_noa_info *p2p_noa_info;
19002 uint8_t i = 0;
19003
19004 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19005 if (!param_buf) {
19006 WMI_LOGE("Invalid swba event buffer");
19007 return QDF_STATUS_E_INVAL;
19008 }
19009
19010 p2p_noa_info = &param_buf->p2p_noa_info[idx];
19011
19012 p2p_desc->modified = false;
19013 p2p_desc->num_descriptors = 0;
19014 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
19015 p2p_desc->modified = true;
19016 p2p_desc->index =
19017 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
19018 p2p_desc->oppPS =
19019 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
19020 p2p_desc->ctwindow =
19021 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
19022 p2p_desc->num_descriptors =
19023 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
19024 (p2p_noa_info);
19025 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19026 p2p_desc->noa_descriptors[i].type_count =
19027 (uint8_t) p2p_noa_info->noa_descriptors[i].
19028 type_count;
19029 p2p_desc->noa_descriptors[i].duration =
19030 p2p_noa_info->noa_descriptors[i].duration;
19031 p2p_desc->noa_descriptors[i].interval =
19032 p2p_noa_info->noa_descriptors[i].interval;
19033 p2p_desc->noa_descriptors[i].start_time =
19034 p2p_noa_info->noa_descriptors[i].start_time;
19035 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019036 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019037 }
19038
19039 return QDF_STATUS_SUCCESS;
19040}
19041
Wu Gaocd3a8512017-03-13 20:17:34 +080019042#ifdef CONVERGED_P2P_ENABLE
19043/**
19044 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19045 * @wmi_handle: wmi handle
19046 * @param evt_buf: pointer to event buffer
19047 * @param param: Pointer to hold p2p noa info
19048 *
19049 * Return: QDF_STATUS_SUCCESS for success or error code
19050 */
19051static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19052 wmi_unified_t wmi_handle, void *evt_buf,
19053 struct p2p_noa_info *param)
19054{
19055 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19056 wmi_p2p_noa_event_fixed_param *fixed_param;
19057 uint8_t i;
19058 wmi_p2p_noa_info *wmi_noa_info;
19059 uint8_t *buf_ptr;
19060 uint32_t descriptors;
19061
19062 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19063 if (!param_tlvs) {
19064 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19065 return QDF_STATUS_E_INVAL;
19066 }
19067
19068 if (!param) {
19069 WMI_LOGE("noa information param is null");
19070 return QDF_STATUS_E_INVAL;
19071 }
19072
19073 fixed_param = param_tlvs->fixed_param;
19074 buf_ptr = (uint8_t *) fixed_param;
19075 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19076 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19077
19078 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19079 WMI_LOGE("%s: noa attr is not modified", __func__);
19080 return QDF_STATUS_E_INVAL;
19081 }
19082
19083 param->vdev_id = fixed_param->vdev_id;
19084 param->index =
19085 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19086 param->opps_ps =
19087 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19088 param->ct_window =
19089 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19090 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19091 param->num_desc = (uint8_t) descriptors;
19092
19093 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19094 param->index, param->opps_ps, param->ct_window,
19095 param->num_desc);
19096 for (i = 0; i < param->num_desc; i++) {
19097 param->noa_desc[i].type_count =
19098 (uint8_t) wmi_noa_info->noa_descriptors[i].
19099 type_count;
19100 param->noa_desc[i].duration =
19101 wmi_noa_info->noa_descriptors[i].duration;
19102 param->noa_desc[i].interval =
19103 wmi_noa_info->noa_descriptors[i].interval;
19104 param->noa_desc[i].start_time =
19105 wmi_noa_info->noa_descriptors[i].start_time;
19106 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19107 __func__, i, param->noa_desc[i].type_count,
19108 param->noa_desc[i].duration,
19109 param->noa_desc[i].interval,
19110 param->noa_desc[i].start_time);
19111 }
19112
19113 return QDF_STATUS_SUCCESS;
19114}
19115
19116/**
19117 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19118 * information from event
19119 * @wmi_handle: wmi handle
19120 * @param evt_buf: pointer to event buffer
19121 * @param param: Pointer to hold p2p lo stop event information
19122 *
19123 * Return: QDF_STATUS_SUCCESS for success or error code
19124 */
19125static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19126 wmi_unified_t wmi_handle, void *evt_buf,
19127 struct p2p_lo_event *param)
19128{
19129 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19130 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19131
19132 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19133 evt_buf;
19134 if (!param_tlvs) {
19135 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19136 return QDF_STATUS_E_INVAL;
19137 }
19138
19139 if (!param) {
19140 WMI_LOGE("lo stop event param is null");
19141 return QDF_STATUS_E_INVAL;
19142 }
19143
19144 lo_param = param_tlvs->fixed_param;
19145 param->vdev_id = lo_param->vdev_id;
19146 param->reason_code = lo_param->reason;
19147 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19148 param->vdev_id, param->reason_code);
19149
19150 return QDF_STATUS_SUCCESS;
19151}
19152#endif /* End of CONVERGED_P2P_ENABLE */
19153
Govind Singhe7f2f342016-05-23 12:12:52 +053019154/**
19155 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19156 * @wmi_handle: wmi handle
19157 * @param evt_buf: pointer to event buffer
19158 * @param ev: Pointer to hold peer param
19159 *
19160 * Return: QDF_STATUS_SUCCESS for success or error code
19161 */
19162static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19163 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19164{
19165 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19166 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19167
19168 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19169 kickout_event = param_buf->fixed_param;
19170
19171 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19172 ev->peer_macaddr);
19173
19174 ev->reason = kickout_event->reason;
19175 ev->rssi = kickout_event->rssi;
19176
19177 return QDF_STATUS_SUCCESS;
19178}
19179
19180/**
19181 * extract_all_stats_counts_tlv() - extract all stats count from event
19182 * @wmi_handle: wmi handle
19183 * @param evt_buf: pointer to event buffer
19184 * @param stats_param: Pointer to hold stats count
19185 *
19186 * Return: QDF_STATUS_SUCCESS for success or error code
19187 */
19188static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19189 void *evt_buf, wmi_host_stats_event *stats_param)
19190{
Govind Singhe7f2f342016-05-23 12:12:52 +053019191 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019192 wmi_per_chain_rssi_stats *rssi_event;
19193 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019194
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019195 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053019196 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019197 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019198 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053019199 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019200 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053019201 return QDF_STATUS_E_FAILURE;
19202 }
19203
19204 switch (ev->stats_id) {
19205 case WMI_REQUEST_PEER_STAT:
19206 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19207 break;
19208
19209 case WMI_REQUEST_AP_STAT:
19210 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19211 break;
19212
19213 case WMI_REQUEST_PDEV_STAT:
19214 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19215 break;
19216
19217 case WMI_REQUEST_VDEV_STAT:
19218 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19219 break;
19220
19221 case WMI_REQUEST_BCNFLT_STAT:
19222 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19223 break;
19224
19225 case WMI_REQUEST_VDEV_RATE_STAT:
19226 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19227 break;
19228
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019229 case WMI_REQUEST_BCN_STAT:
19230 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19231 break;
19232
Govind Singhe7f2f342016-05-23 12:12:52 +053019233 default:
19234 stats_param->stats_id = 0;
19235 break;
19236
19237 }
19238
19239 stats_param->num_pdev_stats = ev->num_pdev_stats;
19240 stats_param->num_pdev_ext_stats = 0;
19241 stats_param->num_vdev_stats = ev->num_vdev_stats;
19242 stats_param->num_peer_stats = ev->num_peer_stats;
19243 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19244 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019245 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019246 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19247 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019248
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019249 /* if chain_stats is not populated */
19250 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
19251 return QDF_STATUS_SUCCESS;
19252
19253 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
19254 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19255 return QDF_STATUS_SUCCESS;
19256
19257 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
19258 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19259 return QDF_STATUS_SUCCESS;
19260
19261 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
19262
Govind Singhe7f2f342016-05-23 12:12:52 +053019263 return QDF_STATUS_SUCCESS;
19264}
19265
19266/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019267 * extract_pdev_tx_stats() - extract pdev tx stats from event
19268 */
19269static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19270{
19271 /* Tx Stats */
19272 tx->comp_queued = tx_stats->comp_queued;
19273 tx->comp_delivered = tx_stats->comp_delivered;
19274 tx->msdu_enqued = tx_stats->msdu_enqued;
19275 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19276 tx->wmm_drop = tx_stats->wmm_drop;
19277 tx->local_enqued = tx_stats->local_enqued;
19278 tx->local_freed = tx_stats->local_freed;
19279 tx->hw_queued = tx_stats->hw_queued;
19280 tx->hw_reaped = tx_stats->hw_reaped;
19281 tx->underrun = tx_stats->underrun;
19282 tx->tx_abort = tx_stats->tx_abort;
19283 tx->mpdus_requed = tx_stats->mpdus_requed;
19284 tx->data_rc = tx_stats->data_rc;
19285 tx->self_triggers = tx_stats->self_triggers;
19286 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19287 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19288 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19289 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19290 tx->pdev_resets = tx_stats->pdev_resets;
19291 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19292 tx->phy_underrun = tx_stats->phy_underrun;
19293 tx->txop_ovf = tx_stats->txop_ovf;
19294
19295 return;
19296}
19297
19298
19299/**
19300 * extract_pdev_rx_stats() - extract pdev rx stats from event
19301 */
19302static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19303{
19304 /* Rx Stats */
19305 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19306 rx->status_rcvd = rx_stats->status_rcvd;
19307 rx->r0_frags = rx_stats->r0_frags;
19308 rx->r1_frags = rx_stats->r1_frags;
19309 rx->r2_frags = rx_stats->r2_frags;
19310 /* Only TLV */
19311 rx->r3_frags = 0;
19312 rx->htt_msdus = rx_stats->htt_msdus;
19313 rx->htt_mpdus = rx_stats->htt_mpdus;
19314 rx->loc_msdus = rx_stats->loc_msdus;
19315 rx->loc_mpdus = rx_stats->loc_mpdus;
19316 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19317 rx->phy_errs = rx_stats->phy_errs;
19318 rx->phy_err_drop = rx_stats->phy_err_drop;
19319 rx->mpdu_errs = rx_stats->mpdu_errs;
19320
19321 return;
19322}
19323
19324/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019325 * extract_pdev_stats_tlv() - extract pdev stats from event
19326 * @wmi_handle: wmi handle
19327 * @param evt_buf: pointer to event buffer
19328 * @param index: Index into pdev stats
19329 * @param pdev_stats: Pointer to hold pdev stats
19330 *
19331 * Return: QDF_STATUS_SUCCESS for success or error code
19332 */
19333static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19334 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19335{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019336 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19337 wmi_stats_event_fixed_param *ev_param;
19338 uint8_t *data;
19339
19340 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19341 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19342
19343 data = param_buf->data;
19344
19345 if (index < ev_param->num_pdev_stats) {
19346 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19347 (index * sizeof(wmi_pdev_stats)));
19348
19349 pdev_stats->chan_nf = ev->chan_nf;
19350 pdev_stats->tx_frame_count = ev->tx_frame_count;
19351 pdev_stats->rx_frame_count = ev->rx_frame_count;
19352 pdev_stats->rx_clear_count = ev->rx_clear_count;
19353 pdev_stats->cycle_count = ev->cycle_count;
19354 pdev_stats->phy_err_count = ev->phy_err_count;
19355 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19356
19357 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19358 &(ev->pdev_stats.tx));
19359 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19360 &(ev->pdev_stats.rx));
19361 }
19362
Govind Singhe7f2f342016-05-23 12:12:52 +053019363 return QDF_STATUS_SUCCESS;
19364}
19365
19366/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019367 * extract_unit_test_tlv() - extract unit test data
19368 * @wmi_handle: wmi handle
19369 * @param evt_buf: pointer to event buffer
19370 * @param unit_test: pointer to hold unit test data
19371 * @param maxspace: Amount of space in evt_buf
19372 *
19373 * Return: QDF_STATUS_SUCCESS for success or error code
19374 */
19375static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19376 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19377{
19378 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19379 wmi_unit_test_event_fixed_param *ev_param;
19380 uint32_t num_bufp;
19381 uint32_t copy_size;
19382 uint8_t *bufp;
19383
19384 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19385 ev_param = param_buf->fixed_param;
19386 bufp = param_buf->bufp;
19387 num_bufp = param_buf->num_bufp;
19388 unit_test->vdev_id = ev_param->vdev_id;
19389 unit_test->module_id = ev_param->module_id;
19390 unit_test->diag_token = ev_param->diag_token;
19391 unit_test->flag = ev_param->flag;
19392 unit_test->payload_len = ev_param->payload_len;
19393 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19394 ev_param->vdev_id,
19395 ev_param->module_id,
19396 ev_param->diag_token,
19397 ev_param->flag);
19398 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19399 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19400 bufp, num_bufp);
19401 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19402 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19403 unit_test->buffer_len = copy_size;
19404
19405 return QDF_STATUS_SUCCESS;
19406}
19407
19408/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019409 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19410 * @wmi_handle: wmi handle
19411 * @param evt_buf: pointer to event buffer
19412 * @param index: Index into extended pdev stats
19413 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19414 *
19415 * Return: QDF_STATUS_SUCCESS for success or error code
19416 */
19417static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19418 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19419{
19420 return QDF_STATUS_SUCCESS;
19421}
19422
19423/**
19424 * extract_vdev_stats_tlv() - extract vdev stats from event
19425 * @wmi_handle: wmi handle
19426 * @param evt_buf: pointer to event buffer
19427 * @param index: Index into vdev stats
19428 * @param vdev_stats: Pointer to hold vdev stats
19429 *
19430 * Return: QDF_STATUS_SUCCESS for success or error code
19431 */
19432static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19433 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19434{
19435 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19436 wmi_stats_event_fixed_param *ev_param;
19437 uint8_t *data;
19438
19439 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19440 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19441 data = (uint8_t *) param_buf->data;
19442
19443 if (index < ev_param->num_vdev_stats) {
19444 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19445 ((ev_param->num_pdev_stats) *
19446 sizeof(wmi_pdev_stats)) +
19447 (index * sizeof(wmi_vdev_stats)));
19448
19449 vdev_stats->vdev_id = ev->vdev_id;
19450 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19451 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19452
19453 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19454 sizeof(ev->tx_frm_cnt));
19455 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19456 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19457 ev->multiple_retry_cnt,
19458 sizeof(ev->multiple_retry_cnt));
19459 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19460 sizeof(ev->fail_cnt));
19461 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19462 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19463 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19464 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19465 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19466 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19467 sizeof(ev->tx_rate_history));
19468 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19469 sizeof(ev->bcn_rssi_history));
19470
19471 }
19472
19473 return QDF_STATUS_SUCCESS;
19474}
19475
19476/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019477 * extract_bcn_stats_tlv() - extract bcn stats from event
19478 * @wmi_handle: wmi handle
19479 * @param evt_buf: pointer to event buffer
19480 * @param index: Index into vdev stats
19481 * @param bcn_stats: Pointer to hold bcn stats
19482 *
19483 * Return: QDF_STATUS_SUCCESS for success or error code
19484 */
19485static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19486 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19487{
19488 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19489 wmi_stats_event_fixed_param *ev_param;
19490 uint8_t *data;
19491
19492 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19493 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19494 data = (uint8_t *) param_buf->data;
19495
19496 if (index < ev_param->num_bcn_stats) {
19497 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19498 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19499 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19500 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19501 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19502 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19503 (index * sizeof(wmi_bcn_stats)));
19504
19505 bcn_stats->vdev_id = ev->vdev_id;
19506 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19507 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19508 }
19509
19510 return QDF_STATUS_SUCCESS;
19511}
19512
19513/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019514 * extract_peer_stats_tlv() - extract peer stats from event
19515 * @wmi_handle: wmi handle
19516 * @param evt_buf: pointer to event buffer
19517 * @param index: Index into peer stats
19518 * @param peer_stats: Pointer to hold peer stats
19519 *
19520 * Return: QDF_STATUS_SUCCESS for success or error code
19521 */
19522static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19523 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19524{
19525 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19526 wmi_stats_event_fixed_param *ev_param;
19527 uint8_t *data;
19528
19529 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19530 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19531 data = (uint8_t *) param_buf->data;
19532
19533 if (index < ev_param->num_peer_stats) {
19534 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19535 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19536 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19537 (index * sizeof(wmi_peer_stats)));
19538
19539 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19540
19541 OS_MEMCPY(&(peer_stats->peer_macaddr),
19542 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19543
19544 peer_stats->peer_rssi = ev->peer_rssi;
19545 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19546 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19547 }
19548
19549 return QDF_STATUS_SUCCESS;
19550}
19551
19552/**
19553 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19554 * @wmi_handle: wmi handle
19555 * @param evt_buf: pointer to event buffer
19556 * @param index: Index into bcn fault stats
19557 * @param bcnflt_stats: Pointer to hold bcn fault stats
19558 *
19559 * Return: QDF_STATUS_SUCCESS for success or error code
19560 */
19561static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19562 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19563{
19564 return QDF_STATUS_SUCCESS;
19565}
19566
19567/**
19568 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19569 * @wmi_handle: wmi handle
19570 * @param evt_buf: pointer to event buffer
19571 * @param index: Index into extended peer stats
19572 * @param peer_extd_stats: Pointer to hold extended peer stats
19573 *
19574 * Return: QDF_STATUS_SUCCESS for success or error code
19575 */
19576static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19577 void *evt_buf, uint32_t index,
19578 wmi_host_peer_extd_stats *peer_extd_stats)
19579{
19580 return QDF_STATUS_SUCCESS;
19581}
19582
19583/**
19584 * extract_chan_stats_tlv() - extract chan stats from event
19585 * @wmi_handle: wmi handle
19586 * @param evt_buf: pointer to event buffer
19587 * @param index: Index into chan stats
19588 * @param vdev_extd_stats: Pointer to hold chan stats
19589 *
19590 * Return: QDF_STATUS_SUCCESS for success or error code
19591 */
19592static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19593 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19594{
19595 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19596 wmi_stats_event_fixed_param *ev_param;
19597 uint8_t *data;
19598
19599 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19600 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19601 data = (uint8_t *) param_buf->data;
19602
19603 if (index < ev_param->num_chan_stats) {
19604 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19605 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19606 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19607 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19608 (index * sizeof(wmi_chan_stats)));
19609
19610
19611 /* Non-TLV doesnt have num_chan_stats */
19612 chan_stats->chan_mhz = ev->chan_mhz;
19613 chan_stats->sampling_period_us = ev->sampling_period_us;
19614 chan_stats->rx_clear_count = ev->rx_clear_count;
19615 chan_stats->tx_duration_us = ev->tx_duration_us;
19616 chan_stats->rx_duration_us = ev->rx_duration_us;
19617 }
19618
19619 return QDF_STATUS_SUCCESS;
19620}
19621
19622/**
19623 * extract_profile_ctx_tlv() - extract profile context from event
19624 * @wmi_handle: wmi handle
19625 * @param evt_buf: pointer to event buffer
19626 * @idx: profile stats index to extract
19627 * @param profile_ctx: Pointer to hold profile context
19628 *
19629 * Return: QDF_STATUS_SUCCESS for success or error code
19630 */
19631static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19632 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19633{
19634 return QDF_STATUS_SUCCESS;
19635}
19636
19637/**
19638 * extract_profile_data_tlv() - extract profile data from event
19639 * @wmi_handle: wmi handle
19640 * @param evt_buf: pointer to event buffer
19641 * @param profile_data: Pointer to hold profile data
19642 *
19643 * Return: QDF_STATUS_SUCCESS for success or error code
19644 */
19645static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19646 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19647{
19648
19649 return QDF_STATUS_SUCCESS;
19650}
19651
19652/**
19653 * extract_chan_info_event_tlv() - extract chan information from event
19654 * @wmi_handle: wmi handle
19655 * @param evt_buf: pointer to event buffer
19656 * @param chan_info: Pointer to hold chan information
19657 *
19658 * Return: QDF_STATUS_SUCCESS for success or error code
19659 */
19660static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19661 void *evt_buf, wmi_host_chan_info_event *chan_info)
19662{
19663 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19664 wmi_chan_info_event_fixed_param *ev;
19665
19666 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19667
19668 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19669 if (!ev) {
19670 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19671 return QDF_STATUS_E_FAILURE;
19672 }
19673
19674 chan_info->err_code = ev->err_code;
19675 chan_info->freq = ev->freq;
19676 chan_info->cmd_flags = ev->cmd_flags;
19677 chan_info->noise_floor = ev->noise_floor;
19678 chan_info->rx_clear_count = ev->rx_clear_count;
19679 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019680 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19681 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019682 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19683 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19684 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019685 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19686 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19687 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19688 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19689 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19690 chan_info->rx_frame_count = ev->rx_frame_count;
19691 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19692 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019693
19694 return QDF_STATUS_SUCCESS;
19695}
19696
19697/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019698 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19699 * @wmi_handle: WMI handle
19700 * @param evt_buf: Pointer to event buffer
19701 * @param param: Pointer to hold data
19702 *
19703 * Return : QDF_STATUS_SUCCESS for success or error code
19704 */
19705static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19706 uint8_t *evt_buf,
19707 struct wmi_host_pdev_utf_event *event)
19708{
19709 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019710 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019711
19712 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19713 event->data = param_buf->data;
19714 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019715 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019716 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019717 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019718 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019719
19720 return QDF_STATUS_SUCCESS;
19721}
Govind Singhe7f2f342016-05-23 12:12:52 +053019722
Kiran Venkatappa06520822016-08-10 23:55:40 +053019723/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019724 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19725 * @wmi_handle: wmi handle
19726 * @param evt_buf: pointer to event buffer
19727 * @param param: Pointer to hold evt buf
19728 *
19729 * Return: QDF_STATUS_SUCCESS for success or error code
19730 */
19731static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19732 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19733{
19734 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19735 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19736 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19737 uint8_t i = 0, j = 0;
19738
19739 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19740 if (!param_buf)
19741 return QDF_STATUS_E_INVAL;
19742
19743 hw_caps = param_buf->soc_hw_mode_caps;
19744 if (!hw_caps)
19745 return QDF_STATUS_E_INVAL;
19746
19747 if (!hw_caps->num_chainmask_tables)
19748 return QDF_STATUS_E_INVAL;
19749
19750 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19751
19752 if (chainmask_caps == NULL)
19753 return QDF_STATUS_E_INVAL;
19754
19755 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19756
19757 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19758 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19759
19760 chainmask_table[i].cap_list[j].chainmask =
19761 chainmask_caps->chainmask;
19762
19763 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19764 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19765
19766 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19767 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19768
19769 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19770 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19771
19772 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19773 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19774
19775 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19776 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19777
19778 chainmask_table[i].cap_list[j].chain_mask_2G =
19779 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19780
19781 chainmask_table[i].cap_list[j].chain_mask_5G =
19782 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19783
19784 chainmask_table[i].cap_list[j].chain_mask_tx =
19785 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19786
19787 chainmask_table[i].cap_list[j].chain_mask_rx =
19788 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19789
19790 chainmask_table[i].cap_list[j].supports_aDFS =
19791 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19792
19793 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19794 chainmask_caps->supported_flags,
19795 chainmask_caps->chainmask
19796 );
19797 chainmask_caps++;
19798 }
19799 }
19800
19801 return QDF_STATUS_SUCCESS;
19802}
19803
19804/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019805 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19806 * from event
19807 * @wmi_handle: wmi handle
19808 * @param evt_buf: pointer to event buffer
19809 * @param param: Pointer to hold evt buf
19810 *
19811 * Return: QDF_STATUS_SUCCESS for success or error code
19812 */
19813static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019814 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019815{
19816 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19817 wmi_service_ready_ext_event_fixed_param *ev;
19818 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19819 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019820 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19821 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019822
19823 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19824 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019825 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019826
19827 ev = param_buf->fixed_param;
19828 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019829 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019830
19831 /* Move this to host based bitmap */
19832 param->default_conc_scan_config_bits =
19833 ev->default_conc_scan_config_bits;
19834 param->default_fw_config_bits = ev->default_fw_config_bits;
19835 param->he_cap_info = ev->he_cap_info;
19836 param->mpdu_density = ev->mpdu_density;
19837 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019838 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019839 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019840 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19841
19842 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019843 if (hw_caps)
19844 param->num_hw_modes = hw_caps->num_hw_modes;
19845 else
19846 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019847
19848 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019849 if (reg_caps)
19850 param->num_phy = reg_caps->num_phy;
19851 else
19852 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019853
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019854 if (hw_caps) {
19855 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19856 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19857 } else
19858 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019859
19860 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19861
19862 if (chain_mask_combo == NULL)
19863 return QDF_STATUS_SUCCESS;
19864
19865 qdf_print("Dumping chain mask combo data\n");
19866
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019867 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019868
19869 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19870 chain_mask_combo->chainmask_table_id,
19871 chain_mask_combo->num_valid_chainmask
19872 );
19873
19874 param->chainmask_table[i].table_id =
19875 chain_mask_combo->chainmask_table_id;
19876 param->chainmask_table[i].num_valid_chainmasks =
19877 chain_mask_combo->num_valid_chainmask;
19878 chain_mask_combo++;
19879 }
19880 qdf_print("chain mask combo end\n");
19881
Kiran Venkatappa06520822016-08-10 23:55:40 +053019882 return QDF_STATUS_SUCCESS;
19883}
19884
19885/**
19886 * extract_hw_mode_cap_service_ready_ext_tlv() -
19887 * extract HW mode cap from service ready event
19888 * @wmi_handle: wmi handle
19889 * @param evt_buf: pointer to event buffer
19890 * @param param: Pointer to hold evt buf
19891 * @param hw_mode_idx: hw mode idx should be less than num_mode
19892 *
19893 * Return: QDF_STATUS_SUCCESS for success or error code
19894 */
19895static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19896 wmi_unified_t wmi_handle,
19897 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019898 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019899{
19900 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19901 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19902
19903 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19904 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019905 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019906
19907 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019908 if (!hw_caps)
19909 return QDF_STATUS_E_INVAL;
19910
Kiran Venkatappa06520822016-08-10 23:55:40 +053019911 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019912 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019913
19914 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19915 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19916
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019917 param->hw_mode_config_type =
19918 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19919
Kiran Venkatappa06520822016-08-10 23:55:40 +053019920 return QDF_STATUS_SUCCESS;
19921}
19922
19923/**
19924 * extract_mac_phy_cap_service_ready_ext_tlv() -
19925 * extract MAC phy cap from service ready event
19926 * @wmi_handle: wmi handle
19927 * @param evt_buf: pointer to event buffer
19928 * @param param: Pointer to hold evt buf
19929 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019930 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019931 *
19932 * Return: QDF_STATUS_SUCCESS for success or error code
19933 */
19934static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19935 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019936 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019937 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019938{
19939 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019940 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019941 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19942 uint32_t phy_map;
19943 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019944
19945 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19946 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019947 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019948
19949 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019950 if (!hw_caps)
19951 return QDF_STATUS_E_INVAL;
19952
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019953 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19954 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19955 break;
19956
19957 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19958 while (phy_map) {
19959 phy_map >>= 1;
19960 phy_idx++;
19961 }
19962 }
19963
19964 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019965 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019966
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019967 phy_idx += phy_id;
19968 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019969 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019970
19971 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019972
19973 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019974 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19975 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019976 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019977 param->supports_11b =
19978 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19979 param->supports_11g =
19980 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19981 param->supports_11a =
19982 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19983 param->supports_11n =
19984 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19985 param->supports_11ac =
19986 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19987 param->supports_11ax =
19988 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019989
19990 param->supported_bands = mac_phy_caps->supported_bands;
19991 param->ampdu_density = mac_phy_caps->ampdu_density;
19992 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19993 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19994 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19995 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19996 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19997 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19998 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19999 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
20000 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
20001 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
20002 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
20003 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
20004 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
20005 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
20006 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
20007 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080020008 qdf_mem_copy(&param->he_cap_phy_info_2G,
20009 &mac_phy_caps->he_cap_phy_info_2G,
20010 sizeof(param->he_cap_phy_info_2G));
20011 qdf_mem_copy(&param->he_cap_phy_info_5G,
20012 &mac_phy_caps->he_cap_phy_info_5G,
20013 sizeof(param->he_cap_phy_info_5G));
20014 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
20015 sizeof(param->he_ppet2G));
20016 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
20017 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020018 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020019
20020 return QDF_STATUS_SUCCESS;
20021}
20022
20023/**
20024 * extract_reg_cap_service_ready_ext_tlv() -
20025 * extract REG cap from service ready event
20026 * @wmi_handle: wmi handle
20027 * @param evt_buf: pointer to event buffer
20028 * @param param: Pointer to hold evt buf
20029 * @param phy_idx: phy idx should be less than num_mode
20030 *
20031 * Return: QDF_STATUS_SUCCESS for success or error code
20032 */
20033static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20034 wmi_unified_t wmi_handle,
20035 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020036 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020037{
20038 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20039 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20040 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20041
20042 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20043 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020044 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020045
20046 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020047 if (!reg_caps)
20048 return QDF_STATUS_E_INVAL;
20049
Kiran Venkatappa06520822016-08-10 23:55:40 +053020050 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020051 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020052
20053 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20054
20055 param->phy_id = ext_reg_cap->phy_id;
20056 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20057 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20058 param->regcap1 = ext_reg_cap->regcap1;
20059 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020060 param->wireless_modes = convert_wireless_modes_tlv(
20061 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020062 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20063 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20064 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20065 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20066
20067 return QDF_STATUS_SUCCESS;
20068}
20069
Sathish Kumarf396c722017-11-17 17:30:41 +053020070static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20071 wmi_unified_t wmi_handle,
20072 uint8_t *event, uint8_t idx,
20073 struct wlan_psoc_host_dbr_ring_caps *param)
20074{
20075 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20076 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20077
20078 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20079 if (!param_buf)
20080 return QDF_STATUS_E_INVAL;
20081
20082 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20083
20084 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20085 dbr_ring_caps->pdev_id);
20086 param->mod_id = dbr_ring_caps->mod_id;
20087 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20088 param->min_buf_size = dbr_ring_caps->min_buf_size;
20089 param->min_buf_align = dbr_ring_caps->min_buf_align;
20090
20091 return QDF_STATUS_SUCCESS;
20092}
20093
20094static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20095 uint8_t *event, struct direct_buf_rx_rsp *param)
20096{
20097 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20098 wmi_dma_buf_release_fixed_param *ev;
20099
20100 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20101 if (!param_buf)
20102 return QDF_STATUS_E_INVAL;
20103
20104 ev = param_buf->fixed_param;
20105 if (!ev)
20106 return QDF_STATUS_E_INVAL;
20107
20108 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20109 ev->pdev_id);
20110 param->mod_id = ev->mod_id;
20111 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020112 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053020113 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20114 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20115
20116 return QDF_STATUS_SUCCESS;
20117}
20118
20119static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20120 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20121{
20122 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20123 wmi_dma_buf_release_entry *entry;
20124
20125 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20126 if (!param_buf)
20127 return QDF_STATUS_E_INVAL;
20128
20129 entry = &param_buf->entries[idx];
20130
20131 if (!entry) {
20132 WMI_LOGE("%s: Entry is NULL\n", __func__);
20133 return QDF_STATUS_E_FAILURE;
20134 }
20135
20136 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20137
20138 param->paddr_lo = entry->paddr_lo;
20139 param->paddr_hi = entry->paddr_hi;
20140
20141 return QDF_STATUS_SUCCESS;
20142}
20143
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020144static QDF_STATUS extract_dbr_buf_metadata_tlv(
20145 wmi_unified_t wmi_handle, uint8_t *event,
20146 uint8_t idx, struct direct_buf_rx_metadata *param)
20147{
20148 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20149 wmi_dma_buf_release_spectral_meta_data *entry;
20150
20151 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20152 if (!param_buf)
20153 return QDF_STATUS_E_INVAL;
20154
20155 entry = &param_buf->meta_data[idx];
20156
20157 if (!entry) {
20158 WMI_LOGE("%s: Entry is NULL\n", __func__);
20159 return QDF_STATUS_E_FAILURE;
20160 }
20161
20162 qdf_mem_copy(param->noisefloor, entry->noise_floor,
20163 sizeof(entry->noise_floor));
20164 return QDF_STATUS_SUCCESS;
20165}
20166
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020167/**
20168 * extract_dcs_interference_type_tlv() - extract dcs interference type
20169 * from event
20170 * @wmi_handle: wmi handle
20171 * @param evt_buf: pointer to event buffer
20172 * @param param: Pointer to hold dcs interference param
20173 *
20174 * Return: 0 for success or error code
20175 */
20176static QDF_STATUS extract_dcs_interference_type_tlv(
20177 wmi_unified_t wmi_handle,
20178 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20179{
20180 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20181
20182 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20183 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020184 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020185
20186 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020187 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20188 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020189
20190 return QDF_STATUS_SUCCESS;
20191}
20192
20193/*
20194 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20195 * @wmi_handle: wmi handle
20196 * @param evt_buf: pointer to event buffer
20197 * @param cw_int: Pointer to hold cw interference
20198 *
20199 * Return: 0 for success or error code
20200 */
20201static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20202 void *evt_buf,
20203 wmi_host_ath_dcs_cw_int *cw_int)
20204{
20205 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20206 wlan_dcs_cw_int *ev;
20207
20208 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20209 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020210 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020211
20212 ev = param_buf->cw_int;
20213
20214 cw_int->channel = ev->channel;
20215
20216 return QDF_STATUS_SUCCESS;
20217}
20218
20219/**
20220 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20221 * @wmi_handle: wmi handle
20222 * @param evt_buf: pointer to event buffer
20223 * @param wlan_stat: Pointer to hold wlan stats
20224 *
20225 * Return: 0 for success or error code
20226 */
20227static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20228 void *evt_buf,
20229 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20230{
20231 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20232 wlan_dcs_im_tgt_stats_t *ev;
20233
20234 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20235 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020236 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020237
20238 ev = param_buf->wlan_stat;
20239 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20240 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20241 wlan_stat->tx_waste_time = ev->tx_waste_time;
20242 wlan_stat->rx_time = ev->rx_time;
20243 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20244 wlan_stat->mib_stats.listen_time = ev->listen_time;
20245 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20246 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20247 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20248 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20249 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20250 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20251 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20252 wlan_stat->chan_nf = ev->chan_nf;
20253 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20254
20255 return QDF_STATUS_SUCCESS;
20256}
20257
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020258/**
20259 * extract_thermal_stats_tlv() - extract thermal stats from event
20260 * @wmi_handle: wmi handle
20261 * @param evt_buf: Pointer to event buffer
20262 * @param temp: Pointer to hold extracted temperature
20263 * @param level: Pointer to hold extracted level
20264 *
20265 * Return: 0 for success or error code
20266 */
20267static QDF_STATUS
20268extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20269 void *evt_buf, uint32_t *temp,
20270 uint32_t *level, uint32_t *pdev_id)
20271{
20272 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20273 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20274
20275 param_buf =
20276 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20277 if (!param_buf)
20278 return QDF_STATUS_E_INVAL;
20279
20280 tt_stats_event = param_buf->fixed_param;
20281
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020282 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20283 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020284 *temp = tt_stats_event->temp;
20285 *level = tt_stats_event->level;
20286
20287 return QDF_STATUS_SUCCESS;
20288}
20289
20290/**
20291 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20292 * @wmi_handle: wmi handle
20293 * @param evt_buf: pointer to event buffer
20294 * @param idx: Index to level stats
20295 * @param levelcount: Pointer to hold levelcount
20296 * @param dccount: Pointer to hold dccount
20297 *
20298 * Return: 0 for success or error code
20299 */
20300static QDF_STATUS
20301extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20302 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20303 uint32_t *dccount)
20304{
20305 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20306 wmi_therm_throt_level_stats_info *tt_level_info;
20307
20308 param_buf =
20309 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20310 if (!param_buf)
20311 return QDF_STATUS_E_INVAL;
20312
20313 tt_level_info = param_buf->therm_throt_level_stats_info;
20314
20315 if (idx < THERMAL_LEVELS) {
20316 *levelcount = tt_level_info[idx].level_count;
20317 *dccount = tt_level_info[idx].dc_count;
20318 return QDF_STATUS_SUCCESS;
20319 }
20320
20321 return QDF_STATUS_E_FAILURE;
20322}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020323#ifdef BIG_ENDIAN_HOST
20324/**
20325 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20326 * @param data_len - data length
20327 * @param data - pointer to data
20328 *
20329 * Return: QDF_STATUS - success or error status
20330 */
20331static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20332{
20333 uint8_t *data_aligned = NULL;
20334 int c;
20335 unsigned char *data_unaligned;
20336
20337 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20338 FIPS_ALIGN));
20339 /* Assigning unaligned space to copy the data */
20340 /* Checking if kmalloc does succesful allocation */
20341 if (data_unaligned == NULL)
20342 return QDF_STATUS_E_FAILURE;
20343
20344 /* Checking if space is alligned */
20345 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20346 /* align the data space */
20347 data_aligned =
20348 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20349 } else {
20350 data_aligned = (u_int8_t *)data_unaligned;
20351 }
20352
20353 /* memset and copy content from data to data aligned */
20354 OS_MEMSET(data_aligned, 0, data_len);
20355 OS_MEMCPY(data_aligned, data, data_len);
20356 /* Endianness to LE */
20357 for (c = 0; c < data_len/4; c++) {
20358 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020359 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020360 }
20361
20362 /* Copy content to event->data */
20363 OS_MEMCPY(data, data_aligned, data_len);
20364
20365 /* clean up allocated space */
20366 qdf_mem_free(data_unaligned);
20367 data_aligned = NULL;
20368 data_unaligned = NULL;
20369
20370 /*************************************************************/
20371
20372 return QDF_STATUS_SUCCESS;
20373}
20374#else
20375/**
20376 * fips_conv_data_be() - DUMMY for LE platform
20377 *
20378 * Return: QDF_STATUS - success
20379 */
20380static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20381{
20382 return QDF_STATUS_SUCCESS;
20383}
20384#endif
20385
20386/**
20387 * extract_fips_event_data_tlv() - extract fips event data
20388 * @wmi_handle: wmi handle
20389 * @param evt_buf: pointer to event buffer
20390 * @param param: pointer FIPS event params
20391 *
20392 * Return: 0 for success or error code
20393 */
20394static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20395 void *evt_buf, struct wmi_host_fips_event_param *param)
20396{
20397 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20398 wmi_pdev_fips_event_fixed_param *event;
20399
20400 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20401 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20402
20403 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20404 QDF_STATUS_SUCCESS)
20405 return QDF_STATUS_E_FAILURE;
20406
20407 param->data = (uint32_t *)param_buf->data;
20408 param->data_len = event->data_len;
20409 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020410 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20411 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020412
20413 return QDF_STATUS_SUCCESS;
20414}
20415
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020416/*
20417 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20418 * @wmi_handle: wmi handle
20419 * @param evt_buf: pointer to event buffer
20420 * @param vdev_id: Pointer to hold vdev_id
20421 * @param mac_addr: Pointer to hold peer mac address
20422 *
20423 * Return: QDF_STATUS_SUCCESS for success or error code
20424 */
20425static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20426 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20427{
20428 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20429 wmi_peer_delete_resp_event_fixed_param *ev;
20430
20431 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20432
20433 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20434 if (!ev) {
20435 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20436 return QDF_STATUS_E_FAILURE;
20437 }
20438
20439 param->vdev_id = ev->vdev_id;
20440 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20441 &param->mac_address.bytes[0]);
20442
20443 return QDF_STATUS_SUCCESS;
20444}
20445
Govind Singhecf03cd2016-05-12 12:45:51 +053020446static bool is_management_record_tlv(uint32_t cmd_id)
20447{
jiad36c94d22018-01-22 15:37:03 +080020448 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20449 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20450 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020451 return true;
jiad36c94d22018-01-22 15:37:03 +080020452 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020453
Govind Singhecf03cd2016-05-12 12:45:51 +053020454 return false;
20455}
20456
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020457static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20458{
20459 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20460
20461 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20462
20463 switch (set_cmd->param_id) {
20464 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20465 case WMI_VDEV_PARAM_DTIM_POLICY:
20466 return HTC_TX_PACKET_TAG_AUTO_PM;
20467 default:
20468 break;
20469 }
20470
20471 return 0;
20472}
20473
20474static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20475{
20476 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20477
20478 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20479
20480 switch (ps_cmd->param) {
20481 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20482 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20483 case WMI_STA_PS_ENABLE_QPOWER:
20484 return HTC_TX_PACKET_TAG_AUTO_PM;
20485 default:
20486 break;
20487 }
20488
20489 return 0;
20490}
20491
20492static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20493 uint32_t cmd_id)
20494{
20495 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20496 return 0;
20497
20498 switch (cmd_id) {
20499 case WMI_VDEV_SET_PARAM_CMDID:
20500 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20501 case WMI_STA_POWERSAVE_PARAM_CMDID:
20502 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20503 default:
20504 break;
20505 }
20506
20507 return 0;
20508}
20509
20510static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20511{
20512 uint16_t tag = 0;
20513
20514 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20515 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20516 __func__);
20517 return tag;
20518 }
20519
20520 if (wmi_handle->tag_crash_inject)
20521 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20522
20523 wmi_handle->tag_crash_inject = false;
20524 return tag;
20525}
20526
20527/**
20528 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20529 * @wmi_handle: WMI handle
20530 * @buf: WMI buffer
20531 * @cmd_id: WMI command Id
20532 *
20533 * Return htc_tx_tag
20534 */
20535static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20536 wmi_buf_t buf,
20537 uint32_t cmd_id)
20538{
20539 uint16_t htc_tx_tag = 0;
20540
20541 switch (cmd_id) {
20542 case WMI_WOW_ENABLE_CMDID:
20543 case WMI_PDEV_SUSPEND_CMDID:
20544 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20545 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20546 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20547 case WMI_PDEV_RESUME_CMDID:
20548 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20549 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20550#ifdef FEATURE_WLAN_D0WOW
20551 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20552#endif
20553 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20554 break;
20555 case WMI_FORCE_FW_HANG_CMDID:
20556 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20557 break;
20558 case WMI_VDEV_SET_PARAM_CMDID:
20559 case WMI_STA_POWERSAVE_PARAM_CMDID:
20560 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20561 default:
20562 break;
20563 }
20564
20565 return htc_tx_tag;
20566}
20567
Sathish Kumard3ab1002017-02-07 17:10:59 +053020568/**
20569 * extract_channel_hopping_event_tlv() - extract channel hopping param
20570 * from event
20571 * @wmi_handle: wmi handle
20572 * @param evt_buf: pointer to event buffer
20573 * @param ch_hopping: Pointer to hold channel hopping param
20574 *
20575 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20576 */
20577static QDF_STATUS extract_channel_hopping_event_tlv(
20578 wmi_unified_t wmi_handle, void *evt_buf,
20579 wmi_host_pdev_channel_hopping_event *ch_hopping)
20580{
20581 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20582 wmi_pdev_channel_hopping_event_fixed_param *event;
20583
20584 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20585 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20586 param_buf->fixed_param;
20587
20588 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20589 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020590 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20591 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020592
20593 return QDF_STATUS_SUCCESS;
20594}
20595
20596/**
20597 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20598 * @wmi_handle: wmi handle
20599 * @param evt_buf: pointer to event buffer
20600 * @param param: Pointer to hold tpc param
20601 *
20602 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20603 */
20604static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20605 void *evt_buf,
20606 wmi_host_pdev_tpc_event *param)
20607{
20608 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20609 wmi_pdev_tpc_event_fixed_param *event;
20610
20611 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20612 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20613
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020614 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20615 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020616 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20617
20618 return QDF_STATUS_SUCCESS;
20619}
20620
nobeljf74583b2018-01-25 16:35:36 -080020621/**
20622 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20623 * power param from event
20624 * @wmi_handle: wmi handle
20625 * @param evt_buf: pointer to event buffer
20626 * @param param: Pointer to hold nf cal power param
20627 *
20628 * Return: 0 for success or error code
20629 */
20630static QDF_STATUS
20631extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20632 void *evt_buf,
20633 wmi_host_pdev_nfcal_power_all_channels_event *param)
20634{
20635 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20636 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20637 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20638 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20639 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20640 uint32_t i;
20641
20642 param_buf =
20643 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20644 event = param_buf->fixed_param;
20645 ch_nfdbr = param_buf->nfdbr;
20646 ch_nfdbm = param_buf->nfdbm;
20647 ch_freqnum = param_buf->freqnum;
20648
20649 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20650 event->pdev_id, param_buf->num_nfdbr,
20651 param_buf->num_nfdbm, param_buf->num_freqnum);
20652
20653 if (param_buf->num_nfdbr >
20654 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20655 WMI_LOGE("invalid number of nfdBr");
20656 return QDF_STATUS_E_FAILURE;
20657 }
20658
20659 if (param_buf->num_nfdbm >
20660 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20661 WMI_LOGE("invalid number of nfdBm");
20662 return QDF_STATUS_E_FAILURE;
20663 }
20664
20665 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20666 WMI_LOGE("invalid number of freqNum");
20667 return QDF_STATUS_E_FAILURE;
20668 }
20669
20670 for (i = 0; i < param_buf->num_nfdbr; i++) {
20671 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20672 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20673 ch_nfdbr++;
20674 ch_nfdbm++;
20675 }
20676
20677 for (i = 0; i < param_buf->num_freqnum; i++) {
20678 param->freqnum[i] = ch_freqnum->freqNum;
20679 ch_freqnum++;
20680 }
20681
20682 param->pdev_id = event->pdev_id;
20683
20684 return QDF_STATUS_SUCCESS;
20685}
20686
Sathish Kumard3ab1002017-02-07 17:10:59 +053020687
20688#ifdef BIG_ENDIAN_HOST
20689/**
20690 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20691 * @param data_len - data length
20692 * @param data - pointer to data
20693 *
20694 * Return: QDF_STATUS - success or error status
20695 */
20696static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20697{
20698 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020699 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020700 /* Skip swapping the first word */
20701 datap += sizeof(uint32_t);
20702 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20703 i++, datap += sizeof(uint32_t)) {
20704 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20705 }
20706
20707 return QDF_STATUS_SUCCESS;
20708}
20709#else
20710/**
20711 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20712 * @param data_len - data length
20713 * @param data - pointer to data
20714 *
20715 * Return: QDF_STATUS - success or error status
20716 */
20717static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20718{
20719 return QDF_STATUS_SUCCESS;
20720}
20721#endif
20722
20723/**
20724 * extract_wds_addr_event_tlv() - extract wds address from event
20725 * @wmi_handle: wmi handle
20726 * @param evt_buf: pointer to event buffer
20727 * @param wds_ev: Pointer to hold wds address
20728 *
20729 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20730 */
20731static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20732 void *evt_buf,
20733 uint16_t len, wds_addr_event_t *wds_ev)
20734{
20735 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20736 wmi_wds_addr_event_fixed_param *ev;
20737 int i;
20738
20739 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20740 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20741
20742 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20743 return QDF_STATUS_E_FAILURE;
20744
20745 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20746 sizeof(wds_ev->event_type));
20747 for (i = 0; i < 4; i++) {
20748 wds_ev->peer_mac[i] =
20749 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20750 wds_ev->dest_mac[i] =
20751 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20752 }
20753 for (i = 0; i < 2; i++) {
20754 wds_ev->peer_mac[4+i] =
20755 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20756 wds_ev->dest_mac[4+i] =
20757 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20758 }
20759 return QDF_STATUS_SUCCESS;
20760}
20761
20762/**
20763 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20764 * from event
20765 * @wmi_handle: wmi handle
20766 * @param evt_buf: pointer to event buffer
20767 * @param ev: Pointer to hold peer param and ps state
20768 *
20769 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20770 */
20771static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20772 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20773{
20774 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20775 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20776
20777 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20778 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20779 param_buf->fixed_param;
20780
20781 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20782 ev->peer_ps_state = event->peer_ps_state;
20783
20784 return QDF_STATUS_SUCCESS;
20785}
20786
20787/**
20788 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20789 * @wmi_handle: wmi handle
20790 * @param evt_buf: pointer to event buffer
20791 * @param inst_rssi_resp: Pointer to hold inst rssi response
20792 *
20793 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20794 */
20795static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20796 wmi_unified_t wmi_handle, void *evt_buf,
20797 wmi_host_inst_stats_resp *inst_rssi_resp)
20798{
20799 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20800 wmi_inst_rssi_stats_resp_fixed_param *event;
20801
20802 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20803 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20804
20805 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20806 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20807 inst_rssi_resp->iRSSI = event->iRSSI;
20808
20809 return QDF_STATUS_SUCCESS;
20810}
20811
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020812static struct cur_reg_rule
20813*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20814 wmi_regulatory_rule_struct *wmi_reg_rule)
20815{
20816 struct cur_reg_rule *reg_rule_ptr;
20817 uint32_t count;
20818
20819 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20820
20821 if (NULL == reg_rule_ptr) {
20822 WMI_LOGE("memory allocation failure");
20823 return NULL;
20824 }
20825
20826 for (count = 0; count < num_reg_rules; count++) {
20827 reg_rule_ptr[count].start_freq =
20828 WMI_REG_RULE_START_FREQ_GET(
20829 wmi_reg_rule[count].freq_info);
20830 reg_rule_ptr[count].end_freq =
20831 WMI_REG_RULE_END_FREQ_GET(
20832 wmi_reg_rule[count].freq_info);
20833 reg_rule_ptr[count].max_bw =
20834 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020835 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020836 reg_rule_ptr[count].reg_power =
20837 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020838 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020839 reg_rule_ptr[count].ant_gain =
20840 WMI_REG_RULE_ANTENNA_GAIN_GET(
20841 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020842 reg_rule_ptr[count].flags =
20843 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020844 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020845 }
20846
20847 return reg_rule_ptr;
20848}
20849
20850static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20851 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20852 struct cur_regulatory_info *reg_info, uint32_t len)
20853{
20854 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20855 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20856 wmi_regulatory_rule_struct *wmi_reg_rule;
20857 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20858
20859 WMI_LOGD("processing regulatory channel list");
20860
20861 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20862 if (!param_buf) {
20863 WMI_LOGE("invalid channel list event buf");
20864 return QDF_STATUS_E_FAILURE;
20865 }
20866
20867 chan_list_event_hdr = param_buf->fixed_param;
20868
20869 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20870 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20871 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020872 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020873 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20874 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020875 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020876 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020877 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020878 reg_info->ctry_code = chan_list_event_hdr->country_id;
20879 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20880 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20881 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20882 else if (chan_list_event_hdr->status_code ==
20883 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20884 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20885 else if (chan_list_event_hdr->status_code ==
20886 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20887 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20888 else if (chan_list_event_hdr->status_code ==
20889 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20890 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20891 else if (chan_list_event_hdr->status_code ==
20892 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20893 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20894 else if (chan_list_event_hdr->status_code ==
20895 WMI_REG_SET_CC_STATUS_FAIL)
20896 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20897
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020898 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20899 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20900 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20901 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20902
20903 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20904 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20905
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020906 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20907 __func__, reg_info->alpha2, reg_info->dfs_region,
20908 reg_info->min_bw_2g, reg_info->max_bw_2g,
20909 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020910
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020911 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20912 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020913 wmi_reg_rule =
20914 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20915 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20916 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020917 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20918 wmi_reg_rule);
20919 wmi_reg_rule += num_2g_reg_rules;
20920
20921 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20922 wmi_reg_rule);
20923
20924 WMI_LOGD("processed regulatory channel list");
20925
20926 return QDF_STATUS_SUCCESS;
20927}
20928
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020929static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20930 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20931 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20932{
20933 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20934 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20935
20936 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20937 if (!param_buf) {
20938 WMI_LOGE("invalid 11d country event buf");
20939 return QDF_STATUS_E_FAILURE;
20940 }
20941
20942 reg_11d_country_event = param_buf->fixed_param;
20943
20944 qdf_mem_copy(reg_11d_country->alpha2,
20945 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20946
20947 WMI_LOGD("processed 11d country event, new cc %s",
20948 reg_11d_country->alpha2);
20949
20950 return QDF_STATUS_SUCCESS;
20951}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020952
20953static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20954 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20955 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20956{
20957 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20958 wmi_avoid_freq_range_desc *afr_desc;
20959 uint32_t num_freq_ranges, freq_range_idx;
20960 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20961 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20962
20963 if (!param_buf) {
20964 WMI_LOGE("Invalid channel avoid event buffer");
20965 return QDF_STATUS_E_INVAL;
20966 }
20967
20968 afr_fixed_param = param_buf->fixed_param;
20969 if (!afr_fixed_param) {
20970 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20971 return QDF_STATUS_E_INVAL;
20972 }
20973
20974 if (!ch_avoid_ind) {
20975 WMI_LOGE("Invalid channel avoid indication buffer");
20976 return QDF_STATUS_E_INVAL;
20977 }
20978 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20979 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20980 afr_fixed_param->num_freq_ranges;
20981
20982 WMI_LOGD("Channel avoid event received with %d ranges",
20983 num_freq_ranges);
20984
20985 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20986 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20987 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20988 freq_range_idx++) {
20989 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20990 afr_desc->start_freq;
20991 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20992 afr_desc->end_freq;
20993 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20994 freq_range_idx, afr_desc->tlv_header,
20995 afr_desc->start_freq, afr_desc->end_freq);
20996 afr_desc++;
20997 }
20998
20999 return QDF_STATUS_SUCCESS;
21000}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021001#ifdef DFS_COMPONENT_ENABLE
21002/**
21003 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
21004 * @wmi_handle: wma handle
21005 * @evt_buf: event buffer
21006 * @vdev_id: vdev id
21007 * @len: length of buffer
21008 *
21009 * Return: 0 for success or error code
21010 */
21011static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
21012 uint8_t *evt_buf,
21013 uint32_t *vdev_id,
21014 uint32_t len)
21015{
21016 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
21017 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
21018
21019 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
21020 if (!param_tlvs) {
21021 WMI_LOGE("invalid cac complete event buf");
21022 return QDF_STATUS_E_FAILURE;
21023 }
21024
21025 cac_event = param_tlvs->fixed_param;
21026 *vdev_id = cac_event->vdev_id;
21027 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
21028
21029 return QDF_STATUS_SUCCESS;
21030}
21031
21032/**
21033 * extract_dfs_radar_detection_event_tlv() - extract radar found event
21034 * @wmi_handle: wma handle
21035 * @evt_buf: event buffer
21036 * @radar_found: radar found event info
21037 * @len: length of buffer
21038 *
21039 * Return: 0 for success or error code
21040 */
21041static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21042 wmi_unified_t wmi_handle,
21043 uint8_t *evt_buf,
21044 struct radar_found_info *radar_found,
21045 uint32_t len)
21046{
21047 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21048 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21049
21050 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21051 if (!param_tlv) {
21052 WMI_LOGE("invalid radar detection event buf");
21053 return QDF_STATUS_E_FAILURE;
21054 }
21055
21056 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021057 radar_found->pdev_id = wmi_handle->ops->
21058 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021059 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021060 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021061 radar_found->chan_width = radar_event->chan_width;
21062 radar_found->detector_id = radar_event->detector_id;
21063 radar_found->segment_id = radar_event->segment_id;
21064 radar_found->timestamp = radar_event->timestamp;
21065 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021066 radar_found->freq_offset = radar_event->freq_offset;
21067 radar_found->sidx = radar_event->sidx;
21068
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021069 WMI_LOGI("processed radar found event pdev %d,"
21070 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21071 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21072 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21073 "is_chirp %d,detection mode %d\n",
21074 radar_event->pdev_id, radar_event->pdev_id,
21075 radar_event->timestamp, radar_event->chan_freq,
21076 radar_event->chan_width, radar_event->detector_id,
21077 radar_event->freq_offset, radar_event->segment_id,
21078 radar_event->sidx, radar_event->is_chirp,
21079 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021080
21081 return QDF_STATUS_SUCCESS;
21082}
bings1ea12532017-12-18 16:56:53 +080021083
21084#ifdef QCA_MCL_DFS_SUPPORT
21085/**
21086 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21087 * @wmi_handle: wma handle
21088 * @evt_buf: event buffer
21089 * @wlan_radar_event: Pointer to struct radar_event_info
21090 * @len: length of buffer
21091 *
21092 * Return: QDF_STATUS
21093 */
21094static QDF_STATUS extract_wlan_radar_event_info_tlv(
21095 wmi_unified_t wmi_handle,
21096 uint8_t *evt_buf,
21097 struct radar_event_info *wlan_radar_event,
21098 uint32_t len)
21099{
21100 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21101 wmi_dfs_radar_event_fixed_param *radar_event;
21102
21103 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21104 if (!param_tlv) {
21105 WMI_LOGE("invalid wlan radar event buf");
21106 return QDF_STATUS_E_FAILURE;
21107 }
21108
21109 radar_event = param_tlv->fixed_param;
21110 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21111 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21112 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21113 wlan_radar_event->rssi = radar_event->rssi;
21114 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21115 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21116 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21117 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021118 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21119 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings1ea12532017-12-18 16:56:53 +080021120 wlan_radar_event->pdev_id = radar_event->pdev_id;
21121
21122 return QDF_STATUS_SUCCESS;
21123}
21124#else
21125static QDF_STATUS extract_wlan_radar_event_info_tlv(
21126 wmi_unified_t wmi_handle,
21127 uint8_t *evt_buf,
21128 struct radar_event_info *wlan_radar_event,
21129 uint32_t len)
21130{
21131 return QDF_STATUS_SUCCESS;
21132}
21133#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021134#endif
21135
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021136/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021137 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21138 * @wmi_handle: wmi handle
21139 * @get_rcpi_param: rcpi params
21140 *
21141 * Return: QDF status
21142 */
21143static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21144 struct rcpi_req *get_rcpi_param)
21145{
21146 wmi_buf_t buf;
21147 wmi_request_rcpi_cmd_fixed_param *cmd;
21148 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21149
21150 buf = wmi_buf_alloc(wmi_handle, len);
21151 if (!buf) {
21152 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21153 return QDF_STATUS_E_NOMEM;
21154 }
21155
21156 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21157 WMITLV_SET_HDR(&cmd->tlv_header,
21158 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21159 WMITLV_GET_STRUCT_TLVLEN
21160 (wmi_request_rcpi_cmd_fixed_param));
21161
21162 cmd->vdev_id = get_rcpi_param->vdev_id;
21163 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21164 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070021165
21166 switch (get_rcpi_param->measurement_type) {
21167
21168 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21169 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21170 break;
21171
21172 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
21173 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
21174 break;
21175
21176 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21177 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21178 break;
21179
21180 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
21181 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
21182 break;
21183
21184 default:
21185 /*
21186 * invalid rcpi measurement type, fall back to
21187 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
21188 */
21189 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21190 break;
21191 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021192 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21193 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21194 WMI_REQUEST_RCPI_CMDID)) {
21195
21196 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21197 __func__);
21198 wmi_buf_free(buf);
21199 return QDF_STATUS_E_FAILURE;
21200 }
21201
21202 return QDF_STATUS_SUCCESS;
21203}
21204
21205/**
21206 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21207 * @wmi_handle: wmi handle
21208 * @evt_buf: pointer to event buffer
21209 * @res: pointer to hold rcpi response from firmware
21210 *
21211 * Return: QDF_STATUS_SUCCESS for successful event parse
21212 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21213 */
21214static QDF_STATUS
21215extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21216 void *evt_buf, struct rcpi_res *res)
21217{
21218 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21219 wmi_update_rcpi_event_fixed_param *event;
21220
21221 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21222 if (!param_buf) {
21223 WMI_LOGE(FL("Invalid rcpi event"));
21224 return QDF_STATUS_E_INVAL;
21225 }
21226
21227 event = param_buf->fixed_param;
21228 res->vdev_id = event->vdev_id;
21229 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21230
21231 switch (event->measurement_type) {
21232
21233 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21234 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21235 break;
21236
21237 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21238 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21239 break;
21240
21241 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21242 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21243 break;
21244
21245 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21246 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21247 break;
21248
21249 default:
21250 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21251 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21252 return QDF_STATUS_E_FAILURE;
21253 }
21254
21255 if (event->status)
21256 return QDF_STATUS_E_FAILURE;
21257 else
21258 return QDF_STATUS_SUCCESS;
21259}
21260
21261/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021262 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21263 * host to target defines. For legacy there is not conversion
21264 * required. Just return pdev_id as it is.
21265 * @param pdev_id: host pdev_id to be converted.
21266 * Return: target pdev_id after conversion.
21267 */
21268static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21269 uint32_t pdev_id)
21270{
21271 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21272 return WMI_PDEV_ID_SOC;
21273
21274 /*No conversion required*/
21275 return pdev_id;
21276}
21277
21278/**
21279 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21280 * target to host defines. For legacy there is not conversion
21281 * required. Just return pdev_id as it is.
21282 * @param pdev_id: target pdev_id to be converted.
21283 * Return: host pdev_id after conversion.
21284 */
21285static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21286 uint32_t pdev_id)
21287{
21288 /*No conversion required*/
21289 return pdev_id;
21290}
21291
21292/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021293 * send_set_country_cmd_tlv() - WMI scan channel list function
21294 * @param wmi_handle : handle to WMI.
21295 * @param param : pointer to hold scan channel list parameter
21296 *
21297 * Return: 0 on success and -ve on failure.
21298 */
21299static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21300 struct set_country *params)
21301{
21302 wmi_buf_t buf;
21303 QDF_STATUS qdf_status;
21304 wmi_set_current_country_cmd_fixed_param *cmd;
21305 uint16_t len = sizeof(*cmd);
21306
21307 buf = wmi_buf_alloc(wmi_handle, len);
21308 if (!buf) {
21309 WMI_LOGE("Failed to allocate memory");
21310 qdf_status = QDF_STATUS_E_NOMEM;
21311 goto end;
21312 }
21313
21314 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21315 WMITLV_SET_HDR(&cmd->tlv_header,
21316 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21317 WMITLV_GET_STRUCT_TLVLEN
21318 (wmi_set_current_country_cmd_fixed_param));
21319
21320 WMI_LOGD("setting cuurnet country to %s", params->country);
21321
21322 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21323
21324 cmd->pdev_id = params->pdev_id;
21325
21326 qdf_status = wmi_unified_cmd_send(wmi_handle,
21327 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21328
21329 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21330 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21331 wmi_buf_free(buf);
21332 }
21333
21334end:
21335 return qdf_status;
21336}
21337
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021338#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21339 WMI_SET_BITS(alpha, 0, 8, val0); \
21340 WMI_SET_BITS(alpha, 8, 8, val1); \
21341 WMI_SET_BITS(alpha, 16, 8, val2); \
21342 } while (0)
21343
21344static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21345 uint8_t pdev_id, struct cc_regdmn_s *rd)
21346{
21347 wmi_set_init_country_cmd_fixed_param *cmd;
21348 uint16_t len;
21349 wmi_buf_t buf;
21350 int ret;
21351
21352 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21353 buf = wmi_buf_alloc(wmi_handle, len);
21354 if (!buf) {
21355 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21356 return QDF_STATUS_E_NOMEM;
21357 }
21358 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21359 WMITLV_SET_HDR(&cmd->tlv_header,
21360 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21361 WMITLV_GET_STRUCT_TLVLEN
21362 (wmi_set_init_country_cmd_fixed_param));
21363
21364 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21365
21366 if (rd->flags == CC_IS_SET) {
21367 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21368 cmd->country_code.country_id = rd->cc.country_code;
21369 } else if (rd->flags == ALPHA_IS_SET) {
21370 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21371 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21372 rd->cc.alpha[0],
21373 rd->cc.alpha[1],
21374 rd->cc.alpha[2]);
21375 } else if (rd->flags == REGDMN_IS_SET) {
21376 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21377 cmd->country_code.domain_code = rd->cc.regdmn_id;
21378 }
21379
21380 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21381 WMI_SET_INIT_COUNTRY_CMDID);
21382 if (ret) {
21383 WMI_LOGE("Failed to config wow wakeup event");
21384 wmi_buf_free(buf);
21385 return QDF_STATUS_E_FAILURE;
21386 }
21387
21388 return QDF_STATUS_SUCCESS;
21389}
21390
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021391/**
21392 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21393 * configuration params
21394 * @wmi_handle: wmi handler
21395 * @limit_off_chan_param: pointer to wmi_off_chan_param
21396 *
21397 * Return: 0 for success and non zero for failure
21398 */
21399static
21400QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21401 struct wmi_limit_off_chan_param *limit_off_chan_param)
21402{
21403 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21404 wmi_buf_t buf;
21405 uint32_t len = sizeof(*cmd);
21406 int err;
21407
21408 buf = wmi_buf_alloc(wmi_handle, len);
21409 if (!buf) {
21410 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21411 __func__);
21412 return QDF_STATUS_E_NOMEM;
21413 }
21414
21415 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21416
21417 WMITLV_SET_HDR(&cmd->tlv_header,
21418 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21419 WMITLV_GET_STRUCT_TLVLEN(
21420 wmi_vdev_limit_offchan_cmd_fixed_param));
21421
21422 cmd->vdev_id = limit_off_chan_param->vdev_id;
21423
21424 cmd->flags &= 0;
21425 if (limit_off_chan_param->status)
21426 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21427 if (limit_off_chan_param->skip_dfs_chans)
21428 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21429
21430 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21431 cmd->rest_time = limit_off_chan_param->rest_time;
21432
21433 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21434 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21435 cmd->rest_time);
21436
21437 err = wmi_unified_cmd_send(wmi_handle, buf,
21438 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21439 if (QDF_IS_STATUS_ERROR(err)) {
21440 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21441 wmi_buf_free(buf);
21442 return QDF_STATUS_E_FAILURE;
21443 }
21444
21445 return QDF_STATUS_SUCCESS;
21446}
21447
Anurag Chouhan97f00422017-09-11 14:56:30 +053021448/**
21449 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21450 * @wmi_handle: wmi handler
21451 * @req_buf: set arp stats request buffer
21452 *
21453 * Return: 0 for success and non zero for failure
21454 */
21455static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21456 struct set_arp_stats *req_buf)
21457{
21458 wmi_buf_t buf = NULL;
21459 QDF_STATUS status;
21460 int len;
21461 uint8_t *buf_ptr;
21462 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21463
21464 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021465 if (req_buf->pkt_type_bitmap) {
21466 len += WMI_TLV_HDR_SIZE;
21467 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21468 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021469 buf = wmi_buf_alloc(wmi_handle, len);
21470 if (!buf) {
21471 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21472 return QDF_STATUS_E_NOMEM;
21473 }
21474
21475 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21476 wmi_set_arp =
21477 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21478 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21479 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21480 WMITLV_GET_STRUCT_TLVLEN
21481 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21482
21483 /* fill in per roam config values */
21484 wmi_set_arp->vdev_id = req_buf->vdev_id;
21485
21486 wmi_set_arp->set_clr = req_buf->flag;
21487 wmi_set_arp->pkt_type = req_buf->pkt_type;
21488 wmi_set_arp->ipv4 = req_buf->ip_addr;
21489
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021490 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21491 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21492 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21493
21494 /*
21495 * pkt_type_bitmap should be non-zero to ensure
21496 * presence of additional stats.
21497 */
21498 if (req_buf->pkt_type_bitmap) {
21499 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21500
21501 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21502 WMITLV_SET_HDR(buf_ptr,
21503 WMITLV_TAG_ARRAY_STRUC,
21504 sizeof(wmi_vdev_set_connectivity_check_stats));
21505 buf_ptr += WMI_TLV_HDR_SIZE;
21506 wmi_set_connect_stats =
21507 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21508 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21509 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21510 WMITLV_GET_STRUCT_TLVLEN(
21511 wmi_vdev_set_connectivity_check_stats));
21512 wmi_set_connect_stats->pkt_type_bitmap =
21513 req_buf->pkt_type_bitmap;
21514 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21515 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21516 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21517
21518 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21519 wmi_set_connect_stats->pkt_type_bitmap,
21520 wmi_set_connect_stats->tcp_src_port,
21521 wmi_set_connect_stats->tcp_dst_port,
21522 wmi_set_connect_stats->icmp_ipv4);
21523 }
21524
Anurag Chouhan97f00422017-09-11 14:56:30 +053021525 /* Send per roam config parameters */
21526 status = wmi_unified_cmd_send(wmi_handle, buf,
21527 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21528 if (QDF_IS_STATUS_ERROR(status)) {
21529 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21530 status);
21531 goto error;
21532 }
21533
21534 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21535 req_buf->flag, req_buf->vdev_id);
21536 return QDF_STATUS_SUCCESS;
21537error:
21538 wmi_buf_free(buf);
21539
21540 return status;
21541}
21542
21543/**
21544 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21545 * @wmi_handle: wmi handler
21546 * @req_buf: get arp stats request buffer
21547 *
21548 * Return: 0 for success and non zero for failure
21549 */
21550static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21551 struct get_arp_stats *req_buf)
21552{
21553 wmi_buf_t buf = NULL;
21554 QDF_STATUS status;
21555 int len;
21556 uint8_t *buf_ptr;
21557 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21558
21559 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21560 buf = wmi_buf_alloc(wmi_handle, len);
21561 if (!buf) {
21562 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21563 return QDF_STATUS_E_NOMEM;
21564 }
21565
21566 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21567 get_arp_stats =
21568 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21569 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21570 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21571 WMITLV_GET_STRUCT_TLVLEN
21572 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21573
21574 /* fill in arp stats req cmd values */
21575 get_arp_stats->vdev_id = req_buf->vdev_id;
21576
21577 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21578 /* Send per roam config parameters */
21579 status = wmi_unified_cmd_send(wmi_handle, buf,
21580 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21581 if (QDF_IS_STATUS_ERROR(status)) {
21582 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21583 status);
21584 goto error;
21585 }
21586
21587 return QDF_STATUS_SUCCESS;
21588error:
21589 wmi_buf_free(buf);
21590
21591 return status;
21592}
21593
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021594/**
21595 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21596 * @wmi_handle: wmi handler
21597 * @pmk_info: pointer to PMK cache entry
21598 * @vdev_id: vdev id
21599 *
21600 * Return: 0 for success and non zero for failure
21601 */
21602static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21603 struct wmi_unified_pmk_cache *pmk_info)
21604{
21605 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21606 wmi_buf_t buf;
21607 QDF_STATUS status;
21608 uint8_t *buf_ptr;
21609 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021610 uint32_t len = sizeof(*cmd);
21611
21612 if (pmk_info->pmk_len)
21613 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021614
21615 buf = wmi_buf_alloc(wmi_handle, len);
21616 if (!buf) {
21617 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21618 __func__);
21619 return QDF_STATUS_E_NOMEM;
21620 }
21621
21622 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21623 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21624
21625 WMITLV_SET_HDR(&cmd->tlv_header,
21626 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21627 WMITLV_GET_STRUCT_TLVLEN(
21628 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21629
21630 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021631
21632 /* If pmk_info->pmk_len is 0, this is a flush request */
21633 if (!pmk_info->pmk_len) {
21634 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21635 cmd->num_cache = 0;
21636 goto send_cmd;
21637 }
21638
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021639 cmd->num_cache = 1;
21640 buf_ptr += sizeof(*cmd);
21641
21642 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21643 sizeof(*pmksa));
21644 buf_ptr += WMI_TLV_HDR_SIZE;
21645
21646 pmksa = (wmi_pmk_cache *)buf_ptr;
21647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21648 WMITLV_GET_STRUCT_TLVLEN
21649 (wmi_pmk_cache));
21650 pmksa->pmk_len = pmk_info->pmk_len;
21651 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21652 pmksa->pmkid_len = pmk_info->pmkid_len;
21653 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21654 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21655 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21656 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21657 pmksa->ssid.ssid_len);
21658 pmksa->cache_id = pmk_info->cache_id;
21659 pmksa->cat_flag = pmk_info->cat_flag;
21660 pmksa->action_flag = pmk_info->action_flag;
21661
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021662send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021663 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21664 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21665 if (status != QDF_STATUS_SUCCESS) {
21666 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21667 __func__, status);
21668 wmi_buf_free(buf);
21669 }
21670
21671 return status;
21672}
21673
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021674/**
21675 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21676 * @wmi_handle: wmi handle
21677 * @param: reserved param
21678 *
21679 * Return: 0 for success or error code
21680 */
21681static QDF_STATUS
21682send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21683 uint32_t param)
21684{
21685 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21686 wmi_buf_t buf;
21687 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21688
21689 buf = wmi_buf_alloc(wmi_handle, len);
21690 if (!buf) {
21691 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21692 return QDF_STATUS_E_FAILURE;
21693 }
21694 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21695 WMITLV_SET_HDR(&cmd->tlv_header,
21696 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21697 WMITLV_GET_STRUCT_TLVLEN
21698 (wmi_pdev_check_cal_version_cmd_fixed_param));
21699 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21700 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21701 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21702 wmi_buf_free(buf);
21703 return QDF_STATUS_E_FAILURE;
21704 }
21705
21706 return QDF_STATUS_SUCCESS;
21707}
21708
21709/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021710 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21711 * host to target defines.
21712 * @param pdev_id: host pdev_id to be converted.
21713 * Return: target pdev_id after conversion.
21714 */
21715static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21716{
21717 switch (pdev_id) {
21718 case WMI_HOST_PDEV_ID_SOC:
21719 return WMI_PDEV_ID_SOC;
21720 case WMI_HOST_PDEV_ID_0:
21721 return WMI_PDEV_ID_1ST;
21722 case WMI_HOST_PDEV_ID_1:
21723 return WMI_PDEV_ID_2ND;
21724 case WMI_HOST_PDEV_ID_2:
21725 return WMI_PDEV_ID_3RD;
21726 }
21727
21728 QDF_ASSERT(0);
21729
21730 return WMI_PDEV_ID_SOC;
21731}
21732
21733/**
21734 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21735 * target to host defines.
21736 * @param pdev_id: target pdev_id to be converted.
21737 * Return: host pdev_id after conversion.
21738 */
21739static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21740{
21741 switch (pdev_id) {
21742 case WMI_PDEV_ID_SOC:
21743 return WMI_HOST_PDEV_ID_SOC;
21744 case WMI_PDEV_ID_1ST:
21745 return WMI_HOST_PDEV_ID_0;
21746 case WMI_PDEV_ID_2ND:
21747 return WMI_HOST_PDEV_ID_1;
21748 case WMI_PDEV_ID_3RD:
21749 return WMI_HOST_PDEV_ID_2;
21750 }
21751
21752 QDF_ASSERT(0);
21753
21754 return WMI_HOST_PDEV_ID_SOC;
21755}
21756
21757/**
21758 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21759 *
21760 * Return None.
21761 */
21762static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21763{
21764 wmi_handle->ops->convert_pdev_id_host_to_target =
21765 convert_host_pdev_id_to_target_pdev_id;
21766 wmi_handle->ops->convert_pdev_id_target_to_host =
21767 convert_target_pdev_id_to_host_pdev_id;
21768}
21769
21770/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021771 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21772 * @wmi_handle: wmi handle
21773 * @param evt_buf: pointer to event buffer
21774 * @param param: Pointer to hold peer caldata version data
21775 *
21776 * Return: 0 for success or error code
21777 */
21778static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21779 wmi_unified_t wmi_handle,
21780 void *evt_buf,
21781 wmi_host_pdev_check_cal_version_event *param)
21782{
21783 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21784 wmi_pdev_check_cal_version_event_fixed_param *event;
21785
21786 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21787 if (!param_tlvs) {
21788 WMI_LOGE("invalid cal version event buf");
21789 return QDF_STATUS_E_FAILURE;
21790 }
21791 event = param_tlvs->fixed_param;
21792 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21793 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21794 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21795 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21796
21797 param->software_cal_version = event->software_cal_version;
21798 param->board_cal_version = event->board_cal_version;
21799 param->cal_ok = event->cal_status;
21800
21801 return QDF_STATUS_SUCCESS;
21802}
21803
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021804/*
21805 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21806 * @wmi_handle: wmi handle
21807 * @params: pointer to wmi_btm_config
21808 *
21809 * Return: QDF_STATUS
21810 */
21811static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21812 struct wmi_btm_config *params)
21813{
21814
21815 wmi_btm_config_fixed_param *cmd;
21816 wmi_buf_t buf;
21817 uint32_t len;
21818
21819 len = sizeof(*cmd);
21820 buf = wmi_buf_alloc(wmi_handle, len);
21821 if (!buf) {
21822 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21823 return QDF_STATUS_E_NOMEM;
21824 }
21825
21826 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21827 WMITLV_SET_HDR(&cmd->tlv_header,
21828 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21829 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21830 cmd->vdev_id = params->vdev_id;
21831 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021832 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21833 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21834 cmd->stick_time_seconds = params->btm_sticky_time;
21835
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021836 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21837 WMI_ROAM_BTM_CONFIG_CMDID)) {
21838 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21839 __func__);
21840 wmi_buf_free(buf);
21841 return QDF_STATUS_E_FAILURE;
21842 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021843
21844 return QDF_STATUS_SUCCESS;
21845}
21846
21847/**
21848 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21849 * configurations to firmware.
21850 * @wmi_handle: wmi handle
21851 * @obss_cfg_param: obss detection configurations
21852 *
21853 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21854 *
21855 * Return: QDF_STATUS
21856 */
21857static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21858 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21859{
21860 wmi_buf_t buf;
21861 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21862 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21863
21864 buf = wmi_buf_alloc(wmi_handle, len);
21865 if (!buf) {
21866 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21867 return QDF_STATUS_E_NOMEM;
21868 }
21869
21870 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21871 WMITLV_SET_HDR(&cmd->tlv_header,
21872 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21873 WMITLV_GET_STRUCT_TLVLEN
21874 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21875
21876 cmd->vdev_id = obss_cfg_param->vdev_id;
21877 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21878 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21879 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21880 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21881 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21882 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21883 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21884 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021885
21886 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21887 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21888 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21889 wmi_buf_free(buf);
21890 return QDF_STATUS_E_FAILURE;
21891 }
21892
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021893 return QDF_STATUS_SUCCESS;
21894}
21895
Arif Hussain33d98502018-01-12 13:15:04 -080021896/**
21897 * extract_obss_detection_info_tlv() - Extract obss detection info
21898 * received from firmware.
21899 * @evt_buf: pointer to event buffer
21900 * @obss_detection: Pointer to hold obss detection info
21901 *
21902 * Return: QDF_STATUS
21903 */
21904static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21905 struct wmi_obss_detect_info
21906 *obss_detection)
21907{
21908 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21909 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21910
21911 if (!obss_detection) {
21912 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21913 return QDF_STATUS_E_INVAL;
21914 }
21915
21916 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21917 if (!param_buf) {
21918 WMI_LOGE("%s: Invalid evt_buf", __func__);
21919 return QDF_STATUS_E_INVAL;
21920 }
21921
21922 fix_param = param_buf->fixed_param;
21923 obss_detection->vdev_id = fix_param->vdev_id;
21924 obss_detection->matched_detection_masks =
21925 fix_param->matched_detection_masks;
21926 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21927 &obss_detection->matched_bssid_addr[0]);
21928 switch (fix_param->reason) {
21929 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21930 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21931 break;
21932 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21933 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21934 break;
21935 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21936 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21937 break;
21938 default:
21939 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21940 return QDF_STATUS_E_INVAL;
21941 }
21942
21943 return QDF_STATUS_SUCCESS;
21944}
21945
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021946/**
21947 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21948 * @wmi_handle: wmi handler
21949 * @params: pointer to 11k offload params
21950 *
21951 * Return: 0 for success and non zero for failure
21952 */
21953static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21954 struct wmi_11k_offload_params *params)
21955{
21956 wmi_11k_offload_report_fixed_param *cmd;
21957 wmi_buf_t buf;
21958 QDF_STATUS status;
21959 uint8_t *buf_ptr;
21960 wmi_neighbor_report_11k_offload_tlv_param
21961 *neighbor_report_offload_params;
21962 wmi_neighbor_report_offload *neighbor_report_offload;
21963
21964 uint32_t len = sizeof(*cmd);
21965
21966 if (params->offload_11k_bitmask &
21967 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21968 len += WMI_TLV_HDR_SIZE +
21969 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21970
21971 buf = wmi_buf_alloc(wmi_handle, len);
21972 if (!buf) {
21973 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21974 __func__);
21975 return QDF_STATUS_E_NOMEM;
21976 }
21977
21978 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21979 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21980
21981 WMITLV_SET_HDR(&cmd->tlv_header,
21982 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21983 WMITLV_GET_STRUCT_TLVLEN(
21984 wmi_11k_offload_report_fixed_param));
21985
21986 cmd->vdev_id = params->vdev_id;
21987 cmd->offload_11k = params->offload_11k_bitmask;
21988
21989 if (params->offload_11k_bitmask &
21990 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21991 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21992
21993 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21994 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21995 buf_ptr += WMI_TLV_HDR_SIZE;
21996
21997 neighbor_report_offload_params =
21998 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21999 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
22000 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
22001 WMITLV_GET_STRUCT_TLVLEN(
22002 wmi_neighbor_report_11k_offload_tlv_param));
22003
22004 neighbor_report_offload = &neighbor_report_offload_params->
22005 neighbor_rep_ofld_params;
22006
22007 neighbor_report_offload->time_offset =
22008 params->neighbor_report_params.time_offset;
22009 neighbor_report_offload->low_rssi_offset =
22010 params->neighbor_report_params.low_rssi_offset;
22011 neighbor_report_offload->bmiss_count_trigger =
22012 params->neighbor_report_params.bmiss_count_trigger;
22013 neighbor_report_offload->per_threshold_offset =
22014 params->neighbor_report_params.per_threshold_offset;
22015 neighbor_report_offload->neighbor_report_cache_timeout =
22016 params->neighbor_report_params.
22017 neighbor_report_cache_timeout;
22018 neighbor_report_offload->max_neighbor_report_req_cap =
22019 params->neighbor_report_params.
22020 max_neighbor_report_req_cap;
22021 neighbor_report_offload->ssid.ssid_len =
22022 params->neighbor_report_params.ssid.length;
22023 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
22024 &params->neighbor_report_params.ssid.mac_ssid,
22025 neighbor_report_offload->ssid.ssid_len);
22026 }
22027
22028 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22029 WMI_11K_OFFLOAD_REPORT_CMDID);
22030 if (status != QDF_STATUS_SUCCESS) {
22031 WMI_LOGE("%s: failed to send 11k offload command %d",
22032 __func__, status);
22033 wmi_buf_free(buf);
22034 }
22035
22036 return status;
22037}
22038
22039/**
22040 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
22041 * command
22042 * @wmi_handle: wmi handler
22043 * @params: pointer to neighbor report invoke params
22044 *
22045 * Return: 0 for success and non zero for failure
22046 */
22047static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
22048 struct wmi_invoke_neighbor_report_params *params)
22049{
22050 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
22051 wmi_buf_t buf;
22052 QDF_STATUS status;
22053 uint8_t *buf_ptr;
22054 uint32_t len = sizeof(*cmd);
22055
22056 buf = wmi_buf_alloc(wmi_handle, len);
22057 if (!buf) {
22058 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22059 __func__);
22060 return QDF_STATUS_E_NOMEM;
22061 }
22062
22063 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22064 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22065
22066 WMITLV_SET_HDR(&cmd->tlv_header,
22067 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22068 WMITLV_GET_STRUCT_TLVLEN(
22069 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22070
22071 cmd->vdev_id = params->vdev_id;
22072 cmd->flags = params->send_resp_to_host;
22073
22074 cmd->ssid.ssid_len = params->ssid.length;
22075 qdf_mem_copy(cmd->ssid.ssid,
22076 &params->ssid.mac_ssid,
22077 cmd->ssid.ssid_len);
22078
22079 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22080 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22081 if (status != QDF_STATUS_SUCCESS) {
22082 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22083 __func__, status);
22084 wmi_buf_free(buf);
22085 }
22086
22087 return status;
22088}
22089
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022090#ifdef WLAN_SUPPORT_GREEN_AP
22091static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22092 uint8_t *evt_buf,
22093 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22094{
22095 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22096 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22097 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22098
22099 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22100 if (!param_buf) {
22101 WMI_LOGE("Invalid EGAP Info status event buffer");
22102 return QDF_STATUS_E_INVAL;
22103 }
22104
22105 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22106 param_buf->fixed_param;
22107 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22108 param_buf->chainmask_list;
22109
22110 egap_status_info_params->status = egap_info_event->status;
22111 egap_status_info_params->mac_id = chainmask_event->mac_id;
22112 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22113 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22114
22115 return QDF_STATUS_SUCCESS;
22116}
22117#endif
22118
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022119/*
22120 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22121 * updating bss color change within firmware when AP announces bss color change.
22122 * @wmi_handle: wmi handle
22123 * @vdev_id: vdev ID
22124 * @enable: enable bss color change within firmware
22125 *
22126 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22127 *
22128 * Return: QDF_STATUS
22129 */
22130static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22131 uint32_t vdev_id,
22132 bool enable)
22133{
22134 wmi_buf_t buf;
22135 wmi_bss_color_change_enable_fixed_param *cmd;
22136 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22137
22138 buf = wmi_buf_alloc(wmi_handle, len);
22139 if (!buf) {
22140 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22141 return QDF_STATUS_E_NOMEM;
22142 }
22143
22144 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22145 WMITLV_SET_HDR(&cmd->tlv_header,
22146 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22147 WMITLV_GET_STRUCT_TLVLEN
22148 (wmi_bss_color_change_enable_fixed_param));
22149 cmd->vdev_id = vdev_id;
22150 cmd->enable = enable;
22151 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22152 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22153 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22154 wmi_buf_free(buf);
22155 return QDF_STATUS_E_FAILURE;
22156 }
22157
22158 return QDF_STATUS_SUCCESS;
22159}
22160
22161/**
22162 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22163 * configurations to firmware.
22164 * @wmi_handle: wmi handle
22165 * @cfg_param: obss detection configurations
22166 *
22167 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22168 *
22169 * Return: QDF_STATUS
22170 */
22171static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22172 wmi_unified_t wmi_handle,
22173 struct wmi_obss_color_collision_cfg_param *cfg_param)
22174{
22175 wmi_buf_t buf;
22176 wmi_obss_color_collision_det_config_fixed_param *cmd;
22177 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22178
22179 buf = wmi_buf_alloc(wmi_handle, len);
22180 if (!buf) {
22181 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22182 return QDF_STATUS_E_NOMEM;
22183 }
22184
22185 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22186 buf);
22187 WMITLV_SET_HDR(&cmd->tlv_header,
22188 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22189 WMITLV_GET_STRUCT_TLVLEN
22190 (wmi_obss_color_collision_det_config_fixed_param));
22191 cmd->vdev_id = cfg_param->vdev_id;
22192 cmd->flags = cfg_param->flags;
22193 cmd->current_bss_color = cfg_param->current_bss_color;
22194 cmd->detection_period_ms = cfg_param->detection_period_ms;
22195 cmd->scan_period_ms = cfg_param->scan_period_ms;
22196 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22197
22198 switch (cfg_param->evt_type) {
22199 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22200 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22201 break;
22202 case OBSS_COLOR_COLLISION_DETECTION:
22203 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22204 break;
22205 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22206 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22207 break;
22208 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22209 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22210 break;
22211 default:
22212 WMI_LOGE("%s: invalid event type: %d",
22213 __func__, cfg_param->evt_type);
22214 wmi_buf_free(buf);
22215 return QDF_STATUS_E_FAILURE;
22216 }
22217
22218 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22219 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22220 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22221 __func__, cfg_param->vdev_id);
22222 wmi_buf_free(buf);
22223 return QDF_STATUS_E_FAILURE;
22224 }
22225
22226 return QDF_STATUS_SUCCESS;
22227}
22228
22229/**
22230 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22231 * received from firmware.
22232 * @evt_buf: pointer to event buffer
22233 * @info: Pointer to hold bss collision info
22234 *
22235 * Return: QDF_STATUS
22236 */
22237static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22238 struct wmi_obss_color_collision_info *info)
22239{
22240 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22241 wmi_obss_color_collision_evt_fixed_param *fix_param;
22242
22243 if (!info) {
22244 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22245 return QDF_STATUS_E_INVAL;
22246 }
22247
22248 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22249 evt_buf;
22250 if (!param_buf) {
22251 WMI_LOGE("%s: Invalid evt_buf", __func__);
22252 return QDF_STATUS_E_INVAL;
22253 }
22254
22255 fix_param = param_buf->fixed_param;
22256 info->vdev_id = fix_param->vdev_id;
22257 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22258 info->obss_color_bitmap_bit32to63 =
22259 fix_param->bss_color_bitmap_bit32to63;
22260
22261 switch (fix_param->evt_type) {
22262 case WMI_BSS_COLOR_COLLISION_DISABLE:
22263 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22264 break;
22265 case WMI_BSS_COLOR_COLLISION_DETECTION:
22266 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22267 break;
22268 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22269 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22270 break;
22271 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22272 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22273 break;
22274 default:
22275 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22276 __func__, fix_param->evt_type, fix_param->vdev_id);
22277 return QDF_STATUS_E_FAILURE;
22278 }
22279
22280 return QDF_STATUS_SUCCESS;
22281}
22282
Arif Hussaine0eb7302018-03-01 14:40:59 -080022283/*
22284 * extract_comb_phyerr_tlv() - extract comb phy error from event
22285 * @wmi_handle: wmi handle
22286 * @evt_buf: pointer to event buffer
22287 * @datalen: data length of event buffer
22288 * @buf_offset: Pointer to hold value of current event buffer offset
22289 * post extraction
22290 * @phyerr: Pointer to hold phyerr
22291 *
22292 * Return: QDF_STATUS
22293 */
22294static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22295 void *evt_buf,
22296 uint16_t datalen,
22297 uint16_t *buf_offset,
22298 wmi_host_phyerr_t *phyerr)
22299{
22300 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22301 wmi_comb_phyerr_rx_hdr *pe_hdr;
22302
22303 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22304 if (!param_tlvs) {
22305 WMI_LOGD("%s: Received null data from FW", __func__);
22306 return QDF_STATUS_E_FAILURE;
22307 }
22308
22309 pe_hdr = param_tlvs->hdr;
22310 if (!pe_hdr) {
22311 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22312 return QDF_STATUS_E_FAILURE;
22313 }
22314
22315 /* Ensure it's at least the size of the header */
22316 if (datalen < sizeof(*pe_hdr)) {
22317 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22318 __func__, sizeof(*pe_hdr), datalen);
22319 return QDF_STATUS_E_FAILURE;
22320 }
22321
22322 phyerr->pdev_id = wmi_handle->ops->
22323 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22324 phyerr->tsf64 = pe_hdr->tsf_l32;
22325 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22326 phyerr->bufp = param_tlvs->bufp;
22327 phyerr->buf_len = pe_hdr->buf_len;
22328 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22329 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22330 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22331
22332 return QDF_STATUS_SUCCESS;
22333}
22334
22335/**
22336 * extract_single_phyerr_tlv() - extract single phy error from event
22337 * @wmi_handle: wmi handle
22338 * @evt_buf: pointer to event buffer
22339 * @datalen: data length of event buffer
22340 * @buf_offset: Pointer to hold value of current event buffer offset
22341 * post extraction
22342 * @phyerr: Pointer to hold phyerr
22343 *
22344 * Return: QDF_STATUS
22345 */
22346static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22347 void *evt_buf,
22348 uint16_t datalen,
22349 uint16_t *buf_offset,
22350 wmi_host_phyerr_t *phyerr)
22351{
22352 wmi_single_phyerr_rx_event *ev;
22353 uint16_t n = *buf_offset;
22354 uint8_t *data = (uint8_t *)evt_buf;
22355
22356 if (n < datalen) {
22357 if ((datalen - n) < sizeof(ev->hdr)) {
22358 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22359 __func__, datalen, n, sizeof(ev->hdr));
22360 return QDF_STATUS_E_FAILURE;
22361 }
22362
22363 /*
22364 * Obtain a pointer to the beginning of the current event.
22365 * data[0] is the beginning of the WMI payload.
22366 */
22367 ev = (wmi_single_phyerr_rx_event *)&data[n];
22368
22369 /*
22370 * Sanity check the buffer length of the event against
22371 * what we currently have.
22372 *
22373 * Since buf_len is 32 bits, we check if it overflows
22374 * a large 32 bit value. It's not 0x7fffffff because
22375 * we increase n by (buf_len + sizeof(hdr)), which would
22376 * in itself cause n to overflow.
22377 *
22378 * If "int" is 64 bits then this becomes a moot point.
22379 */
22380 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22381 WMI_LOGD("%s: buf_len is garbage 0x%x",
22382 __func__, ev->hdr.buf_len);
22383 return QDF_STATUS_E_FAILURE;
22384 }
22385
22386 if ((n + ev->hdr.buf_len) > datalen) {
22387 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22388 __func__, n, ev->hdr.buf_len, datalen);
22389 return QDF_STATUS_E_FAILURE;
22390 }
22391
22392 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22393 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22394 phyerr->bufp = &ev->bufp[0];
22395 phyerr->buf_len = ev->hdr.buf_len;
22396 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22397
22398 /*
22399 * Advance the buffer pointer to the next PHY error.
22400 * buflen is the length of this payload, so we need to
22401 * advance past the current header _AND_ the payload.
22402 */
22403 n += sizeof(*ev) + ev->hdr.buf_len;
22404 }
22405 *buf_offset = n;
22406
22407 return QDF_STATUS_SUCCESS;
22408}
22409
Govind Singh5eb51532016-03-09 11:34:12 +053022410struct wmi_ops tlv_ops = {
22411 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22412 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22413 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022414 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22415 .send_hidden_ssid_vdev_restart_cmd =
22416 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022417 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22418 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22419 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022420 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022421 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022422 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022423 .send_peer_rx_reorder_queue_setup_cmd =
22424 send_peer_rx_reorder_queue_setup_cmd_tlv,
22425 .send_peer_rx_reorder_queue_remove_cmd =
22426 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022427 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22428 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22429 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022430 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22431 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022432 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022433 .send_suspend_cmd = send_suspend_cmd_tlv,
22434 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022435#ifdef FEATURE_WLAN_D0WOW
22436 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22437 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22438#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022439 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22440 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22441 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22442 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
22443 .send_dbglog_cmd = send_dbglog_cmd_tlv,
22444 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22445 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22446 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022447 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022448 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022449 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022450 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022451 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22452 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22453 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22454 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022455 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022456 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022457 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22458 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022459 .send_set_sta_uapsd_auto_trig_cmd =
22460 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022461 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22462 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22463 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022464#ifdef CONVERGED_P2P_ENABLE
22465 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22466 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22467#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022468 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22469 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022470#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022471 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22472 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22473 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22474 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22475 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22476 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22477 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022478 .send_ocb_start_timing_advert_cmd =
22479 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022480 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22481 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22482 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22483 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22484#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022485 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22486 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22487 .send_set_mcc_channel_time_latency_cmd =
22488 send_set_mcc_channel_time_latency_cmd_tlv,
22489 .send_set_mcc_channel_time_quota_cmd =
22490 send_set_mcc_channel_time_quota_cmd_tlv,
22491 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22492 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022493 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022494 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22495 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22496 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022497 .send_probe_rsp_tmpl_send_cmd =
22498 send_probe_rsp_tmpl_send_cmd_tlv,
22499 .send_p2p_go_set_beacon_ie_cmd =
22500 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022501 .send_setup_install_key_cmd =
22502 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022503 .send_set_gateway_params_cmd =
22504 send_set_gateway_params_cmd_tlv,
22505 .send_set_rssi_monitoring_cmd =
22506 send_set_rssi_monitoring_cmd_tlv,
22507 .send_scan_probe_setoui_cmd =
22508 send_scan_probe_setoui_cmd_tlv,
22509 .send_reset_passpoint_network_list_cmd =
22510 send_reset_passpoint_network_list_cmd_tlv,
22511 .send_set_passpoint_network_list_cmd =
22512 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022513 .send_roam_scan_offload_rssi_thresh_cmd =
22514 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022515 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022516 .send_roam_scan_filter_cmd =
22517 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022518 .send_set_epno_network_list_cmd =
22519 send_set_epno_network_list_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022520#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022521 .send_ipa_offload_control_cmd =
22522 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022523#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022524 .send_extscan_get_capabilities_cmd =
22525 send_extscan_get_capabilities_cmd_tlv,
22526 .send_extscan_get_cached_results_cmd =
22527 send_extscan_get_cached_results_cmd_tlv,
22528 .send_extscan_stop_change_monitor_cmd =
22529 send_extscan_stop_change_monitor_cmd_tlv,
22530 .send_extscan_start_change_monitor_cmd =
22531 send_extscan_start_change_monitor_cmd_tlv,
22532 .send_extscan_stop_hotlist_monitor_cmd =
22533 send_extscan_stop_hotlist_monitor_cmd_tlv,
22534 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22535 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22536 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22537 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22538 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22539 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022540 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022541 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22542 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22543 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22544 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022545 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022546 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22547 .send_snr_cmd = send_snr_cmd_tlv,
22548 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022549#ifdef WLAN_PMO_ENABLE
22550 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22551 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22552 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22553 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022554 .send_multiple_add_clear_mcbc_filter_cmd =
22555 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022556 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022557 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22558 .send_process_gtk_offload_getinfo_cmd =
22559 send_process_gtk_offload_getinfo_cmd_tlv,
22560 .send_enable_enhance_multicast_offload_cmd =
22561 send_enable_enhance_multicast_offload_tlv,
22562 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22563#ifdef FEATURE_WLAN_RA_FILTERING
22564 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22565#endif
22566 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022567 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22568 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022569 .send_lphb_config_tcp_pkt_filter_cmd =
22570 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022571 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22572 .send_lphb_config_udp_pkt_filter_cmd =
22573 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022574 .send_enable_disable_packet_filter_cmd =
22575 send_enable_disable_packet_filter_cmd_tlv,
22576 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022577#endif /* End of WLAN_PMO_ENABLE */
22578#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022579 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22580 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022581 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022582 .send_roam_scan_offload_mode_cmd =
22583 send_roam_scan_offload_mode_cmd_tlv,
22584 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22585 .send_roam_scan_offload_ap_profile_cmd =
22586 send_roam_scan_offload_ap_profile_cmd_tlv,
22587#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022588#ifdef WLAN_SUPPORT_GREEN_AP
22589 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22590 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022591 .extract_green_ap_egap_status_info =
22592 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022593#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022594 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22595 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022596 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022597 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022598 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022599#ifdef WLAN_FEATURE_CIF_CFR
22600 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22601#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022602 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022603 .send_dfs_phyerr_filter_offload_en_cmd =
22604 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022605 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22606 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22607 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22608 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22609 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022610 .send_process_add_periodic_tx_ptrn_cmd =
22611 send_process_add_periodic_tx_ptrn_cmd_tlv,
22612 .send_process_del_periodic_tx_ptrn_cmd =
22613 send_process_del_periodic_tx_ptrn_cmd_tlv,
22614 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22615 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22616 .send_set_app_type2_params_in_fw_cmd =
22617 send_set_app_type2_params_in_fw_cmd_tlv,
22618 .send_set_auto_shutdown_timer_cmd =
22619 send_set_auto_shutdown_timer_cmd_tlv,
22620 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22621 .send_process_dhcpserver_offload_cmd =
22622 send_process_dhcpserver_offload_cmd_tlv,
22623 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22624 .send_process_ch_avoid_update_cmd =
22625 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022626 .send_pdev_set_regdomain_cmd =
22627 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022628 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22629 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22630 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22631 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022632 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022633 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022634 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022635 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022636 .send_set_base_macaddr_indicate_cmd =
22637 send_set_base_macaddr_indicate_cmd_tlv,
22638 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22639 .send_enable_specific_fw_logs_cmd =
22640 send_enable_specific_fw_logs_cmd_tlv,
22641 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022642 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022643 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022644#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022645 .send_pdev_set_dual_mac_config_cmd =
22646 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022647#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022648 .send_app_type1_params_in_fw_cmd =
22649 send_app_type1_params_in_fw_cmd_tlv,
22650 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22651 .send_process_roam_synch_complete_cmd =
22652 send_process_roam_synch_complete_cmd_tlv,
22653 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22654 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22655 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022656 .send_roam_scan_offload_scan_period_cmd =
22657 send_roam_scan_offload_scan_period_cmd_tlv,
22658 .send_roam_scan_offload_chan_list_cmd =
22659 send_roam_scan_offload_chan_list_cmd_tlv,
22660 .send_roam_scan_offload_rssi_change_cmd =
22661 send_roam_scan_offload_rssi_change_cmd_tlv,
22662 .send_get_buf_extscan_hotlist_cmd =
22663 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022664 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022665 .send_adapt_dwelltime_params_cmd =
22666 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022667 .send_dbs_scan_sel_params_cmd =
22668 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022669 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022670 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22671 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22672 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22673 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22674 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22675 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022676 .send_vdev_set_custom_aggr_size_cmd =
22677 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022678 .send_vdev_set_qdepth_thresh_cmd =
22679 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022680 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22681 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22682 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022683 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22684 .send_smart_ant_set_training_info_cmd =
22685 send_smart_ant_set_training_info_cmd_tlv,
22686 .send_smart_ant_set_node_config_cmd =
22687 send_smart_ant_set_node_config_cmd_tlv,
22688 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22689 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22690 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022691 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22692 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22693 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22694 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022695 .send_periodic_chan_stats_config_cmd =
22696 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022697 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22698 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22699 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022700 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22701 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22702 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22703 .send_vdev_spectral_configure_cmd =
22704 send_vdev_spectral_configure_cmd_tlv,
22705 .send_vdev_spectral_enable_cmd =
22706 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022707 .send_thermal_mitigation_param_cmd =
22708 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022709 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22710 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022711 .send_process_update_edca_param_cmd =
22712 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022713 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022714 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022715 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022716 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22717 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022718 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022719 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22720 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22721 .extract_host_mem_req = extract_host_mem_req_tlv,
22722 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022723 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022724 .is_service_enabled = is_service_enabled_tlv,
22725 .save_fw_version = save_fw_version_in_service_ready_tlv,
22726 .ready_extract_init_status = ready_extract_init_status_tlv,
22727 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022728 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022729 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022730 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22731 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022732 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022733 .extract_tbttoffset_update_params =
22734 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022735 .extract_ext_tbttoffset_update_params =
22736 extract_ext_tbttoffset_update_params_tlv,
22737 .extract_tbttoffset_num_vdevs =
22738 extract_tbttoffset_num_vdevs_tlv,
22739 .extract_ext_tbttoffset_num_vdevs =
22740 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022741 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22742 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22743 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22744 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022745#ifdef CONVERGED_TDLS_ENABLE
22746 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22747#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022748 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022749 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022750 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22751 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022752#ifdef CONVERGED_P2P_ENABLE
22753 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22754 .extract_p2p_lo_stop_ev_param =
22755 extract_p2p_lo_stop_ev_param_tlv,
22756#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022757 .extract_offchan_data_tx_compl_param =
22758 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022759 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22760 .extract_all_stats_count = extract_all_stats_counts_tlv,
22761 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022762 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022763 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22764 .extract_vdev_stats = extract_vdev_stats_tlv,
22765 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022766 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022767 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22768 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22769 .extract_chan_stats = extract_chan_stats_tlv,
22770 .extract_profile_ctx = extract_profile_ctx_tlv,
22771 .extract_profile_data = extract_profile_data_tlv,
22772 .extract_chan_info_event = extract_chan_info_event_tlv,
22773 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022774 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022775#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022776 .send_encrypt_decrypt_send_cmd =
22777 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022778 .extract_encrypt_decrypt_resp_event =
22779 extract_encrypt_decrypt_resp_event_tlv,
22780#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022781 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022782 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22783 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022784 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022785 .send_multiple_vdev_restart_req_cmd =
22786 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022787 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22788 .extract_hw_mode_cap_service_ready_ext =
22789 extract_hw_mode_cap_service_ready_ext_tlv,
22790 .extract_mac_phy_cap_service_ready_ext =
22791 extract_mac_phy_cap_service_ready_ext_tlv,
22792 .extract_reg_cap_service_ready_ext =
22793 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022794 .extract_dbr_ring_cap_service_ready_ext =
22795 extract_dbr_ring_cap_service_ready_ext_tlv,
22796 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22797 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022798 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022799 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022800 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022801 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22802 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22803 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022804 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022805 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022806 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022807 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022808 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022809 .extract_pdev_csa_switch_count_status =
22810 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022811 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022812 .extract_pdev_tpc_config_ev_param =
22813 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022814 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022815 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22816 .extract_peer_sta_ps_statechange_ev =
22817 extract_peer_sta_ps_statechange_ev_tlv,
22818 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022819 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022820 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22821 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022822 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022823 extract_reg_chan_list_update_event_tlv,
22824 .extract_chainmask_tables =
22825 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022826 .extract_thermal_stats = extract_thermal_stats_tlv,
22827 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022828 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22829 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022830#ifdef DFS_COMPONENT_ENABLE
22831 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22832 .extract_dfs_radar_detection_event =
22833 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022834 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022835#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022836 .convert_pdev_id_host_to_target =
22837 convert_host_pdev_id_to_target_pdev_id_legacy,
22838 .convert_pdev_id_target_to_host =
22839 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022840
22841 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22842 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22843 .extract_reg_11d_new_country_event =
22844 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022845 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022846 .send_limit_off_chan_cmd =
22847 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022848 .extract_reg_ch_avoid_event =
22849 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022850 .send_pdev_caldata_version_check_cmd =
22851 send_pdev_caldata_version_check_cmd_tlv,
22852 .extract_pdev_caldata_version_check_ev_param =
22853 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022854 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22855 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022856 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22857#if defined(WLAN_FEATURE_FILS_SK)
22858 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22859#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022860 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022861#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22862 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22863 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22864 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22865 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22866 .extract_ndp_ind = extract_ndp_ind_tlv,
22867 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22868 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22869 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22870 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
22871#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022872 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022873 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022874 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022875#ifdef WLAN_SUPPORT_FILS
22876 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22877 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22878 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22879#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022880 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22881 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022882 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22883 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22884 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22885 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022886 .send_bss_color_change_enable_cmd =
22887 send_bss_color_change_enable_cmd_tlv,
22888 .send_obss_color_collision_cfg_cmd =
22889 send_obss_color_collision_cfg_cmd_tlv,
22890 .extract_obss_color_collision_info =
22891 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022892 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22893 .extract_single_phyerr = extract_single_phyerr_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022894};
22895
Govind Singhe7f2f342016-05-23 12:12:52 +053022896/**
22897 * populate_tlv_event_id() - populates wmi event ids
22898 *
22899 * @param event_ids: Pointer to hold event ids
22900 * Return: None
22901 */
22902static void populate_tlv_events_id(uint32_t *event_ids)
22903{
22904 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22905 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22906 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22907 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22908 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22909 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22910 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22911 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22912 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22913 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22914 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22915 event_ids[wmi_service_ready_ext_event_id] =
22916 WMI_SERVICE_READY_EXT_EVENTID;
22917 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22918 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22919 event_ids[wmi_vdev_install_key_complete_event_id] =
22920 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22921 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22922 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22923
22924 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22925 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22926 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22927 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22928 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22929 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22930 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22931 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022932 event_ids[wmi_peer_delete_response_event_id] =
22933 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022934 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22935 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22936 event_ids[wmi_tbttoffset_update_event_id] =
22937 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022938 event_ids[wmi_ext_tbttoffset_update_event_id] =
22939 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022940 event_ids[wmi_offload_bcn_tx_status_event_id] =
22941 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22942 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22943 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22944 event_ids[wmi_mgmt_tx_completion_event_id] =
22945 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022946 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22947 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022948 event_ids[wmi_tx_delba_complete_event_id] =
22949 WMI_TX_DELBA_COMPLETE_EVENTID;
22950 event_ids[wmi_tx_addba_complete_event_id] =
22951 WMI_TX_ADDBA_COMPLETE_EVENTID;
22952 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22953
22954 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22955
22956 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22957 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22958
22959 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022960 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022961
22962 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22963
22964 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022965 event_ids[wmi_p2p_lo_stop_event_id] =
22966 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022967 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22968 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022969 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022970 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22971 event_ids[wmi_wow_initial_wakeup_event_id] =
22972 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22973
22974 event_ids[wmi_rtt_meas_report_event_id] =
22975 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22976 event_ids[wmi_tsf_meas_report_event_id] =
22977 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22978 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22979 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22980 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22981 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22982 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022983 event_ids[wmi_diag_event_id_log_supported_event_id] =
22984 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22985 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22986 event_ids[wmi_nlo_scan_complete_event_id] =
22987 WMI_NLO_SCAN_COMPLETE_EVENTID;
22988 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22989 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22990
22991 event_ids[wmi_gtk_offload_status_event_id] =
22992 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22993 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22994 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22995 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22996
22997 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22998
22999 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
23000
23001 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
23002 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
23003 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
23004 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
23005 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
23006 event_ids[wmi_wlan_profile_data_event_id] =
23007 WMI_WLAN_PROFILE_DATA_EVENTID;
23008 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
23009 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
23010 event_ids[wmi_vdev_get_keepalive_event_id] =
23011 WMI_VDEV_GET_KEEPALIVE_EVENTID;
23012 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
23013
23014 event_ids[wmi_diag_container_event_id] =
23015 WMI_DIAG_DATA_CONTAINER_EVENTID;
23016
23017 event_ids[wmi_host_auto_shutdown_event_id] =
23018 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
23019
23020 event_ids[wmi_update_whal_mib_stats_event_id] =
23021 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
23022
23023 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
23024 event_ids[wmi_update_vdev_rate_stats_event_id] =
23025 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
23026
23027 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070023028 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023029
23030 /** Set OCB Sched Response, deprecated */
23031 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
23032
23033 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
23034 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
23035 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
23036
23037 /* GPIO Event */
23038 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
23039 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
23040
23041 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
23042 event_ids[wmi_rfkill_state_change_event_id] =
23043 WMI_RFKILL_STATE_CHANGE_EVENTID;
23044
23045 /* TDLS Event */
23046 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
23047
23048 event_ids[wmi_batch_scan_enabled_event_id] =
23049 WMI_BATCH_SCAN_ENABLED_EVENTID;
23050 event_ids[wmi_batch_scan_result_event_id] =
23051 WMI_BATCH_SCAN_RESULT_EVENTID;
23052 /* OEM Event */
23053 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
23054 event_ids[wmi_oem_meas_report_event_id] =
23055 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
23056 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
23057
23058 /* NAN Event */
23059 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23060
23061 /* LPI Event */
23062 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23063 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23064 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23065
23066 /* ExtScan events */
23067 event_ids[wmi_extscan_start_stop_event_id] =
23068 WMI_EXTSCAN_START_STOP_EVENTID;
23069 event_ids[wmi_extscan_operation_event_id] =
23070 WMI_EXTSCAN_OPERATION_EVENTID;
23071 event_ids[wmi_extscan_table_usage_event_id] =
23072 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23073 event_ids[wmi_extscan_cached_results_event_id] =
23074 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23075 event_ids[wmi_extscan_wlan_change_results_event_id] =
23076 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23077 event_ids[wmi_extscan_hotlist_match_event_id] =
23078 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23079 event_ids[wmi_extscan_capabilities_event_id] =
23080 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23081 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23082 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23083
23084 /* mDNS offload events */
23085 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23086
23087 /* SAP Authentication offload events */
23088 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23089 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23090
23091 /** Out-of-context-of-bss (OCB) events */
23092 event_ids[wmi_ocb_set_config_resp_event_id] =
23093 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23094 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23095 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23096 event_ids[wmi_dcc_get_stats_resp_event_id] =
23097 WMI_DCC_GET_STATS_RESP_EVENTID;
23098 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23099 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23100 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23101 /* System-On-Chip events */
23102 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23103 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23104 event_ids[wmi_soc_hw_mode_transition_event_id] =
23105 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23106 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23107 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023108 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023109 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23110 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023111 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023112 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23113 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23114 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23115 WMI_PEER_STA_PS_STATECHG_EVENTID;
23116 event_ids[wmi_pdev_channel_hopping_event_id] =
23117 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023118 event_ids[wmi_offchan_data_tx_completion_event] =
23119 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023120 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23121 event_ids[wmi_dfs_radar_detection_event_id] =
23122 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023123 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023124 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023125 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023126 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023127 event_ids[wmi_service_available_event_id] =
23128 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023129 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023130 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023131 /* NDP events */
23132 event_ids[wmi_ndp_initiator_rsp_event_id] =
23133 WMI_NDP_INITIATOR_RSP_EVENTID;
23134 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23135 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23136 event_ids[wmi_ndp_responder_rsp_event_id] =
23137 WMI_NDP_RESPONDER_RSP_EVENTID;
23138 event_ids[wmi_ndp_end_indication_event_id] =
23139 WMI_NDP_END_INDICATION_EVENTID;
23140 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
23141
23142 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23143 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23144 event_ids[wmi_pdev_chip_power_stats_event_id] =
23145 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23146 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23147 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23148 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
23149 event_ids[wmi_bpf_capability_info_event_id] =
23150 WMI_BPF_CAPABILIY_INFO_EVENTID;
23151 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23152 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23153 event_ids[wmi_report_rx_aggr_failure_event_id] =
23154 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23155 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23156 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23157 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23158 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23159 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23160 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23161 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23162 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23163 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23164 event_ids[wmi_coex_bt_activity_event_id] =
23165 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23166 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23167 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23168 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23169 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23170 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023171 event_ids[wmi_dma_buf_release_event_id] =
23172 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023173 event_ids[wmi_sap_obss_detection_report_event_id] =
23174 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023175 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023176 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023177 event_ids[wmi_obss_color_collision_report_event_id] =
23178 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080023179 event_ids[wmi_pdev_div_rssi_antid_event_id] =
23180 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023181}
23182
Soumya Bhat488092d2017-03-22 14:41:01 +053023183/**
23184 * populate_tlv_service() - populates wmi services
23185 *
23186 * @param wmi_service: Pointer to hold wmi_service
23187 * Return: None
23188 */
23189static void populate_tlv_service(uint32_t *wmi_service)
23190{
23191 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023192 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023193 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23194 wmi_service[wmi_service_roam_scan_offload] =
23195 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23196 wmi_service[wmi_service_bcn_miss_offload] =
23197 WMI_SERVICE_BCN_MISS_OFFLOAD;
23198 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23199 wmi_service[wmi_service_sta_advanced_pwrsave] =
23200 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23201 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23202 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23203 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23204 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23205 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23206 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23207 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23208 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23209 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23210 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23211 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23212 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23213 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23214 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23215 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23216 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23217 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23218 wmi_service[wmi_service_packet_power_save] =
23219 WMI_SERVICE_PACKET_POWER_SAVE;
23220 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23221 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23222 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23223 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23224 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23225 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23226 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23227 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23228 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23229 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23230 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23231 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23232 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23233 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23234 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23235 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23236 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23237 wmi_service[wmi_service_mcc_bcn_interval_change] =
23238 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23239 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23240 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23241 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23242 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23243 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23244 wmi_service[wmi_service_lte_ant_share_support] =
23245 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23246 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23247 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23248 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23249 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23250 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23251 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23252 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23253 wmi_service[wmi_service_bcn_txrate_override] =
23254 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23255 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23256 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23257 wmi_service[wmi_service_estimate_linkspeed] =
23258 WMI_SERVICE_ESTIMATE_LINKSPEED;
23259 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23260 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23261 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23262 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23263 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23264 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23265 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23266 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23267 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23268 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23269 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23270 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23271 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23272 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23273 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23274 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23275 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23276 wmi_service[wmi_service_sap_auth_offload] =
23277 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23278 wmi_service[wmi_service_dual_band_simultaneous_support] =
23279 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23280 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23281 wmi_service[wmi_service_ap_arpns_offload] =
23282 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23283 wmi_service[wmi_service_per_band_chainmask_support] =
23284 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23285 wmi_service[wmi_service_packet_filter_offload] =
23286 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23287 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23288 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23289 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23290 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23291 wmi_service[wmi_service_multiple_vdev_restart] =
23292 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23293
23294 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23295 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23296 wmi_service[wmi_service_smart_antenna_sw_support] =
23297 WMI_SERVICE_UNAVAILABLE;
23298 wmi_service[wmi_service_smart_antenna_hw_support] =
23299 WMI_SERVICE_UNAVAILABLE;
23300 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023301 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023302 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023303 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23304 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23305 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23306 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23307 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23308 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23309 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23310 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023311 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23312 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23313 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023314 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023315 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23316 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23317 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23318 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23319 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23320 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023321 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23322 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23323 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23324 wmi_service[wmi_service_unified_wow_capability] =
23325 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23326 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23327 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23328 wmi_service[wmi_service_sync_delete_cmds] =
23329 WMI_SERVICE_SYNC_DELETE_CMDS;
23330 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23331 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23332 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23333 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23334 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23335 wmi_service[wmi_service_deprecated_replace] =
23336 WMI_SERVICE_DEPRECATED_REPLACE;
23337 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23338 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23339 wmi_service[wmi_service_enhanced_mcast_filter] =
23340 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23341 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23342 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23343 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23344 wmi_service[wmi_service_p2p_listen_offload_support] =
23345 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23346 wmi_service[wmi_service_mark_first_wakeup_packet] =
23347 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23348 wmi_service[wmi_service_multiple_mcast_filter_set] =
23349 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23350 wmi_service[wmi_service_host_managed_rx_reorder] =
23351 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23352 wmi_service[wmi_service_flash_rdwr_support] =
23353 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23354 wmi_service[wmi_service_wlan_stats_report] =
23355 WMI_SERVICE_WLAN_STATS_REPORT;
23356 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23357 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23358 wmi_service[wmi_service_dfs_phyerr_offload] =
23359 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23360 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23361 wmi_service[wmi_service_fw_mem_dump_support] =
23362 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23363 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23364 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23365 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23366 wmi_service[wmi_service_hw_data_filtering] =
23367 WMI_SERVICE_HW_DATA_FILTERING;
23368 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23369 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023370 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023371 wmi_service[wmi_service_extended_nss_support] =
23372 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023373 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023374 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23375 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023376 wmi_service[wmi_service_offchan_data_tid_support] =
23377 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023378 wmi_service[wmi_service_support_dma] =
23379 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023380 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23381 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23382 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023383 wmi_service[wmi_service_11k_neighbour_report_support] =
23384 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023385 wmi_service[wmi_service_ap_obss_detection_offload] =
23386 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23387 wmi_service[wmi_service_bss_color_offload] =
23388 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023389 wmi_service[wmi_service_gmac_offload_support] =
23390 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023391
Soumya Bhat488092d2017-03-22 14:41:01 +053023392}
23393
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023394#ifndef CONFIG_MCL
23395
Govind Singhe7f2f342016-05-23 12:12:52 +053023396/**
23397 * populate_pdev_param_tlv() - populates pdev params
23398 *
23399 * @param pdev_param: Pointer to hold pdev params
23400 * Return: None
23401 */
23402static void populate_pdev_param_tlv(uint32_t *pdev_param)
23403{
23404 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23405 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23406 pdev_param[wmi_pdev_param_txpower_limit2g] =
23407 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23408 pdev_param[wmi_pdev_param_txpower_limit5g] =
23409 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23410 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23411 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23412 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23413 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23414 WMI_PDEV_PARAM_BEACON_TX_MODE;
23415 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23416 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23417 pdev_param[wmi_pdev_param_protection_mode] =
23418 WMI_PDEV_PARAM_PROTECTION_MODE;
23419 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23420 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23421 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23422 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23423 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23424 pdev_param[wmi_pdev_param_sta_kickout_th] =
23425 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23426 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23427 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23428 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23429 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23430 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23431 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23432 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23433 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23434 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23435 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23436 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23437 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23438 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23439 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23440 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23441 pdev_param[wmi_pdev_param_ltr_rx_override] =
23442 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23443 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23444 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23445 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23446 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23447 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23448 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23449 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23450 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23451 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23452 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23453 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23454 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23455 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23456 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23457 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23458 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23459 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23460 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23461 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23462 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23463 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23464 pdev_param[wmi_pdev_param_arp_ac_override] =
23465 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23466 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23467 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23468 pdev_param[wmi_pdev_param_ani_poll_period] =
23469 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23470 pdev_param[wmi_pdev_param_ani_listen_period] =
23471 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23472 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23473 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23474 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23475 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23476 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23477 pdev_param[wmi_pdev_param_idle_ps_config] =
23478 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23479 pdev_param[wmi_pdev_param_power_gating_sleep] =
23480 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23481 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23482 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23483 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23484 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23485 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23486 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23487 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23488 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23489 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23490 pdev_param[wmi_pdev_param_power_collapse_enable] =
23491 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23492 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23493 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23494 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23495 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23496 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23497 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23498 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23499 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23500 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23501 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23502 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23503 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23504 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23505 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23506 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23507 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23508 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23509 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23510 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23511 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23512 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23513 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23514 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23515 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23516 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23517 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23518 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23519 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23520 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23521 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23522 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23523 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23524 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23525 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23526 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23527 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23528 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23529 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23530 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23531 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23532 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23533 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23534 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23535 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023536 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23537 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23538 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023539 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23540 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023541 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023542 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023543 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23544 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23545 WMI_PDEV_PARAM_PROXY_STA_MODE;
23546 pdev_param[wmi_pdev_param_mu_group_policy] =
23547 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23548 pdev_param[wmi_pdev_param_noise_detection] =
23549 WMI_PDEV_PARAM_NOISE_DETECTION;
23550 pdev_param[wmi_pdev_param_noise_threshold] =
23551 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23552 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23553 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23554 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023555 pdev_param[wmi_pdev_param_atf_strict_sch] =
23556 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23557 pdev_param[wmi_pdev_param_atf_sched_duration] =
23558 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023559 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23560 pdev_param[wmi_pdev_param_sensitivity_level] =
23561 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23562 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23563 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23564 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23565 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023566 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23567 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23568 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23569 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023570 pdev_param[wmi_pdev_param_cca_threshold] =
23571 WMI_PDEV_PARAM_CCA_THRESHOLD;
23572 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23573 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023574 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023575 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23576 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23577 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23578 pdev_param[wmi_pdev_param_arp_srcaddr] =
23579 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23580 pdev_param[wmi_pdev_param_arp_dstaddr] =
23581 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23582 pdev_param[wmi_pdev_param_txpower_decr_db] =
23583 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023584 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23585 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023586 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23587 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023588 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023589 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023590 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23591 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023592 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23593 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023594 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23595 WMI_UNAVAILABLE_PARAM;
23596 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23597 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023598 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23599 pdev_param[wmi_pdev_param_block_interbss] =
23600 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023601 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023602 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23603 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23604 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023605 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023606 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023607 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23608 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023609 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023610 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23611 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023612 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23613 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23614 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23615 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23616 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23617 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23618 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23619 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23620 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23621 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23622 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23623 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23624 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23625 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23626 pdev_param[wmi_pdev_param_fast_channel_reset] =
23627 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23628 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023629 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023630 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023631}
23632
23633/**
23634 * populate_vdev_param_tlv() - populates vdev params
23635 *
23636 * @param vdev_param: Pointer to hold vdev params
23637 * Return: None
23638 */
23639static void populate_vdev_param_tlv(uint32_t *vdev_param)
23640{
23641 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23642 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23643 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23644 vdev_param[wmi_vdev_param_beacon_interval] =
23645 WMI_VDEV_PARAM_BEACON_INTERVAL;
23646 vdev_param[wmi_vdev_param_listen_interval] =
23647 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23648 vdev_param[wmi_vdev_param_multicast_rate] =
23649 WMI_VDEV_PARAM_MULTICAST_RATE;
23650 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23651 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23652 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23653 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23654 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23655 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23656 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23657 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23658 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23659 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23660 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23661 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23662 vdev_param[wmi_vdev_param_bmiss_count_max] =
23663 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23664 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23665 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23666 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23667 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23668 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23669 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23670 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23671 vdev_param[wmi_vdev_param_disable_htprotection] =
23672 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23673 vdev_param[wmi_vdev_param_sta_quickkickout] =
23674 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23675 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23676 vdev_param[wmi_vdev_param_protection_mode] =
23677 WMI_VDEV_PARAM_PROTECTION_MODE;
23678 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23679 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23680 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23681 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23682 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23683 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23684 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23685 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23686 vdev_param[wmi_vdev_param_bcast_data_rate] =
23687 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23688 vdev_param[wmi_vdev_param_mcast_data_rate] =
23689 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23690 vdev_param[wmi_vdev_param_mcast_indicate] =
23691 WMI_VDEV_PARAM_MCAST_INDICATE;
23692 vdev_param[wmi_vdev_param_dhcp_indicate] =
23693 WMI_VDEV_PARAM_DHCP_INDICATE;
23694 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23695 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23696 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23697 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23698 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23699 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23700 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23701 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23702 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23703 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23704 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23705 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23706 vdev_param[wmi_vdev_param_packet_powersave] =
23707 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23708 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23709 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23710 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23711 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23712 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23713 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23714 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23715 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23716 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23717 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23718 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23719 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23720 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23721 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23722 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23723 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23724 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23725 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23726 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23727 vdev_param[wmi_vdev_param_roam_fw_offload] =
23728 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23729 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23730 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23731 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23732 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23733 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23734 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23735 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23736 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23737 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23738 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23739 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23740 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23741 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23742 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23743 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23744 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23745 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23746 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23747 vdev_param[wmi_vdev_param_inactivity_cnt] =
23748 WMI_VDEV_PARAM_INACTIVITY_CNT;
23749 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23750 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23751 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23752 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23753 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23754 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23755 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23756 vdev_param[wmi_vdev_param_rx_leak_window] =
23757 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23758 vdev_param[wmi_vdev_param_stats_avg_factor] =
23759 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23760 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23761 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23762 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23763 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23764 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23765 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023766 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23767 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023768 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023769 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23770 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23771 WMI_VDEV_PARAM_HE_RANGE_EXT;
23772 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23773 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023774 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023775 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23776 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23777 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23778 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23779 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23780 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23781 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023782 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23783 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23784 vdev_param[wmi_vdev_param_rc_num_retries] =
23785 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23786 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23787 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23788 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23789 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23790 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23791 vdev_param[wmi_vdev_param_vht80_ratemask] =
23792 WMI_VDEV_PARAM_VHT80_RATEMASK;
23793 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23794 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23795 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023796 vdev_param[wmi_vdev_param_set_he_ltf] =
23797 WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023798 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23799 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023800 vdev_param[wmi_vdev_param_set_ba_mode] =
23801 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023802 vdev_param[wmi_vdev_param_capabilities] =
23803 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023804 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23805 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023806}
23807#endif
23808
Govind Singh5eb51532016-03-09 11:34:12 +053023809/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023810 * populate_target_defines_tlv() - Populate target defines and params
23811 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023812 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023813 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023814 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023815#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023816static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023817{
Govind Singhe7f2f342016-05-23 12:12:52 +053023818 populate_pdev_param_tlv(wmi_handle->pdev_param);
23819 populate_vdev_param_tlv(wmi_handle->vdev_param);
23820}
23821#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023822static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23823{ }
23824#endif
23825
23826/**
Zhang Qian537fca62018-01-03 16:33:24 +080023827 * wmi_ocb_ut_attach() - Attach OCB test framework
23828 * @wmi_handle: wmi handle
23829 *
23830 * Return: None
23831 */
23832#ifdef WLAN_OCB_UT
23833void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23834#else
23835static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23836{
23837 return;
23838}
23839#endif
23840
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023841#ifdef WLAN_SUPPORT_TWT
23842void wmi_twt_attach_tlv(struct wmi_unified *wmi_handle);
23843#else
23844static void wmi_twt_attach_tlv(struct wmi_unified *wmi_handle)
23845{
23846 return;
23847}
23848#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023849/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023850 * wmi_tlv_attach() - Attach TLV APIs
23851 *
23852 * Return: None
23853 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023854void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023855{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023856 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023857 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023858 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023859#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023860 /* Skip saving WMI_CMD_HDR and TLV HDR */
23861 wmi_handle->log_info.buf_offset_command = 8;
23862 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023863 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023864#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023865 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023866 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023867 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023868 wmi_twt_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023869}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023870qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023871
23872/**
23873 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23874 *
23875 * Return: None
23876 */
23877void wmi_tlv_init(void)
23878{
23879 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23880}