blob: dcc2651db47bc0c3bcbcb1f87c0c8d5c39cf0ba7 [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"
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053033#include <wlan_defs.h>
34
Wu Gaocd3a8512017-03-13 20:17:34 +080035#ifdef CONVERGED_P2P_ENABLE
36#include "wlan_p2p_public_struct.h"
37#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070038#ifdef WLAN_PMO_ENABLE
39#include "wlan_pmo_hw_filter_public_struct.h"
40#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053041#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053042#ifdef WLAN_SUPPORT_GREEN_AP
43#include "wlan_green_ap_api.h"
44#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053045
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080046#ifdef WLAN_FEATURE_NAN_CONVERGENCE
47#include "nan_public_structs.h"
48#endif
49
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053050/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
51 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053052 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053053 * @cmd: pointer target vdev create command buffer
54 * @param: pointer host params for vdev create
55 *
56 * Return: None
57 */
58#ifdef CONFIG_MCL
59static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053060 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053061 wmi_vdev_create_cmd_fixed_param * cmd,
62 struct vdev_create_params *param)
63{
64 cmd->pdev_id = WMI_PDEV_ID_SOC;
65}
66#else
67static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053068 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053069 wmi_vdev_create_cmd_fixed_param * cmd,
70 struct vdev_create_params *param)
71{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053072 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
73 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053074}
75#endif
76
Govind Singh5eb51532016-03-09 11:34:12 +053077/**
78 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
79 * @wmi_handle: wmi handle
80 * @param: pointer to hold vdev create parameter
81 * @macaddr: vdev mac address
82 *
Govind Singhe7f2f342016-05-23 12:12:52 +053083 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053084 */
Sathish Kumarfd347372017-02-13 12:29:09 +053085static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053086 uint8_t macaddr[IEEE80211_ADDR_LEN],
87 struct vdev_create_params *param)
88{
89 wmi_vdev_create_cmd_fixed_param *cmd;
90 wmi_buf_t buf;
91 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053092 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070093 int num_bands = 2;
94 uint8_t *buf_ptr;
95 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053096
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070097 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053098 buf = wmi_buf_alloc(wmi_handle, len);
99 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530100 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530101 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530102 }
103 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
104 WMITLV_SET_HDR(&cmd->tlv_header,
105 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
106 WMITLV_GET_STRUCT_TLVLEN
107 (wmi_vdev_create_cmd_fixed_param));
108 cmd->vdev_id = param->if_id;
109 cmd->vdev_type = param->type;
110 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700111 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530112 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530113 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700114 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
115 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530116 macaddr[0], macaddr[1], macaddr[2],
117 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700118 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
120 (num_bands * sizeof(wmi_vdev_txrx_streams)));
121 buf_ptr += WMI_TLV_HDR_SIZE;
122
Govind Singh224a7312016-06-21 14:33:26 +0530123 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700124 param->type, param->subtype,
125 param->nss_2g, param->nss_5g);
126 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
127 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
128 txrx_streams->supported_tx_streams = param->nss_2g;
129 txrx_streams->supported_rx_streams = param->nss_2g;
130 WMITLV_SET_HDR(&txrx_streams->tlv_header,
131 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
132 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
133
134 txrx_streams++;
135 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
136 txrx_streams->supported_tx_streams = param->nss_5g;
137 txrx_streams->supported_rx_streams = param->nss_5g;
138 WMITLV_SET_HDR(&txrx_streams->tlv_header,
139 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
140 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530141 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530142 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530143 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530144 wmi_buf_free(buf);
145 }
146
147 return ret;
148}
149
150/**
151 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
152 * @wmi_handle: wmi handle
153 * @if_id: vdev id
154 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530155 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530156 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530157static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530158 uint8_t if_id)
159{
160 wmi_vdev_delete_cmd_fixed_param *cmd;
161 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530162 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530163
164 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530166 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530167 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530168 }
169
170 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
171 WMITLV_SET_HDR(&cmd->tlv_header,
172 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
173 WMITLV_GET_STRUCT_TLVLEN
174 (wmi_vdev_delete_cmd_fixed_param));
175 cmd->vdev_id = if_id;
176 ret = wmi_unified_cmd_send(wmi_handle, buf,
177 sizeof(wmi_vdev_delete_cmd_fixed_param),
178 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530179 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530180 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530181 wmi_buf_free(buf);
182 }
Govind Singhb53420c2016-03-09 14:32:57 +0530183 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530184
185 return ret;
186}
187
188/**
189 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
190 * @wmi: wmi handle
191 * @vdev_id: vdev id
192 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530193 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530194 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530195static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530196 uint8_t vdev_id)
197{
198 wmi_vdev_stop_cmd_fixed_param *cmd;
199 wmi_buf_t buf;
200 int32_t len = sizeof(*cmd);
201
202 buf = wmi_buf_alloc(wmi, len);
203 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530204 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530205 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530206 }
207 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
208 WMITLV_SET_HDR(&cmd->tlv_header,
209 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
210 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
211 cmd->vdev_id = vdev_id;
212 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530213 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530214 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530215 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530216 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530217 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530218
219 return 0;
220}
221
222/**
223 * send_vdev_down_cmd_tlv() - send vdev down command to fw
224 * @wmi: wmi handle
225 * @vdev_id: vdev id
226 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530227 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530228 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530229static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530230{
231 wmi_vdev_down_cmd_fixed_param *cmd;
232 wmi_buf_t buf;
233 int32_t len = sizeof(*cmd);
234
235 buf = wmi_buf_alloc(wmi, len);
236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530237 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530238 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530239 }
240 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
241 WMITLV_SET_HDR(&cmd->tlv_header,
242 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
243 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
244 cmd->vdev_id = vdev_id;
245 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530246 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530247 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530248 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530249 }
Govind Singhb53420c2016-03-09 14:32:57 +0530250 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530251
252 return 0;
253}
254
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530255#ifdef CONFIG_MCL
256static inline void copy_channel_info(
257 wmi_vdev_start_request_cmd_fixed_param * cmd,
258 wmi_channel *chan,
259 struct vdev_start_params *req)
260{
261 chan->mhz = req->chan_freq;
262
263 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
264
265 chan->band_center_freq1 = req->band_center_freq1;
266 chan->band_center_freq2 = req->band_center_freq2;
267
268 if (req->is_half_rate)
269 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
270 else if (req->is_quarter_rate)
271 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
272
Naveen Rawat44f2f432016-12-01 12:58:57 -0800273 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530274 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
275 cmd->disable_hw_ack = req->dis_hw_ack;
276 }
277
278 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
279 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
280
281}
282#else
283static inline void copy_channel_info(
284 wmi_vdev_start_request_cmd_fixed_param * cmd,
285 wmi_channel *chan,
286 struct vdev_start_params *req)
287{
288 chan->mhz = req->channel.mhz;
289
290 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
291
292 chan->band_center_freq1 = req->channel.cfreq1;
293 chan->band_center_freq2 = req->channel.cfreq2;
294
295 if (req->channel.half_rate)
296 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
297 else if (req->channel.quarter_rate)
298 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
299
300 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530301 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530302 cmd->disable_hw_ack = req->disable_hw_ack;
303 }
304
Krishna Rao0b952ea2017-03-20 13:30:10 +0530305 if (req->channel.dfs_set_cfreq2)
306 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
307
Kai Chen4710d462017-12-15 14:06:06 -0800308 /* According to firmware both reg power and max tx power
309 * on set channel power is used and set it to max reg
310 * power from regulatory.
311 */
312 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
313 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530314 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800315 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
316 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
317 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530318
319}
320#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530321/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530322 * send_vdev_start_cmd_tlv() - send vdev start request to fw
323 * @wmi_handle: wmi handle
324 * @req: vdev start params
325 *
326 * Return: QDF status
327 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530328static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530329 struct vdev_start_params *req)
330{
331 wmi_vdev_start_request_cmd_fixed_param *cmd;
332 wmi_buf_t buf;
333 wmi_channel *chan;
334 int32_t len, ret;
335 uint8_t *buf_ptr;
336
337 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
338 buf = wmi_buf_alloc(wmi_handle, len);
339 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530340 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530341 return QDF_STATUS_E_NOMEM;
342 }
343 buf_ptr = (uint8_t *) wmi_buf_data(buf);
344 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
345 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
346 WMITLV_SET_HDR(&cmd->tlv_header,
347 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
348 WMITLV_GET_STRUCT_TLVLEN
349 (wmi_vdev_start_request_cmd_fixed_param));
350 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
351 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
352 cmd->vdev_id = req->vdev_id;
353
354 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530355 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530356
357 cmd->beacon_interval = req->beacon_intval;
358 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530359
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800360 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
361 if (req->bcn_tx_rate_code)
362 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
363
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530364 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530365 cmd->beacon_interval = req->beacon_intval;
366 cmd->dtim_period = req->dtim_period;
367
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 /* Copy the SSID */
369 if (req->ssid.length) {
370 if (req->ssid.length < sizeof(cmd->ssid.ssid))
371 cmd->ssid.ssid_len = req->ssid.length;
372 else
373 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
374 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
375 cmd->ssid.ssid_len);
376 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530377
378 if (req->hidden_ssid)
379 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
380
381 if (req->pmf_enabled)
382 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530383 }
384
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700385 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530386 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530387 cmd->preferred_rx_streams = req->preferred_rx_streams;
388 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700389 cmd->cac_duration_ms = req->cac_duration_ms;
390 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700391 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392
393 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
394 sizeof(wmi_channel));
395 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
396 cmd->num_noa_descriptors *
397 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800398 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530399 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
400 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700401 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800402 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530403 req->is_dfs, req->beacon_intval, cmd->dtim_period,
404 chan->band_center_freq1, chan->band_center_freq2,
405 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700406 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700407 req->ldpc_rx_enabled, req->cac_duration_ms,
408 req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530409
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530410 if (req->is_restart)
411 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
412 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530413 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
415 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530416 if (ret) {
417 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530418 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530419 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530420 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421
422 return QDF_STATUS_SUCCESS;
423}
424
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530425/**
426 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
427 * @wmi_handle: wmi handle
428 * @restart_params: vdev restart params
429 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530430 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530432static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530433 struct hidden_ssid_vdev_restart_params *restart_params)
434{
435 wmi_vdev_start_request_cmd_fixed_param *cmd;
436 wmi_buf_t buf;
437 wmi_channel *chan;
438 int32_t len;
439 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530440 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530441
442 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
443 buf = wmi_buf_alloc(wmi_handle, len);
444 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530445 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530446 return QDF_STATUS_E_NOMEM;
447 }
448 buf_ptr = (uint8_t *) wmi_buf_data(buf);
449 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
450 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
451
452 WMITLV_SET_HDR(&cmd->tlv_header,
453 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
454 WMITLV_GET_STRUCT_TLVLEN
455 (wmi_vdev_start_request_cmd_fixed_param));
456
457 WMITLV_SET_HDR(&chan->tlv_header,
458 WMITLV_TAG_STRUC_wmi_channel,
459 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
460
461 cmd->vdev_id = restart_params->session_id;
462 cmd->ssid.ssid_len = restart_params->ssid_len;
463 qdf_mem_copy(cmd->ssid.ssid,
464 restart_params->ssid,
465 cmd->ssid.ssid_len);
466 cmd->flags = restart_params->flags;
467 cmd->requestor_id = restart_params->requestor_id;
468 cmd->disable_hw_ack = restart_params->disable_hw_ack;
469
470 chan->mhz = restart_params->mhz;
471 chan->band_center_freq1 =
472 restart_params->band_center_freq1;
473 chan->band_center_freq2 =
474 restart_params->band_center_freq2;
475 chan->info = restart_params->info;
476 chan->reg_info_1 = restart_params->reg_info_1;
477 chan->reg_info_2 = restart_params->reg_info_2;
478
479 cmd->num_noa_descriptors = 0;
480 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
481 sizeof(wmi_channel));
482 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
483 cmd->num_noa_descriptors *
484 sizeof(wmi_p2p_noa_descriptor));
485
486 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
487 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530488 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530489 wmi_buf_free(buf);
490 return QDF_STATUS_E_FAILURE;
491 }
492 return QDF_STATUS_SUCCESS;
493}
494
495
496/**
Govind Singh5eb51532016-03-09 11:34:12 +0530497 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
498 * @wmi: wmi handle
499 * @peer_addr: peer mac address
500 * @param: pointer to hold peer flush tid parameter
501 *
502 * Return: 0 for sucess or error code
503 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530504static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530505 uint8_t peer_addr[IEEE80211_ADDR_LEN],
506 struct peer_flush_params *param)
507{
508 wmi_peer_flush_tids_cmd_fixed_param *cmd;
509 wmi_buf_t buf;
510 int32_t len = sizeof(*cmd);
511
512 buf = wmi_buf_alloc(wmi, len);
513 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530514 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530515 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530516 }
517 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
518 WMITLV_SET_HDR(&cmd->tlv_header,
519 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
520 WMITLV_GET_STRUCT_TLVLEN
521 (wmi_peer_flush_tids_cmd_fixed_param));
522 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
523 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
524 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530525 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530526 peer_addr, param->vdev_id,
527 param->peer_tid_bitmap);
528 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530529 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530530 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530531 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530532 }
533
534 return 0;
535}
536
537/**
538 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
539 * @wmi: wmi handle
540 * @peer_addr: peer mac addr
541 * @vdev_id: vdev id
542 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530543 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530544 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530545static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530546 uint8_t peer_addr[IEEE80211_ADDR_LEN],
547 uint8_t vdev_id)
548{
549 wmi_peer_delete_cmd_fixed_param *cmd;
550 wmi_buf_t buf;
551 int32_t len = sizeof(*cmd);
552 buf = wmi_buf_alloc(wmi, len);
553 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530554 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530555 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530556 }
557 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
558 WMITLV_SET_HDR(&cmd->tlv_header,
559 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
560 WMITLV_GET_STRUCT_TLVLEN
561 (wmi_peer_delete_cmd_fixed_param));
562 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
563 cmd->vdev_id = vdev_id;
564
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800565 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530566 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530567 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530568 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530569 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530570 }
Govind Singh5eb51532016-03-09 11:34:12 +0530571
572 return 0;
573}
574
575/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530576 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
577 * to target id.
578 * @targ_paramid: Target parameter id to hold the result.
579 * @peer_param_id: host param id.
580 *
581 * Return: QDF_STATUS_SUCCESS for success
582 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
583 */
584#ifdef CONFIG_MCL
585static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
586 uint32_t *targ_paramid,
587 uint32_t peer_param_id)
588{
589 *targ_paramid = peer_param_id;
590 return QDF_STATUS_SUCCESS;
591}
592#else
593static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
594 uint32_t *targ_paramid,
595 uint32_t peer_param_id)
596{
597 switch (peer_param_id) {
598 case WMI_HOST_PEER_MIMO_PS_STATE:
599 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
600 break;
601 case WMI_HOST_PEER_AMPDU:
602 *targ_paramid = WMI_PEER_AMPDU;
603 break;
604 case WMI_HOST_PEER_AUTHORIZE:
605 *targ_paramid = WMI_PEER_AUTHORIZE;
606 break;
607 case WMI_HOST_PEER_CHWIDTH:
608 *targ_paramid = WMI_PEER_CHWIDTH;
609 break;
610 case WMI_HOST_PEER_NSS:
611 *targ_paramid = WMI_PEER_NSS;
612 break;
613 case WMI_HOST_PEER_USE_4ADDR:
614 *targ_paramid = WMI_PEER_USE_4ADDR;
615 break;
616 case WMI_HOST_PEER_MEMBERSHIP:
617 *targ_paramid = WMI_PEER_MEMBERSHIP;
618 break;
619 case WMI_HOST_PEER_USERPOS:
620 *targ_paramid = WMI_PEER_USERPOS;
621 break;
622 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
623 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
624 break;
625 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
626 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
627 break;
628 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
629 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
630 break;
631 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
632 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
633 break;
634 case WMI_HOST_PEER_PHYMODE:
635 *targ_paramid = WMI_PEER_PHYMODE;
636 break;
637 case WMI_HOST_PEER_USE_FIXED_PWR:
638 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
639 break;
640 case WMI_HOST_PEER_PARAM_FIXED_RATE:
641 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
642 break;
643 case WMI_HOST_PEER_SET_MU_WHITELIST:
644 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
645 break;
646 case WMI_HOST_PEER_SET_MAC_TX_RATE:
647 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
648 break;
649 case WMI_HOST_PEER_SET_MIN_TX_RATE:
650 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
651 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530652 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
653 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
654 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530655 case WMI_HOST_PEER_NSS_VHT160:
656 *targ_paramid = WMI_PEER_NSS_VHT160;
657 break;
658 case WMI_HOST_PEER_NSS_VHT80_80:
659 *targ_paramid = WMI_PEER_NSS_VHT80_80;
660 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530661 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
662 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
663 break;
664 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
665 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
666 break;
667 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
668 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
669 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530670 default:
671 return QDF_STATUS_E_NOSUPPORT;
672 }
673
674 return QDF_STATUS_SUCCESS;
675}
676#endif
677/**
Govind Singh5eb51532016-03-09 11:34:12 +0530678 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530679 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530680 * @peer_addr: peer mac address
681 * @param : pointer to hold peer set parameter
682 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530683 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530684 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530685static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530686 uint8_t peer_addr[IEEE80211_ADDR_LEN],
687 struct peer_set_params *param)
688{
689 wmi_peer_set_param_cmd_fixed_param *cmd;
690 wmi_buf_t buf;
691 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530692 uint32_t param_id;
693
694 if (convert_host_peer_id_to_target_id_tlv(&param_id,
695 param->param_id) != QDF_STATUS_SUCCESS)
696 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530697
698 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
699 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530700 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530701 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530702 }
703 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
704 WMITLV_SET_HDR(&cmd->tlv_header,
705 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
706 WMITLV_GET_STRUCT_TLVLEN
707 (wmi_peer_set_param_cmd_fixed_param));
708 cmd->vdev_id = param->vdev_id;
709 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530710 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530711 cmd->param_value = param->param_value;
712 err = wmi_unified_cmd_send(wmi, buf,
713 sizeof(wmi_peer_set_param_cmd_fixed_param),
714 WMI_PEER_SET_PARAM_CMDID);
715 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530716 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530717 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530718 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530719 }
720
721 return 0;
722}
723
724/**
725 * send_vdev_up_cmd_tlv() - send vdev up command in fw
726 * @wmi: wmi handle
727 * @bssid: bssid
728 * @vdev_up_params: pointer to hold vdev up parameter
729 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530730 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530731 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530732static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530733 uint8_t bssid[IEEE80211_ADDR_LEN],
734 struct vdev_up_params *params)
735{
736 wmi_vdev_up_cmd_fixed_param *cmd;
737 wmi_buf_t buf;
738 int32_t len = sizeof(*cmd);
739
Govind Singhb53420c2016-03-09 14:32:57 +0530740 WMI_LOGD("%s: VDEV_UP", __func__);
741 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530742 params->vdev_id, params->assoc_id, bssid);
743 buf = wmi_buf_alloc(wmi, len);
744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530745 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530746 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530747 }
748 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
749 WMITLV_SET_HDR(&cmd->tlv_header,
750 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
751 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
752 cmd->vdev_id = params->vdev_id;
753 cmd->vdev_assoc_id = params->assoc_id;
754 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
755 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530756 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530757 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530758 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530759 }
760
761 return 0;
762}
763
764/**
765 * send_peer_create_cmd_tlv() - send peer create command to fw
766 * @wmi: wmi handle
767 * @peer_addr: peer mac address
768 * @peer_type: peer type
769 * @vdev_id: vdev id
770 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530771 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530772 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530773static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530774 struct peer_create_params *param)
775{
776 wmi_peer_create_cmd_fixed_param *cmd;
777 wmi_buf_t buf;
778 int32_t len = sizeof(*cmd);
779
780 buf = wmi_buf_alloc(wmi, len);
781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530782 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530783 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530784 }
785 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
786 WMITLV_SET_HDR(&cmd->tlv_header,
787 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
788 WMITLV_GET_STRUCT_TLVLEN
789 (wmi_peer_create_cmd_fixed_param));
790 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
791 cmd->peer_type = param->peer_type;
792 cmd->vdev_id = param->vdev_id;
793
794 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530795 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530796 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530797 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530798 }
Govind Singhb53420c2016-03-09 14:32:57 +0530799 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530800 param->vdev_id);
801
802 return 0;
803}
804
805/**
Leo Changeee40872016-09-28 13:43:36 -0700806 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
807 * command to fw
808 * @wmi: wmi handle
809 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
810 *
811 * Return: 0 for success or error code
812 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700813static
Leo Changeee40872016-09-28 13:43:36 -0700814QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
815 struct rx_reorder_queue_setup_params *param)
816{
817 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
818 wmi_buf_t buf;
819 int32_t len = sizeof(*cmd);
820
821 buf = wmi_buf_alloc(wmi, len);
822 if (!buf) {
823 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
824 return QDF_STATUS_E_NOMEM;
825 }
826 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
827 WMITLV_SET_HDR(&cmd->tlv_header,
828 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
829 WMITLV_GET_STRUCT_TLVLEN
830 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
831 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
832 cmd->vdev_id = param->vdev_id;
833 cmd->tid = param->tid;
834 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
835 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
836 cmd->queue_no = param->queue_no;
837
838 if (wmi_unified_cmd_send(wmi, buf, len,
839 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
840 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
841 __func__);
842 qdf_nbuf_free(buf);
843 return QDF_STATUS_E_FAILURE;
844 }
845 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
846 param->peer_macaddr, param->vdev_id, param->tid);
847
848 return QDF_STATUS_SUCCESS;
849}
850
851/**
852 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
853 * command to fw
854 * @wmi: wmi handle
855 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
856 *
857 * Return: 0 for success or error code
858 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700859static
Leo Changeee40872016-09-28 13:43:36 -0700860QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
861 struct rx_reorder_queue_remove_params *param)
862{
863 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
864 wmi_buf_t buf;
865 int32_t len = sizeof(*cmd);
866
867 buf = wmi_buf_alloc(wmi, len);
868 if (!buf) {
869 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
870 return QDF_STATUS_E_NOMEM;
871 }
872 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
873 wmi_buf_data(buf);
874 WMITLV_SET_HDR(&cmd->tlv_header,
875 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
876 WMITLV_GET_STRUCT_TLVLEN
877 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
878 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
879 cmd->vdev_id = param->vdev_id;
880 cmd->tid_mask = param->peer_tid_bitmap;
881
882 if (wmi_unified_cmd_send(wmi, buf, len,
883 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
884 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
885 __func__);
886 qdf_nbuf_free(buf);
887 return QDF_STATUS_E_FAILURE;
888 }
889 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
890 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
891
892 return QDF_STATUS_SUCCESS;
893}
894
895/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530896 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
897 * @wmi_handle: wmi handle
898 * @param: pointer holding peer details
899 *
900 * Return: 0 for success or error code
901 */
902static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
903 struct peer_add_wds_entry_params *param)
904{
905 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
906 wmi_buf_t buf;
907 int len = sizeof(*cmd);
908
909 buf = wmi_buf_alloc(wmi_handle, len);
910 if (!buf) {
911 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
912 return QDF_STATUS_E_FAILURE;
913 }
914 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
915 WMITLV_SET_HDR(&cmd->tlv_header,
916 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
917 WMITLV_GET_STRUCT_TLVLEN
918 (wmi_peer_add_wds_entry_cmd_fixed_param));
919 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
920 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800921 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
922 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530923
924 return wmi_unified_cmd_send(wmi_handle, buf, len,
925 WMI_PEER_ADD_WDS_ENTRY_CMDID);
926}
927
928/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530929 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530930 * @wmi_handle: wmi handle
931 * @param: pointer holding peer details
932 *
933 * Return: 0 for success or error code
934 */
935static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
936 struct peer_del_wds_entry_params *param)
937{
938 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
939 wmi_buf_t buf;
940 int len = sizeof(*cmd);
941
942 buf = wmi_buf_alloc(wmi_handle, len);
943 if (!buf) {
944 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
945 return QDF_STATUS_E_NOMEM;
946 }
947 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
948 WMITLV_SET_HDR(&cmd->tlv_header,
949 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
950 WMITLV_GET_STRUCT_TLVLEN
951 (wmi_peer_remove_wds_entry_cmd_fixed_param));
952 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800953 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530954 return wmi_unified_cmd_send(wmi_handle, buf, len,
955 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
956}
957
958/**
959 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
960 * @wmi_handle: wmi handle
961 * @param: pointer holding peer details
962 *
963 * Return: 0 for success or error code
964 */
965static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
966 struct peer_update_wds_entry_params *param)
967{
968 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
969 wmi_buf_t buf;
970 int len = sizeof(*cmd);
971
972 buf = wmi_buf_alloc(wmi_handle, len);
973 if (!buf) {
974 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
975 return QDF_STATUS_E_NOMEM;
976 }
977
978 /* wmi_buf_alloc returns zeroed command buffer */
979 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
980 WMITLV_SET_HDR(&cmd->tlv_header,
981 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
982 WMITLV_GET_STRUCT_TLVLEN
983 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800984 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
985 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530986 if (param->wds_macaddr)
987 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
988 &cmd->wds_macaddr);
989 if (param->peer_macaddr)
990 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
991 &cmd->peer_macaddr);
992 return wmi_unified_cmd_send(wmi_handle, buf, len,
993 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
994}
995
Himanshu Agarwal66d4a162018-01-10 14:21:53 +0530996#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530997/**
Govind Singh5eb51532016-03-09 11:34:12 +0530998 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
999 * @wmi_handle: wmi handle
1000 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301001 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301002 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301003 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301004 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301005static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301006 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301007{
1008 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1009 wmi_buf_t buf;
1010 int32_t len = sizeof(*cmd);
1011
Govind Singhb53420c2016-03-09 14:32:57 +05301012 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301013
1014 buf = wmi_buf_alloc(wmi_handle, len);
1015 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301016 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301017 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301018 }
1019
1020 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1021 WMITLV_SET_HDR(&cmd->tlv_header,
1022 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1023 WMITLV_GET_STRUCT_TLVLEN
1024 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301025 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301026 cmd->enable = value;
1027
1028 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1029 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301030 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301031 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301032 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301033 }
1034
1035 return 0;
1036}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301037#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301038
1039/**
1040 * send_pdev_utf_cmd_tlv() - send utf command to fw
1041 * @wmi_handle: wmi handle
1042 * @param: pointer to pdev_utf_params
1043 * @mac_id: mac id to have radio context
1044 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301045 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301046 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301047static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301048send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1049 struct pdev_utf_params *param,
1050 uint8_t mac_id)
1051{
1052 wmi_buf_t buf;
1053 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001054 /* if param->len is 0 no data is sent, return error */
1055 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301056 static uint8_t msgref = 1;
1057 uint8_t segNumber = 0, segInfo, numSegments;
1058 uint16_t chunk_len, total_bytes;
1059 uint8_t *bufpos;
1060 struct seg_hdr_info segHdrInfo;
1061
1062 bufpos = param->utf_payload;
1063 total_bytes = param->len;
1064 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1065 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1066 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1067
1068 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1069 numSegments++;
1070
1071 while (param->len) {
1072 if (param->len > MAX_WMI_UTF_LEN)
1073 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1074 else
1075 chunk_len = param->len;
1076
1077 buf = wmi_buf_alloc(wmi_handle,
1078 (chunk_len + sizeof(segHdrInfo) +
1079 WMI_TLV_HDR_SIZE));
1080 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301081 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301082 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301083 }
1084
1085 cmd = (uint8_t *) wmi_buf_data(buf);
1086
1087 segHdrInfo.len = total_bytes;
1088 segHdrInfo.msgref = msgref;
1089 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1090 segHdrInfo.segmentInfo = segInfo;
1091 segHdrInfo.pad = 0;
1092
Govind Singhb53420c2016-03-09 14:32:57 +05301093 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301094 " segHdrInfo.segmentInfo = %d",
1095 __func__, segHdrInfo.len, segHdrInfo.msgref,
1096 segHdrInfo.segmentInfo);
1097
Govind Singhb53420c2016-03-09 14:32:57 +05301098 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301099 "chunk len %d", __func__, total_bytes, segNumber,
1100 numSegments, chunk_len);
1101
1102 segNumber++;
1103
1104 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1105 (chunk_len + sizeof(segHdrInfo)));
1106 cmd += WMI_TLV_HDR_SIZE;
1107 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1108 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1109
1110 ret = wmi_unified_cmd_send(wmi_handle, buf,
1111 (chunk_len + sizeof(segHdrInfo) +
1112 WMI_TLV_HDR_SIZE),
1113 WMI_PDEV_UTF_CMDID);
1114
Govind Singh67922e82016-04-01 16:48:57 +05301115 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301116 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301117 wmi_buf_free(buf);
1118 break;
1119 }
1120
1121 param->len -= chunk_len;
1122 bufpos += chunk_len;
1123 }
1124
1125 msgref++;
1126
1127 return ret;
1128}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301129#ifdef CONFIG_MCL
1130static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1131 uint32_t host_param)
1132{
1133 return host_param;
1134}
1135#else
1136static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1137 uint32_t host_param)
1138{
1139 if (host_param < wmi_pdev_param_max)
1140 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301141
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301142 return WMI_UNAVAILABLE_PARAM;
1143}
1144#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301145/**
1146 * send_pdev_param_cmd_tlv() - set pdev parameters
1147 * @wmi_handle: wmi handle
1148 * @param: pointer to pdev parameter
1149 * @mac_id: radio context
1150 *
1151 * Return: 0 on success, errno on failure
1152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301153static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301154send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1155 struct pdev_params *param,
1156 uint8_t mac_id)
1157{
Govind Singh67922e82016-04-01 16:48:57 +05301158 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301159 wmi_pdev_set_param_cmd_fixed_param *cmd;
1160 wmi_buf_t buf;
1161 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301162 uint32_t pdev_param;
1163
1164 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1165 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1166 WMI_LOGW("%s: Unavailable param %d\n",
1167 __func__, param->param_id);
1168 return QDF_STATUS_E_INVAL;
1169 }
Govind Singh5eb51532016-03-09 11:34:12 +05301170
1171 buf = wmi_buf_alloc(wmi_handle, len);
1172 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301173 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301174 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301175 }
1176 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1177 WMITLV_SET_HDR(&cmd->tlv_header,
1178 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1179 WMITLV_GET_STRUCT_TLVLEN
1180 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301181 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301182 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301183 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301184 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301185 param->param_value);
1186 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1187 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301188 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301189 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301190 wmi_buf_free(buf);
1191 }
1192 return ret;
1193}
1194
1195/**
1196 * send_suspend_cmd_tlv() - WMI suspend function
1197 * @param wmi_handle : handle to WMI.
1198 * @param param : pointer to hold suspend parameter
1199 * @mac_id: radio context
1200 *
1201 * Return 0 on success and -ve on failure.
1202 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301203static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301204 struct suspend_params *param,
1205 uint8_t mac_id)
1206{
1207 wmi_pdev_suspend_cmd_fixed_param *cmd;
1208 wmi_buf_t wmibuf;
1209 uint32_t len = sizeof(*cmd);
1210 int32_t ret;
1211
1212 /*
1213 * send the comand to Target to ignore the
1214 * PCIE reset so as to ensure that Host and target
1215 * states are in sync
1216 */
1217 wmibuf = wmi_buf_alloc(wmi_handle, len);
1218 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301219 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301220
1221 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1222 WMITLV_SET_HDR(&cmd->tlv_header,
1223 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1224 WMITLV_GET_STRUCT_TLVLEN
1225 (wmi_pdev_suspend_cmd_fixed_param));
1226 if (param->disable_target_intr)
1227 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1228 else
1229 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301230
1231 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1232
Govind Singh5eb51532016-03-09 11:34:12 +05301233 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1234 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301235 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301236 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301237 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301238 }
1239
1240 return ret;
1241}
1242
1243/**
1244 * send_resume_cmd_tlv() - WMI resume function
1245 * @param wmi_handle : handle to WMI.
1246 * @mac_id: radio context
1247 *
1248 * Return: 0 on success and -ve on failure.
1249 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301250static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301251 uint8_t mac_id)
1252{
1253 wmi_buf_t wmibuf;
1254 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301255 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301256
1257 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1258 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301259 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301260 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1261 WMITLV_SET_HDR(&cmd->tlv_header,
1262 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1263 WMITLV_GET_STRUCT_TLVLEN
1264 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301265 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301266 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1267 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301268 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301269 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301270 wmi_buf_free(wmibuf);
1271 }
1272
1273 return ret;
1274}
1275
Will Huang422ac9a2017-11-17 13:19:16 +08001276#ifdef FEATURE_WLAN_D0WOW
1277/**
1278 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1279 * @param wmi_handle: handle to WMI.
1280 * @mac_id: radio context
1281 *
1282 * Return: 0 on success and error code on failure.
1283 */
1284static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1285 uint8_t mac_id)
1286{
1287 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1288 wmi_buf_t buf;
1289 int32_t len;
1290 QDF_STATUS status;
1291
1292 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1293
1294 buf = wmi_buf_alloc(wmi_handle, len);
1295 if (!buf) {
1296 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1297 return QDF_STATUS_E_NOMEM;
1298 }
1299 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1300 WMITLV_SET_HDR(&cmd->tlv_header,
1301 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1302 WMITLV_GET_STRUCT_TLVLEN
1303 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1304
1305 cmd->enable = true;
1306
1307 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1308 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1309 if (QDF_IS_STATUS_ERROR(status))
1310 wmi_buf_free(buf);
1311
1312 return status;
1313}
1314
1315/**
1316 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1317 * @param wmi_handle: handle to WMI.
1318 * @mac_id: radio context
1319 *
1320 * Return: 0 on success and error code on failure.
1321 */
1322static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1323 uint8_t mac_id)
1324{
1325 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1326 wmi_buf_t buf;
1327 int32_t len;
1328 QDF_STATUS status;
1329
1330 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1331
1332 buf = wmi_buf_alloc(wmi_handle, len);
1333 if (!buf) {
1334 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1335 return QDF_STATUS_E_NOMEM;
1336 }
1337 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1338 WMITLV_SET_HDR(&cmd->tlv_header,
1339 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1340 WMITLV_GET_STRUCT_TLVLEN
1341 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1342
1343 cmd->enable = false;
1344
1345 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1346 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1347 if (QDF_IS_STATUS_ERROR(status))
1348 wmi_buf_free(buf);
1349
1350 return status;
1351}
1352#endif
1353
Govind Singh5eb51532016-03-09 11:34:12 +05301354/**
1355 * send_wow_enable_cmd_tlv() - WMI wow enable function
1356 * @param wmi_handle : handle to WMI.
1357 * @param param : pointer to hold wow enable parameter
1358 * @mac_id: radio context
1359 *
1360 * Return: 0 on success and -ve on failure.
1361 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301362static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301363 struct wow_cmd_params *param,
1364 uint8_t mac_id)
1365{
1366 wmi_wow_enable_cmd_fixed_param *cmd;
1367 wmi_buf_t buf;
1368 int32_t len;
1369 int32_t ret;
1370
1371 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1372
1373 buf = wmi_buf_alloc(wmi_handle, len);
1374 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301375 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1376 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301377 }
1378 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1379 WMITLV_SET_HDR(&cmd->tlv_header,
1380 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1381 WMITLV_GET_STRUCT_TLVLEN
1382 (wmi_wow_enable_cmd_fixed_param));
1383 cmd->enable = param->enable;
1384 if (param->can_suspend_link)
1385 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1386 else
1387 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001388 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301389
Govind Singhb53420c2016-03-09 14:32:57 +05301390 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301391 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1392 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1393
1394 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1395 WMI_WOW_ENABLE_CMDID);
1396 if (ret)
1397 wmi_buf_free(buf);
1398
1399 return ret;
1400}
1401
1402/**
1403 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301404 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301405 * @peer_addr: peer mac address
1406 * @param: pointer to ap_ps parameter structure
1407 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301408 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301410static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301411 uint8_t *peer_addr,
1412 struct ap_ps_params *param)
1413{
1414 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1415 wmi_buf_t buf;
1416 int32_t err;
1417
1418 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1419 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301420 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301421 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301422 }
1423 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1424 WMITLV_SET_HDR(&cmd->tlv_header,
1425 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1426 WMITLV_GET_STRUCT_TLVLEN
1427 (wmi_ap_ps_peer_cmd_fixed_param));
1428 cmd->vdev_id = param->vdev_id;
1429 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1430 cmd->param = param->param;
1431 cmd->value = param->value;
1432 err = wmi_unified_cmd_send(wmi_handle, buf,
1433 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1434 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301435 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301436 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301437 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301438 }
1439
1440 return 0;
1441}
1442
1443/**
1444 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301445 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301446 * @peer_addr: peer mac address
1447 * @param: pointer to sta_ps parameter structure
1448 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301449 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301450 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301451static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301452 struct sta_ps_params *param)
1453{
1454 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1455 wmi_buf_t buf;
1456 int32_t len = sizeof(*cmd);
1457
1458 buf = wmi_buf_alloc(wmi_handle, len);
1459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301460 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301461 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301462 }
1463
1464 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1465 WMITLV_SET_HDR(&cmd->tlv_header,
1466 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1467 WMITLV_GET_STRUCT_TLVLEN
1468 (wmi_sta_powersave_param_cmd_fixed_param));
1469 cmd->vdev_id = param->vdev_id;
1470 cmd->param = param->param;
1471 cmd->value = param->value;
1472
1473 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1474 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301475 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301476 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301477 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301478 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301479 }
1480
1481 return 0;
1482}
1483
1484/**
1485 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301486 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301487 * @param: ponirt to crash inject paramter structure
1488 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301489 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301490 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301491static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301492 struct crash_inject *param)
1493{
1494 int32_t ret = 0;
1495 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1496 uint16_t len = sizeof(*cmd);
1497 wmi_buf_t buf;
1498
1499 buf = wmi_buf_alloc(wmi_handle, len);
1500 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301501 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301502 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301503 }
1504
1505 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1506 WMITLV_SET_HDR(&cmd->tlv_header,
1507 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1508 WMITLV_GET_STRUCT_TLVLEN
1509 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1510 cmd->type = param->type;
1511 cmd->delay_time_ms = param->delay_time_ms;
1512
1513 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1514 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301515 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301516 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301517 __func__, ret);
1518 wmi_buf_free(buf);
1519 }
1520
1521 return ret;
1522}
1523
1524/**
1525 * send_dbglog_cmd_tlv() - set debug log level
1526 * @param wmi_handle : handle to WMI.
1527 * @param param : pointer to hold dbglog level parameter
1528 *
1529 * Return: 0 on success and -ve on failure.
1530 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301531 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301532send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1533 struct dbglog_params *dbglog_param)
1534{
1535 wmi_buf_t buf;
1536 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001537 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301538 int32_t i;
1539 int32_t len;
1540 int8_t *buf_ptr;
1541 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1542
Alok Kumar240afea2017-08-30 14:45:34 +05301543 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301544
1545 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1546 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1547 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1548 buf = wmi_buf_alloc(wmi_handle, len);
1549 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001550 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301551
1552 configmsg =
1553 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1554 buf_ptr = (int8_t *) configmsg;
1555 WMITLV_SET_HDR(&configmsg->tlv_header,
1556 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1557 WMITLV_GET_STRUCT_TLVLEN
1558 (wmi_debug_log_config_cmd_fixed_param));
1559 configmsg->dbg_log_param = dbglog_param->param;
1560 configmsg->value = dbglog_param->val;
1561 /* Filling in the data part of second tlv -- should
1562 * follow first tlv _ WMI_TLV_HDR_SIZE */
1563 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1564 sizeof
1565 (wmi_debug_log_config_cmd_fixed_param)
1566 + WMI_TLV_HDR_SIZE);
1567 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1568 WMITLV_TAG_ARRAY_UINT32,
1569 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1570 if (dbglog_param->module_id_bitmap) {
1571 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1572 module_id_bitmap_array[i] =
1573 dbglog_param->module_id_bitmap[i];
1574 }
1575 }
1576
1577 status = wmi_unified_cmd_send(wmi_handle, buf,
1578 len, WMI_DBGLOG_CFG_CMDID);
1579
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001580 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301581 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301582
1583 return status;
1584}
1585
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301586#ifdef CONFIG_MCL
1587static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1588 uint32_t host_param)
1589{
1590 return host_param;
1591}
1592#else
1593static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1594 uint32_t host_param)
1595{
1596 if (host_param < wmi_vdev_param_max)
1597 return wmi_handle->vdev_param[host_param];
1598
1599 return WMI_UNAVAILABLE_PARAM;
1600}
1601#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301602/**
1603 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1604 * @param wmi_handle : handle to WMI.
1605 * @param macaddr : MAC address
1606 * @param param : pointer to hold vdev set parameter
1607 *
1608 * Return: 0 on success and -ve on failure.
1609 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301610static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301611 struct vdev_set_params *param)
1612{
Govind Singh67922e82016-04-01 16:48:57 +05301613 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301614 wmi_vdev_set_param_cmd_fixed_param *cmd;
1615 wmi_buf_t buf;
1616 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301617 uint32_t vdev_param;
1618
1619 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1620 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1621 WMI_LOGW("%s:Vdev param %d not available", __func__,
1622 param->param_id);
1623 return QDF_STATUS_E_INVAL;
1624
1625 }
Govind Singh5eb51532016-03-09 11:34:12 +05301626
1627 buf = wmi_buf_alloc(wmi_handle, len);
1628 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301629 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301630 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301631 }
1632 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1633 WMITLV_SET_HDR(&cmd->tlv_header,
1634 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1635 WMITLV_GET_STRUCT_TLVLEN
1636 (wmi_vdev_set_param_cmd_fixed_param));
1637 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301638 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301639 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301640 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301641 param->if_id, param->param_id, param->param_value);
1642 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1643 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301644 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301645 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301646 wmi_buf_free(buf);
1647 }
1648
1649 return ret;
1650}
1651
1652/**
1653 * send_stats_request_cmd_tlv() - WMI request stats function
1654 * @param wmi_handle : handle to WMI.
1655 * @param macaddr : MAC address
1656 * @param param : pointer to hold stats request parameter
1657 *
1658 * Return: 0 on success and -ve on failure.
1659 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301660static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301661 uint8_t macaddr[IEEE80211_ADDR_LEN],
1662 struct stats_request_params *param)
1663{
Govind Singhd3156eb2016-02-26 17:50:39 +05301664 int32_t ret;
1665 wmi_request_stats_cmd_fixed_param *cmd;
1666 wmi_buf_t buf;
1667 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1668
1669 buf = wmi_buf_alloc(wmi_handle, len);
1670 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301671 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1672 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301673 }
1674
1675 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1676 WMITLV_SET_HDR(&cmd->tlv_header,
1677 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1678 WMITLV_GET_STRUCT_TLVLEN
1679 (wmi_request_stats_cmd_fixed_param));
1680 cmd->stats_id = param->stats_id;
1681 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301682 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1683 param->pdev_id);
1684 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001685
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301686 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1687 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001688
1689 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1690 WMI_REQUEST_STATS_CMDID);
1691
Govind Singhd3156eb2016-02-26 17:50:39 +05301692 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301693 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301694 wmi_buf_free(buf);
1695 }
1696
1697 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301698}
1699
Govind Singh87542482016-06-08 19:40:11 +05301700#ifdef CONFIG_WIN
1701/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001702 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301703 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001704 * @param PKTLOG_EVENT : packet log event
1705 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301706 *
1707 * Return: 0 on success and -ve on failure.
1708 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301709static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001710 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301711{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001712 int32_t ret;
1713 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1714 wmi_buf_t buf;
1715 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1716
1717 buf = wmi_buf_alloc(wmi_handle, len);
1718 if (!buf) {
1719 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1720 return -QDF_STATUS_E_NOMEM;
1721 }
1722
1723 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1724 WMITLV_SET_HDR(&cmd->tlv_header,
1725 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1726 WMITLV_GET_STRUCT_TLVLEN
1727 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1728 cmd->evlist = PKTLOG_EVENT;
1729 cmd->pdev_id = mac_id;
1730 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1731 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1732 if (ret) {
1733 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1734 wmi_buf_free(buf);
1735 }
1736
1737 return ret;
1738}
1739
1740/**
1741 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1742 * @param wmi_handle : handle to WMI.
1743 * @mac_id: mac id to have radio context
1744 *
1745 * Return: 0 on success and -ve on failure.
1746 */
1747static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001748 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001749{
1750 int32_t ret;
1751 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1752 wmi_buf_t buf;
1753 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1754
1755 buf = wmi_buf_alloc(wmi_handle, len);
1756 if (!buf) {
1757 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1758 return -QDF_STATUS_E_NOMEM;
1759 }
1760
1761 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1762 WMITLV_SET_HDR(&cmd->tlv_header,
1763 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1764 WMITLV_GET_STRUCT_TLVLEN
1765 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1766 cmd->pdev_id = mac_id;
1767 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1768 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1769 if (ret) {
1770 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1771 wmi_buf_free(buf);
1772 }
1773
1774 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301775}
1776#else
Govind Singh5eb51532016-03-09 11:34:12 +05301777/**
Keyur Parekhde522342017-08-18 14:01:05 -07001778 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1779 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301780 * @param wmi_handle : handle to WMI.
1781 * @param macaddr : MAC address
1782 * @param param : pointer to hold stats request parameter
1783 *
1784 * Return: 0 on success and -ve on failure.
1785 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301786static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301787 uint8_t macaddr[IEEE80211_ADDR_LEN],
1788 struct packet_enable_params *param)
1789{
1790 return 0;
1791}
Keyur Parekhde522342017-08-18 14:01:05 -07001792/**
1793 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1794 * packet-log
1795 * @param wmi_handle : handle to WMI.
1796 * @mac_id: mac id to have radio context
1797 *
1798 * Return: 0 on success and -ve on failure.
1799 */
1800static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1801 uint8_t mac_id)
1802{
1803 return 0;
1804}
Govind Singh87542482016-06-08 19:40:11 +05301805#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301806
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301807#ifdef WLAN_SUPPORT_FILS
1808/**
1809 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1810 * @wmi_handle: wmi handle
1811 * @evt_buf: pointer to event buffer
1812 * @vdev_id: pointer to hold vdev id
1813 *
1814 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1815 */
1816static QDF_STATUS
1817extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1818 void *evt_buf, uint32_t *vdev_id)
1819{
1820 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1821 wmi_host_swfda_event_fixed_param *swfda_event;
1822
1823 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1824 if (!param_buf) {
1825 WMI_LOGE("Invalid swfda event buffer");
1826 return QDF_STATUS_E_INVAL;
1827 }
1828 swfda_event = param_buf->fixed_param;
1829 *vdev_id = swfda_event->vdev_id;
1830
1831 return QDF_STATUS_SUCCESS;
1832}
1833
1834/**
1835 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1836 * @wmi_handle: wmi handle
1837 * @param: pointer to hold FILS discovery enable param
1838 *
1839 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1840 */
1841static QDF_STATUS
1842send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1843 struct config_fils_params *param)
1844{
1845 wmi_enable_fils_cmd_fixed_param *cmd;
1846 wmi_buf_t buf;
1847 QDF_STATUS status;
1848 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1849
1850 buf = wmi_buf_alloc(wmi_handle, len);
1851 if (!buf) {
1852 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1853 return QDF_STATUS_E_NOMEM;
1854 }
1855 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1856 WMITLV_SET_HDR(&cmd->tlv_header,
1857 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1858 WMITLV_GET_STRUCT_TLVLEN(
1859 wmi_enable_fils_cmd_fixed_param));
1860 cmd->vdev_id = param->vdev_id;
1861 cmd->fd_period = param->fd_period;
1862 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1863 param->fd_period, param->vdev_id);
1864
1865 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1866 WMI_ENABLE_FILS_CMDID);
1867 if (status != QDF_STATUS_SUCCESS) {
1868 wmi_buf_free(buf);
1869 return QDF_STATUS_E_FAILURE;
1870 }
1871
1872 return QDF_STATUS_SUCCESS;
1873}
1874
1875/**
1876 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1877 * @wmi_handle: wmi handle
1878 * @param: pointer to hold FD send cmd parameter
1879 *
1880 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1881 */
1882static QDF_STATUS
1883send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1884 struct fd_params *param)
1885{
1886 QDF_STATUS ret;
1887 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1888 wmi_buf_t wmi_buf;
1889 qdf_dma_addr_t dma_addr;
1890
1891 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1892 if (!wmi_buf) {
1893 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1894 return QDF_STATUS_E_NOMEM;
1895 }
1896 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
1897 WMITLV_SET_HDR(&cmd->tlv_header,
1898 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
1899 WMITLV_GET_STRUCT_TLVLEN(
1900 wmi_fd_send_from_host_cmd_fixed_param));
1901 cmd->vdev_id = param->vdev_id;
1902 cmd->data_len = qdf_nbuf_len(param->wbuf);
1903 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1904 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
1905 cmd->frame_ctrl = param->frame_ctrl;
1906
1907 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
1908 WMI_PDEV_SEND_FD_CMDID);
1909 if (ret != QDF_STATUS_SUCCESS) {
1910 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
1911 __func__, ret);
1912 wmi_buf_free(wmi_buf);
1913 }
1914
1915 return ret;
1916}
1917#endif /* WLAN_SUPPORT_FILS */
1918
Sathish Kumarfd347372017-02-13 12:29:09 +05301919static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301920 struct beacon_params *param)
1921{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301922 QDF_STATUS ret;
1923 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1924 wmi_buf_t wmi_buf;
1925 qdf_dma_addr_t dma_addr;
1926 uint32_t dtim_flag = 0;
1927
1928 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1929 if (!wmi_buf) {
1930 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1931 return QDF_STATUS_E_NOMEM;
1932 }
1933 if (param->is_dtim_count_zero) {
1934 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1935 if (param->is_bitctl_reqd) {
1936 /* deliver CAB traffic in next DTIM beacon */
1937 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1938 }
1939 }
1940 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1941 WMITLV_SET_HDR(&cmd->tlv_header,
1942 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1943 WMITLV_GET_STRUCT_TLVLEN
1944 (wmi_bcn_send_from_host_cmd_fixed_param));
1945 cmd->vdev_id = param->vdev_id;
1946 cmd->data_len = qdf_nbuf_len(param->wbuf);
1947 cmd->frame_ctrl = param->frame_ctrl;
1948 cmd->dtim_flag = dtim_flag;
1949 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1950 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1951#if defined(HTT_PADDR64)
1952 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1953#endif
1954 cmd->bcn_antenna = param->bcn_txant;
1955
1956 ret = wmi_unified_cmd_send(wmi_handle,
1957 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1958 if (ret != QDF_STATUS_SUCCESS) {
1959 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1960 wmi_buf_free(wmi_buf);
1961 }
1962
1963 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301964}
1965
1966/**
1967 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1968 * @param wmi_handle : handle to WMI.
1969 * @param param : pointer to hold beacon send cmd parameter
1970 *
1971 * Return: 0 on success and -ve on failure.
1972 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301973static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301974 struct beacon_tmpl_params *param)
1975{
1976 int32_t ret;
1977 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1978 wmi_bcn_prb_info *bcn_prb_info;
1979 wmi_buf_t wmi_buf;
1980 uint8_t *buf_ptr;
1981 uint32_t wmi_buf_len;
1982
Sathish Kumar45e991b2017-02-27 10:35:40 +05301983 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301984 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1985 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1986 param->tmpl_len_aligned;
1987 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1988 if (!wmi_buf) {
1989 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1990 return QDF_STATUS_E_NOMEM;
1991 }
1992 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1993 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1994 WMITLV_SET_HDR(&cmd->tlv_header,
1995 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1996 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1997 cmd->vdev_id = param->vdev_id;
1998 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301999 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2000 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302001 cmd->buf_len = param->tmpl_len;
2002 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2003
2004 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2005 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2006 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2007 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2008 bcn_prb_info->caps = 0;
2009 bcn_prb_info->erp = 0;
2010 buf_ptr += sizeof(wmi_bcn_prb_info);
2011
2012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2013 buf_ptr += WMI_TLV_HDR_SIZE;
2014 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2015
2016 ret = wmi_unified_cmd_send(wmi_handle,
2017 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2018 if (ret) {
2019 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2020 wmi_buf_free(wmi_buf);
2021 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302022
Govind Singh87542482016-06-08 19:40:11 +05302023 return 0;
2024}
Govind Singh5eb51532016-03-09 11:34:12 +05302025
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302026#ifdef CONFIG_MCL
2027static inline void copy_peer_flags_tlv(
2028 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2029 struct peer_assoc_params *param)
2030{
2031 cmd->peer_flags = param->peer_flags;
2032}
2033#else
2034static inline void copy_peer_flags_tlv(
2035 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2036 struct peer_assoc_params *param)
2037{
2038 /*
2039 * The target only needs a subset of the flags maintained in the host.
2040 * Just populate those flags and send it down
2041 */
2042 cmd->peer_flags = 0;
2043
2044 /*
2045 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2046 */
2047 if (param->is_wme_set) {
2048
2049 if (param->qos_flag)
2050 cmd->peer_flags |= WMI_PEER_QOS;
2051 if (param->apsd_flag)
2052 cmd->peer_flags |= WMI_PEER_APSD;
2053 if (param->ht_flag)
2054 cmd->peer_flags |= WMI_PEER_HT;
2055 if (param->bw_40)
2056 cmd->peer_flags |= WMI_PEER_40MHZ;
2057 if (param->bw_80)
2058 cmd->peer_flags |= WMI_PEER_80MHZ;
2059 if (param->bw_160)
2060 cmd->peer_flags |= WMI_PEER_160MHZ;
2061
2062 /* Typically if STBC is enabled for VHT it should be enabled
2063 * for HT as well
2064 **/
2065 if (param->stbc_flag)
2066 cmd->peer_flags |= WMI_PEER_STBC;
2067
2068 /* Typically if LDPC is enabled for VHT it should be enabled
2069 * for HT as well
2070 **/
2071 if (param->ldpc_flag)
2072 cmd->peer_flags |= WMI_PEER_LDPC;
2073
2074 if (param->static_mimops_flag)
2075 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2076 if (param->dynamic_mimops_flag)
2077 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2078 if (param->spatial_mux_flag)
2079 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2080 if (param->vht_flag)
2081 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002082 if (param->he_flag)
2083 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302084 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002085
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302086 if (param->is_pmf_enabled)
2087 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302088 /*
2089 * Suppress authorization for all AUTH modes that need 4-way handshake
2090 * (during re-association).
2091 * Authorization will be done for these modes on key installation.
2092 */
2093 if (param->auth_flag)
2094 cmd->peer_flags |= WMI_PEER_AUTH;
2095 if (param->need_ptk_4_way)
2096 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2097 else
2098 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2099 if (param->need_gtk_2_way)
2100 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2101 /* safe mode bypass the 4-way handshake */
2102 if (param->safe_mode_enabled)
2103 cmd->peer_flags &=
2104 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2105 /* Disable AMSDU for station transmit, if user configures it */
2106 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2107 * it
2108 * if (param->amsdu_disable) Add after FW support
2109 **/
2110
2111 /* Target asserts if node is marked HT and all MCS is set to 0.
2112 * Mark the node as non-HT if all the mcs rates are disabled through
2113 * iwpriv
2114 **/
2115 if (param->peer_ht_rates.num_rates == 0)
2116 cmd->peer_flags &= ~WMI_PEER_HT;
2117}
2118#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302119
2120#ifdef CONFIG_MCL
2121static inline void copy_peer_mac_addr_tlv(
2122 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2123 struct peer_assoc_params *param)
2124{
2125 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2126 sizeof(param->peer_macaddr));
2127}
2128#else
2129static inline void copy_peer_mac_addr_tlv(
2130 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2131 struct peer_assoc_params *param)
2132{
2133 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2134}
2135#endif
2136
Govind Singh5eb51532016-03-09 11:34:12 +05302137/**
2138 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2139 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302140 * @param param : pointer to peer assoc parameter
2141 *
2142 * Return: 0 on success and -ve on failure.
2143 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302144static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302145 struct peer_assoc_params *param)
2146{
Govind Singhd3156eb2016-02-26 17:50:39 +05302147 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2148 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002149 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302150 wmi_buf_t buf;
2151 int32_t len;
2152 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302153 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302154 uint32_t peer_legacy_rates_align;
2155 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002156 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302157
2158
2159 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2160 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302161
2162 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002163 (peer_legacy_rates_align * sizeof(uint8_t)) +
2164 WMI_TLV_HDR_SIZE +
2165 (peer_ht_rates_align * sizeof(uint8_t)) +
2166 sizeof(wmi_vht_rate_set) +
2167 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2168 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302169
2170 buf = wmi_buf_alloc(wmi_handle, len);
2171 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302172 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302173 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302174 }
2175
2176 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2177 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2178 WMITLV_SET_HDR(&cmd->tlv_header,
2179 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2180 WMITLV_GET_STRUCT_TLVLEN
2181 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302182
Govind Singhd3156eb2016-02-26 17:50:39 +05302183 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302184
Govind Singhd3156eb2016-02-26 17:50:39 +05302185 cmd->peer_new_assoc = param->peer_new_assoc;
2186 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302187
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302188 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302189 copy_peer_mac_addr_tlv(cmd, param);
2190
Govind Singhd3156eb2016-02-26 17:50:39 +05302191 cmd->peer_rate_caps = param->peer_rate_caps;
2192 cmd->peer_caps = param->peer_caps;
2193 cmd->peer_listen_intval = param->peer_listen_intval;
2194 cmd->peer_ht_caps = param->peer_ht_caps;
2195 cmd->peer_max_mpdu = param->peer_max_mpdu;
2196 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302197 cmd->peer_vht_caps = param->peer_vht_caps;
2198 cmd->peer_phymode = param->peer_phymode;
2199
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002200 /* Update 11ax capabilities */
2201 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2202 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002203 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2204 sizeof(param->peer_he_cap_phyinfo));
2205 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2206 sizeof(param->peer_ppet));
2207
Govind Singhd3156eb2016-02-26 17:50:39 +05302208 /* Update peer legacy rate information */
2209 buf_ptr += sizeof(*cmd);
2210 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302211 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302212 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302213 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302214 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302215 param->peer_legacy_rates.num_rates);
2216
2217 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002218 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302219 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302220 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302221 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302222 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302223 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302224 param->peer_ht_rates.num_rates);
2225
2226 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002227 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302228 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2229 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2230
2231 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302232
2233 /* Update bandwidth-NSS mapping */
2234 cmd->peer_bw_rxnss_override = 0;
2235 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2236
Govind Singhd3156eb2016-02-26 17:50:39 +05302237 mcs = (wmi_vht_rate_set *) buf_ptr;
2238 if (param->vht_capable) {
2239 mcs->rx_max_rate = param->rx_max_rate;
2240 mcs->rx_mcs_set = param->rx_mcs_set;
2241 mcs->tx_max_rate = param->tx_max_rate;
2242 mcs->tx_mcs_set = param->tx_mcs_set;
2243 }
2244
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002245 /* HE Rates */
2246 cmd->peer_he_mcs = param->peer_he_mcs_count;
2247 buf_ptr += sizeof(wmi_vht_rate_set);
2248 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2249 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2250 buf_ptr += WMI_TLV_HDR_SIZE;
2251
2252 /* Loop through the HE rate set */
2253 for (i = 0; i < param->peer_he_mcs_count; i++) {
2254 he_mcs = (wmi_he_rate_set *) buf_ptr;
2255 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2256 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2257
2258 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2259 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2260 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2261 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2262 buf_ptr += sizeof(wmi_he_rate_set);
2263 }
2264
2265
Govind Singhb53420c2016-03-09 14:32:57 +05302266 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302267 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2268 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002269 "cmd->peer_vht_caps %x "
2270 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302271 "HE phy %x %x %x "
2272 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302273 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2274 cmd->peer_rate_caps, cmd->peer_caps,
2275 cmd->peer_listen_intval, cmd->peer_ht_caps,
2276 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2277 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002278 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2279 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302280 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2281 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302282
2283 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2284 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302285 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302286 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302287 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302288 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302289 }
2290
2291 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302292}
2293
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302294/* copy_scan_notify_events() - Helper routine to copy scan notify events
2295 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302296static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302297 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302298 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302299{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302300
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302301 /* Scan events subscription */
2302 if (param->scan_ev_started)
2303 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2304 if (param->scan_ev_completed)
2305 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2306 if (param->scan_ev_bss_chan)
2307 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2308 if (param->scan_ev_foreign_chan)
2309 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2310 if (param->scan_ev_dequeued)
2311 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2312 if (param->scan_ev_preempted)
2313 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2314 if (param->scan_ev_start_failed)
2315 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2316 if (param->scan_ev_restarted)
2317 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2318 if (param->scan_ev_foreign_chn_exit)
2319 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2320 if (param->scan_ev_suspended)
2321 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2322 if (param->scan_ev_resumed)
2323 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302324
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302325 /** Set scan control flags */
2326 cmd->scan_ctrl_flags = 0;
2327 if (param->scan_f_passive)
2328 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2329 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302330 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302331 if (param->scan_f_promisc_mode)
2332 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2333 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302334 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302335 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302336 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302337 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302338 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302339 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302340 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302341 if (param->scan_f_ofdm_rates)
2342 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2343 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302344 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302345 if (param->scan_f_filter_prb_req)
2346 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2347 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302348 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302349 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302350 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302351 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302352 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302353 if (param->scan_f_force_active_dfs_chn)
2354 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2355 if (param->scan_f_add_tpc_ie_in_probe)
2356 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2357 if (param->scan_f_add_ds_ie_in_probe)
2358 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2359 if (param->scan_f_add_spoofed_mac_in_probe)
2360 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2361 if (param->scan_f_add_rand_seq_in_probe)
2362 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2363 if (param->scan_f_en_ie_whitelist_in_probe)
2364 cmd->scan_ctrl_flags |=
2365 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302366
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302367 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2368 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2369 param->adaptive_dwell_time_mode);
2370}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302371
2372/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302373static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302374 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302375{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302376 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302377}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302378
Anish Natarajdd855152017-03-20 12:49:08 +05302379/*
2380 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2381 * @param wmi_handle : Handle to WMI
2382 * @param vdev_id : vdev identifier
2383 *
2384 * Return : void *
2385 */
2386static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2387{
2388 struct wlan_objmgr_vdev *vdev = NULL;
2389 struct wlan_objmgr_pdev *pdev = NULL;
2390 uint8_t pdev_id = 0;
2391
2392 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2393 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2394 vdev_id, WLAN_SCAN_ID);
2395 if (vdev) {
2396 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2397 pdev = wlan_vdev_get_pdev(vdev);
2398 if (pdev)
2399 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2400 else {
2401 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2402 }
2403 } else {
2404 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2405 }
2406
2407 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2408}
2409
Govind Singh5eb51532016-03-09 11:34:12 +05302410/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302411 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2412 * @mac: random mac addr
2413 * @mask: random mac mask
2414 * @mac_addr: wmi random mac
2415 * @mac_mask: wmi random mac mask
2416 *
2417 * Return None.
2418 */
2419static inline
2420void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2421 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2422{
2423 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2424 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2425}
2426
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302427/*
2428 * wmi_fill_vendor_oui() - fill vendor OUIs
2429 * @buf_ptr: pointer to wmi tlv buffer
2430 * @num_vendor_oui: number of vendor OUIs to be filled
2431 * @param_voui: pointer to OUI buffer
2432 *
2433 * This function populates the wmi tlv buffer when vendor specific OUIs are
2434 * present.
2435 *
2436 * Return: None
2437 */
2438static inline
2439void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2440 uint32_t *pvoui)
2441{
2442 wmi_vendor_oui *voui = NULL;
2443 uint32_t i;
2444
2445 voui = (wmi_vendor_oui *)buf_ptr;
2446
2447 for (i = 0; i < num_vendor_oui; i++) {
2448 WMITLV_SET_HDR(&voui[i].tlv_header,
2449 WMITLV_TAG_STRUC_wmi_vendor_oui,
2450 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2451 voui[i].oui_type_subtype = pvoui[i];
2452 }
2453}
2454
2455/*
2456 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2457 * @ie_bitmap: output pointer to ie bit map in cmd
2458 * @num_vendor_oui: output pointer to num vendor OUIs
2459 * @ie_whitelist: input parameter
2460 *
2461 * This function populates the IE whitelist attrs of scan, pno and
2462 * scan oui commands for ie_whitelist parameter.
2463 *
2464 * Return: None
2465 */
2466static inline
2467void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2468 uint32_t *num_vendor_oui,
2469 struct probe_req_whitelist_attr *ie_whitelist)
2470{
2471 uint32_t i = 0;
2472
2473 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2474 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2475
2476 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2477}
2478
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302479/**
Govind Singh5eb51532016-03-09 11:34:12 +05302480 * send_scan_start_cmd_tlv() - WMI scan start function
2481 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302482 * @param param : pointer to hold scan start cmd parameter
2483 *
2484 * Return: 0 on success and -ve on failure.
2485 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302486static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302487 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302488{
Govind Singhd3156eb2016-02-26 17:50:39 +05302489 int32_t ret = 0;
2490 int32_t i;
2491 wmi_buf_t wmi_buf;
2492 wmi_start_scan_cmd_fixed_param *cmd;
2493 uint8_t *buf_ptr;
2494 uint32_t *tmp_ptr;
2495 wmi_ssid *ssid = NULL;
2496 wmi_mac_addr *bssid;
2497 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302498 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302499 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302500 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302501
2502 /* Length TLV placeholder for array of uint32_t */
2503 len += WMI_TLV_HDR_SIZE;
2504 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302505 if (params->chan_list.num_chan)
2506 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302507
2508 /* Length TLV placeholder for array of wmi_ssid structures */
2509 len += WMI_TLV_HDR_SIZE;
2510 if (params->num_ssids)
2511 len += params->num_ssids * sizeof(wmi_ssid);
2512
2513 /* Length TLV placeholder for array of wmi_mac_addr structures */
2514 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302515 if (params->num_bssid)
2516 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302517
2518 /* Length TLV placeholder for array of bytes */
2519 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302520 if (params->extraie.len)
2521 extraie_len_with_pad =
2522 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002523 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302524
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302525 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2526 if (ie_whitelist->num_vendor_oui)
2527 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2528
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302529 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2530 if (params->scan_f_wide_band)
2531 phymode_roundup =
2532 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2533 sizeof(uint32_t));
2534 len += phymode_roundup;
2535
Govind Singhd3156eb2016-02-26 17:50:39 +05302536 /* Allocate the memory */
2537 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2538 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302539 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302540 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302541 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302542 }
2543 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2544 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2545 WMITLV_SET_HDR(&cmd->tlv_header,
2546 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2547 WMITLV_GET_STRUCT_TLVLEN
2548 (wmi_start_scan_cmd_fixed_param));
2549
2550 cmd->scan_id = params->scan_id;
2551 cmd->scan_req_id = params->scan_req_id;
2552 cmd->vdev_id = params->vdev_id;
2553 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302554
2555 copy_scan_event_cntrl_flags(cmd, params);
2556
Govind Singhd3156eb2016-02-26 17:50:39 +05302557 cmd->dwell_time_active = params->dwell_time_active;
2558 cmd->dwell_time_passive = params->dwell_time_passive;
2559 cmd->min_rest_time = params->min_rest_time;
2560 cmd->max_rest_time = params->max_rest_time;
2561 cmd->repeat_probe_time = params->repeat_probe_time;
2562 cmd->probe_spacing_time = params->probe_spacing_time;
2563 cmd->idle_time = params->idle_time;
2564 cmd->max_scan_time = params->max_scan_time;
2565 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302566 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302567 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302568 cmd->num_bssid = params->num_bssid;
2569 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302570 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302571 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302572 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2573
2574 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2575
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302576 if (params->scan_random.randomize)
2577 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2578 params->scan_random.mac_mask,
2579 &cmd->mac_addr,
2580 &cmd->mac_mask);
2581
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302582 if (ie_whitelist->white_list)
2583 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2584 &cmd->num_vendor_oui,
2585 ie_whitelist);
2586
Govind Singhd3156eb2016-02-26 17:50:39 +05302587 buf_ptr += sizeof(*cmd);
2588 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302589 for (i = 0; i < params->chan_list.num_chan; ++i)
2590 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302591
2592 WMITLV_SET_HDR(buf_ptr,
2593 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302594 (params->chan_list.num_chan * sizeof(uint32_t)));
2595 buf_ptr += WMI_TLV_HDR_SIZE +
2596 (params->chan_list.num_chan * sizeof(uint32_t));
2597
Govind Singh4eacd2b2016-03-07 14:24:22 +05302598 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302599 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302600 goto error;
2601 }
2602
2603 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2604 (params->num_ssids * sizeof(wmi_ssid)));
2605
2606 if (params->num_ssids) {
2607 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2608 for (i = 0; i < params->num_ssids; ++i) {
2609 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302610 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302611 params->ssid[i].length);
2612 ssid++;
2613 }
2614 }
2615 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2616
2617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2618 (params->num_bssid * sizeof(wmi_mac_addr)));
2619 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302620
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302621 if (params->num_bssid) {
2622 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302623 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2624 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302625 bssid++;
2626 }
2627 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302628
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302629 buf_ptr += WMI_TLV_HDR_SIZE +
2630 (params->num_bssid * sizeof(wmi_mac_addr));
2631
2632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2633 if (params->extraie.len)
2634 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2635 params);
2636
2637 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302638
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302639 /* probe req ie whitelisting */
2640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2641 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2642
2643 buf_ptr += WMI_TLV_HDR_SIZE;
2644
2645 if (cmd->num_vendor_oui) {
2646 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2647 ie_whitelist->voui);
2648 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2649 }
2650
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302651 /* Add phy mode TLV if it's a wide band scan */
2652 if (params->scan_f_wide_band) {
2653 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2654 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2655 for (i = 0; i < params->chan_list.num_chan; ++i)
2656 buf_ptr[i] =
2657 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2658 buf_ptr += phymode_roundup;
2659 } else {
2660 /* Add ZERO legth phy mode TLV */
2661 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2662 }
2663
Anish Natarajdd855152017-03-20 12:49:08 +05302664 ret = wmi_unified_cmd_send(
2665 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302666 len, WMI_START_SCAN_CMDID);
2667 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302668 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302669 wmi_buf_free(wmi_buf);
2670 }
2671 return ret;
2672error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302673 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302674 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302675}
2676
2677/**
2678 * send_scan_stop_cmd_tlv() - WMI scan start function
2679 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302680 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302681 *
2682 * Return: 0 on success and -ve on failure.
2683 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302684static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302685 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302686{
Govind Singhd3156eb2016-02-26 17:50:39 +05302687 wmi_stop_scan_cmd_fixed_param *cmd;
2688 int ret;
2689 int len = sizeof(*cmd);
2690 wmi_buf_t wmi_buf;
2691
2692 /* Allocate the memory */
2693 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2694 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302695 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302696 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302697 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302698 goto error;
2699 }
2700
2701 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2702 WMITLV_SET_HDR(&cmd->tlv_header,
2703 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2704 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2705 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302706 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302707 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302708 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2709 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302710 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302711 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2712 /* Cancelling all scans */
2713 cmd->req_type = WMI_SCAN_STOP_ALL;
2714 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2715 /* Cancelling VAP scans */
2716 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2717 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2718 /* Cancelling specific scan */
2719 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302720 } else {
2721 WMI_LOGE("%s: Invalid Command : ", __func__);
2722 wmi_buf_free(wmi_buf);
2723 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302724 }
2725
Anish Natarajdd855152017-03-20 12:49:08 +05302726 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302727 len, WMI_STOP_SCAN_CMDID);
2728 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302729 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302730 wmi_buf_free(wmi_buf);
2731 }
2732
2733error:
2734 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302735}
2736
Govind Singh87542482016-06-08 19:40:11 +05302737#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302738/**
2739 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2740 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302741 * @param param : pointer to hold scan channel list parameter
2742 *
2743 * Return: 0 on success and -ve on failure.
2744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302745static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302746 struct scan_chan_list_params *chan_list)
2747{
2748 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302749 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302750 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302751 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302752 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302753 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302754 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2755
2756 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2757 buf = wmi_buf_alloc(wmi_handle, len);
2758 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302759 WMI_LOGE("Failed to allocate memory");
2760 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302761 goto end;
2762 }
2763
2764 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2765 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2766 WMITLV_SET_HDR(&cmd->tlv_header,
2767 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2768 WMITLV_GET_STRUCT_TLVLEN
2769 (wmi_scan_chan_list_cmd_fixed_param));
2770
Govind Singhb53420c2016-03-09 14:32:57 +05302771 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302772
2773 cmd->num_scan_chans = chan_list->num_scan_chans;
2774 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2775 WMITLV_TAG_ARRAY_STRUC,
2776 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302777 chan_info = (wmi_channel_param *)
2778 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302779 tchan_info = chan_list->chan_info;
2780
2781 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2782 WMITLV_SET_HDR(&chan_info->tlv_header,
2783 WMITLV_TAG_STRUC_wmi_channel,
2784 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2785 chan_info->mhz = tchan_info->mhz;
2786 chan_info->band_center_freq1 =
2787 tchan_info->band_center_freq1;
2788 chan_info->band_center_freq2 =
2789 tchan_info->band_center_freq2;
2790 chan_info->info = tchan_info->info;
2791 chan_info->reg_info_1 = tchan_info->reg_info_1;
2792 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302793 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302794
2795 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2796 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2797 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2798 tchan_info++;
2799 chan_info++;
2800 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302801 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2802 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302803
Anish Natarajdd855152017-03-20 12:49:08 +05302804 qdf_status = wmi_unified_cmd_send(wmi_handle,
2805 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302806
Govind Singh67922e82016-04-01 16:48:57 +05302807 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302808 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302809 wmi_buf_free(buf);
2810 }
Govind Singh67922e82016-04-01 16:48:57 +05302811
Govind Singhd3156eb2016-02-26 17:50:39 +05302812end:
Govind Singhb53420c2016-03-09 14:32:57 +05302813 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302814}
Govind Singh87542482016-06-08 19:40:11 +05302815#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302816static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302817 struct scan_chan_list_params *chan_list)
2818{
2819 wmi_buf_t buf;
2820 QDF_STATUS qdf_status;
2821 wmi_scan_chan_list_cmd_fixed_param *cmd;
2822 int i;
2823 uint8_t *buf_ptr;
2824 wmi_channel *chan_info;
2825 struct channel_param *tchan_info;
2826 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302827
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302828 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302829 buf = wmi_buf_alloc(wmi_handle, len);
2830 if (!buf) {
2831 WMI_LOGE("Failed to allocate memory");
2832 qdf_status = QDF_STATUS_E_NOMEM;
2833 goto end;
2834 }
2835
2836 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2837 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2838 WMITLV_SET_HDR(&cmd->tlv_header,
2839 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2840 WMITLV_GET_STRUCT_TLVLEN
2841 (wmi_scan_chan_list_cmd_fixed_param));
2842
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302843 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302844
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302845 if (chan_list->append)
2846 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2847
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302848 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2849 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302850 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302851 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2852 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302853 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302854 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2855 tchan_info = &(chan_list->ch_param[0]);
2856
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302857 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302858 WMITLV_SET_HDR(&chan_info->tlv_header,
2859 WMITLV_TAG_STRUC_wmi_channel,
2860 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2861 chan_info->mhz = tchan_info->mhz;
2862 chan_info->band_center_freq1 =
2863 tchan_info->cfreq1;
2864 chan_info->band_center_freq2 =
2865 tchan_info->cfreq2;
2866
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302867 if (tchan_info->is_chan_passive)
2868 WMI_SET_CHANNEL_FLAG(chan_info,
2869 WMI_CHAN_FLAG_PASSIVE);
2870
2871 if (tchan_info->allow_vht)
2872 WMI_SET_CHANNEL_FLAG(chan_info,
2873 WMI_CHAN_FLAG_ALLOW_VHT);
2874 else if (tchan_info->allow_ht)
2875 WMI_SET_CHANNEL_FLAG(chan_info,
2876 WMI_CHAN_FLAG_ALLOW_HT);
2877 WMI_SET_CHANNEL_MODE(chan_info,
2878 tchan_info->phy_mode);
2879
2880 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2881 * after FW support
2882 */
2883
2884 /* also fill in power information */
2885 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2886 tchan_info->minpower);
2887 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2888 tchan_info->maxpower);
2889 WMI_SET_CHANNEL_REG_POWER(chan_info,
2890 tchan_info->maxregpower);
2891 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2892 tchan_info->antennamax);
2893 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2894 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002895 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2896 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302897
Govind Singh87542482016-06-08 19:40:11 +05302898 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2899
Govind Singh87542482016-06-08 19:40:11 +05302900 tchan_info++;
2901 chan_info++;
2902 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302903 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2904 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302905
Anish Natarajdd855152017-03-20 12:49:08 +05302906 qdf_status = wmi_unified_cmd_send(
2907 wmi_handle,
2908 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302909
2910 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2911 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2912 wmi_buf_free(buf);
2913 }
2914
2915end:
2916 return qdf_status;
2917}
2918#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302919
2920/**
2921 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2922 *
2923 * @bufp: Pointer to buffer
2924 * @param: Pointer to tx param
2925 *
2926 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2927 */
2928static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2929 struct tx_send_params param)
2930{
2931 wmi_tx_send_params *tx_param;
2932 QDF_STATUS status = QDF_STATUS_SUCCESS;
2933
2934 if (!bufp) {
2935 status = QDF_STATUS_E_FAILURE;
2936 return status;
2937 }
2938 tx_param = (wmi_tx_send_params *)bufp;
2939 WMITLV_SET_HDR(&tx_param->tlv_header,
2940 WMITLV_TAG_STRUC_wmi_tx_send_params,
2941 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2942 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2943 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2944 param.mcs_mask);
2945 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2946 param.nss_mask);
2947 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2948 param.retry_limit);
2949 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2950 param.chain_mask);
2951 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2952 param.bw_mask);
2953 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2954 param.preamble_type);
2955 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2956 param.frame_type);
2957
2958 return status;
2959}
2960
Govind Singhd3156eb2016-02-26 17:50:39 +05302961/**
2962 * send_mgmt_cmd_tlv() - WMI scan start function
2963 * @wmi_handle : handle to WMI.
2964 * @param : pointer to hold mgmt cmd parameter
2965 *
2966 * Return: 0 on success and -ve on failure.
2967 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302968static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302969 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302970{
Govind Singh427ee5a2016-02-26 18:09:36 +05302971 wmi_buf_t buf;
2972 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2973 int32_t cmd_len;
2974 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302975 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302976 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302977 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302978 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2979 mgmt_tx_dl_frm_len;
2980
2981 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302982 WMI_TLV_HDR_SIZE +
2983 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302984
Sathish Kumar5b636932017-06-28 14:40:32 +05302985 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302987 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2988 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302989 }
2990
2991 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2992 bufp = (uint8_t *) cmd;
2993 WMITLV_SET_HDR(&cmd->tlv_header,
2994 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2995 WMITLV_GET_STRUCT_TLVLEN
2996 (wmi_mgmt_tx_send_cmd_fixed_param));
2997
2998 cmd->vdev_id = param->vdev_id;
2999
Govind Singh224a7312016-06-21 14:33:26 +05303000 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303001 cmd->chanfreq = param->chanfreq;
3002 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3003 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3004 sizeof(uint32_t)));
3005 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303006 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303007
3008 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3009 QDF_DMA_TO_DEVICE);
3010 if (status != QDF_STATUS_SUCCESS) {
3011 WMI_LOGE("%s: wmi buf map failed", __func__);
3012 goto err1;
3013 }
3014
Govind Singhb53420c2016-03-09 14:32:57 +05303015 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303016 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003017#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303018 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3019#endif
3020 cmd->frame_len = param->frm_len;
3021 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303022 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303023
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003024 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003025 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003026
Sathish Kumar5b636932017-06-28 14:40:32 +05303027 bufp += roundup(bufp_len, sizeof(uint32_t));
3028 if (param->tx_params_valid) {
3029 status = populate_tx_send_params(bufp, param->tx_param);
3030 if (status != QDF_STATUS_SUCCESS) {
3031 WMI_LOGE("%s: Populate TX send params failed",
3032 __func__);
3033 goto err1;
3034 }
3035 cmd_len += sizeof(wmi_tx_send_params);
3036 }
3037
Govind Singh427ee5a2016-02-26 18:09:36 +05303038 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3039 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303040 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303041 goto err1;
3042 }
Govind Singhb53420c2016-03-09 14:32:57 +05303043 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303044
3045err1:
3046 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303047 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303048}
3049
3050/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303051 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3052 * @wmi_handle : handle to WMI.
3053 * @param : pointer to offchan data tx cmd parameter
3054 *
3055 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3056 */
3057static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3058 struct wmi_offchan_data_tx_params *param)
3059{
3060 wmi_buf_t buf;
3061 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3062 int32_t cmd_len;
3063 uint64_t dma_addr;
3064 void *qdf_ctx = param->qdf_ctx;
3065 uint8_t *bufp;
3066 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3067 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303068 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303069
3070 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303071 WMI_TLV_HDR_SIZE +
3072 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303073
Sathish Kumar5b636932017-06-28 14:40:32 +05303074 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303075 if (!buf) {
3076 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3077 return QDF_STATUS_E_NOMEM;
3078 }
3079
3080 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3081 bufp = (uint8_t *) cmd;
3082 WMITLV_SET_HDR(&cmd->tlv_header,
3083 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3084 WMITLV_GET_STRUCT_TLVLEN
3085 (wmi_offchan_data_tx_send_cmd_fixed_param));
3086
3087 cmd->vdev_id = param->vdev_id;
3088
3089 cmd->desc_id = param->desc_id;
3090 cmd->chanfreq = param->chanfreq;
3091 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3092 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3093 sizeof(uint32_t)));
3094 bufp += WMI_TLV_HDR_SIZE;
3095 qdf_mem_copy(bufp, param->pdata, bufp_len);
3096 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3097 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3098 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3099#if defined(HTT_PADDR64)
3100 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3101#endif
3102 cmd->frame_len = param->frm_len;
3103 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303104 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303105
3106 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3107 bufp, cmd->vdev_id, cmd->chanfreq);
3108
Sathish Kumar5b636932017-06-28 14:40:32 +05303109 bufp += roundup(bufp_len, sizeof(uint32_t));
3110 if (param->tx_params_valid) {
3111 status = populate_tx_send_params(bufp, param->tx_param);
3112 if (status != QDF_STATUS_SUCCESS) {
3113 WMI_LOGE("%s: Populate TX send params failed",
3114 __func__);
3115 goto err1;
3116 }
3117 cmd_len += sizeof(wmi_tx_send_params);
3118 }
3119
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303120 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3121 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3122 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303123 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303124 }
3125
3126 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303127
3128err1:
3129 wmi_buf_free(buf);
3130 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303131}
3132
3133/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303134 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3135 * @wmi_handle: wmi handle
3136 * @param_value: parameter value
3137 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303138 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303139 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303140static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303141 uint32_t param_value)
3142{
Govind Singh67922e82016-04-01 16:48:57 +05303143 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303144 wmi_modem_power_state_cmd_param *cmd;
3145 wmi_buf_t buf;
3146 uint16_t len = sizeof(*cmd);
3147
3148 buf = wmi_buf_alloc(wmi_handle, len);
3149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303150 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303151 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303152 }
3153 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3154 WMITLV_SET_HDR(&cmd->tlv_header,
3155 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3156 WMITLV_GET_STRUCT_TLVLEN
3157 (wmi_modem_power_state_cmd_param));
3158 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303159 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303160 param_value);
3161 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3162 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303163 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303164 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303165 wmi_buf_free(buf);
3166 }
Govind Singh67922e82016-04-01 16:48:57 +05303167
Govind Singh427ee5a2016-02-26 18:09:36 +05303168 return ret;
3169}
3170
3171/**
3172 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3173 * @wmi_handle: wmi handle
3174 * @vdev_id: vdev id
3175 * @val: value
3176 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303177 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303178 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303179static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303180 uint32_t vdev_id, uint8_t val)
3181{
3182 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3183 wmi_buf_t buf;
3184 int32_t len = sizeof(*cmd);
3185
Govind Singhb53420c2016-03-09 14:32:57 +05303186 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303187
3188 buf = wmi_buf_alloc(wmi_handle, len);
3189 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303190 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303191 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303192 }
3193 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3194 WMITLV_SET_HDR(&cmd->tlv_header,
3195 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3196 WMITLV_GET_STRUCT_TLVLEN
3197 (wmi_sta_powersave_mode_cmd_fixed_param));
3198 cmd->vdev_id = vdev_id;
3199 if (val)
3200 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3201 else
3202 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3203
3204 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3205 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303206 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303207 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303208 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303209 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303210 }
Govind Singh5eb51532016-03-09 11:34:12 +05303211 return 0;
3212}
3213
Govind Singh427ee5a2016-02-26 18:09:36 +05303214/**
3215 * send_set_mimops_cmd_tlv() - set MIMO powersave
3216 * @wmi_handle: wmi handle
3217 * @vdev_id: vdev id
3218 * @value: value
3219 *
Govind Singhb53420c2016-03-09 14:32:57 +05303220 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303221 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303222static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303223 uint8_t vdev_id, int value)
3224{
Govind Singh67922e82016-04-01 16:48:57 +05303225 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303226 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3227 wmi_buf_t buf;
3228 uint16_t len = sizeof(*cmd);
3229
3230 buf = wmi_buf_alloc(wmi_handle, len);
3231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303232 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303233 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303234 }
3235 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3236 WMITLV_SET_HDR(&cmd->tlv_header,
3237 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3238 WMITLV_GET_STRUCT_TLVLEN
3239 (wmi_sta_smps_force_mode_cmd_fixed_param));
3240
3241 cmd->vdev_id = vdev_id;
3242
Houston Hoffmanb5168052016-04-14 02:18:01 -07003243 /* WMI_SMPS_FORCED_MODE values do not directly map
3244 * to SM power save values defined in the specification.
3245 * Make sure to send the right mapping.
3246 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303247 switch (value) {
3248 case 0:
3249 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3250 break;
3251 case 1:
3252 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3253 break;
3254 case 2:
3255 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3256 break;
3257 case 3:
3258 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3259 break;
3260 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303261 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3262 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303263 }
3264
Govind Singhb53420c2016-03-09 14:32:57 +05303265 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303266
3267 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3268 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303269 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303270 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303271 wmi_buf_free(buf);
3272 }
3273
3274 return ret;
3275}
3276
3277/**
3278 * send_set_smps_params_cmd_tlv() - set smps params
3279 * @wmi_handle: wmi handle
3280 * @vdev_id: vdev id
3281 * @value: value
3282 *
Govind Singhb53420c2016-03-09 14:32:57 +05303283 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303284 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303285static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303286 int value)
3287{
Govind Singh67922e82016-04-01 16:48:57 +05303288 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303289 wmi_sta_smps_param_cmd_fixed_param *cmd;
3290 wmi_buf_t buf;
3291 uint16_t len = sizeof(*cmd);
3292
3293 buf = wmi_buf_alloc(wmi_handle, len);
3294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303295 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303296 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303297 }
3298 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3299 WMITLV_SET_HDR(&cmd->tlv_header,
3300 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3301 WMITLV_GET_STRUCT_TLVLEN
3302 (wmi_sta_smps_param_cmd_fixed_param));
3303
3304 cmd->vdev_id = vdev_id;
3305 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3306 cmd->param =
3307 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3308
Govind Singhb53420c2016-03-09 14:32:57 +05303309 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 cmd->param);
3311
3312 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3313 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303314 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303315 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303316 wmi_buf_free(buf);
3317 }
3318
3319 return ret;
3320}
3321
3322/**
3323 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3324 * @wmi_handle: wmi handle
3325 * @noa: p2p power save parameters
3326 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303327 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303328 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303329static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303330 struct p2p_ps_params *noa)
3331{
3332 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3333 wmi_p2p_noa_descriptor *noa_discriptor;
3334 wmi_buf_t buf;
3335 uint8_t *buf_ptr;
3336 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303337 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303338 uint32_t duration;
3339
Govind Singhb53420c2016-03-09 14:32:57 +05303340 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303341 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3342 buf = wmi_buf_alloc(wmi_handle, len);
3343 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303344 WMI_LOGE("Failed to allocate memory");
3345 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 goto end;
3347 }
3348
3349 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3350 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3351 WMITLV_SET_HDR(&cmd->tlv_header,
3352 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3353 WMITLV_GET_STRUCT_TLVLEN
3354 (wmi_p2p_set_noa_cmd_fixed_param));
3355 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3356 cmd->vdev_id = noa->session_id;
3357 cmd->enable = (duration) ? true : false;
3358 cmd->num_noa = 1;
3359
3360 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3361 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3362 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3363 sizeof
3364 (wmi_p2p_set_noa_cmd_fixed_param)
3365 + WMI_TLV_HDR_SIZE);
3366 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3367 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3368 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3369 noa_discriptor->type_count = noa->count;
3370 noa_discriptor->duration = duration;
3371 noa_discriptor->interval = noa->interval;
3372 noa_discriptor->start_time = 0;
3373
Govind Singhb53420c2016-03-09 14:32:57 +05303374 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303375 cmd->vdev_id, noa->count, noa_discriptor->duration,
3376 noa->interval);
3377 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3378 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303379 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303380 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303381 wmi_buf_free(buf);
3382 }
3383
3384end:
Govind Singhb53420c2016-03-09 14:32:57 +05303385 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303386 return status;
3387}
3388
3389
3390/**
3391 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3392 * @wmi_handle: wmi handle
3393 * @noa: p2p opp power save parameters
3394 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303395 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303396 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303397static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303398 struct p2p_ps_params *oppps)
3399{
3400 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3401 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303402 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303403
Govind Singhb53420c2016-03-09 14:32:57 +05303404 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303405 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3406 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303407 WMI_LOGE("Failed to allocate memory");
3408 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303409 goto end;
3410 }
3411
3412 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3413 WMITLV_SET_HDR(&cmd->tlv_header,
3414 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3415 WMITLV_GET_STRUCT_TLVLEN
3416 (wmi_p2p_set_oppps_cmd_fixed_param));
3417 cmd->vdev_id = oppps->session_id;
3418 if (oppps->ctwindow)
3419 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3420
3421 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303422 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303423 cmd->vdev_id, oppps->ctwindow);
3424 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3425 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303426 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303427 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303428 wmi_buf_free(buf);
3429 }
3430
3431end:
Govind Singhb53420c2016-03-09 14:32:57 +05303432 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303433 return status;
3434}
3435
Wu Gaocd3a8512017-03-13 20:17:34 +08003436#ifdef CONVERGED_P2P_ENABLE
3437/**
3438 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3439 * @wmi_handle: wmi handle
3440 * @param: p2p listen offload start parameters
3441 *
3442 * Return: QDF status
3443 */
3444static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3445 struct p2p_lo_start *param)
3446{
3447 wmi_buf_t buf;
3448 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3449 int32_t len = sizeof(*cmd);
3450 uint8_t *buf_ptr;
3451 QDF_STATUS status;
3452 int device_types_len_aligned;
3453 int probe_resp_len_aligned;
3454
3455 if (!param) {
3456 WMI_LOGE("lo start param is null");
3457 return QDF_STATUS_E_INVAL;
3458 }
3459
3460 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3461
3462 device_types_len_aligned =
3463 qdf_roundup(param->dev_types_len,
3464 sizeof(A_UINT32));
3465 probe_resp_len_aligned =
3466 qdf_roundup(param->probe_resp_len,
3467 sizeof(A_UINT32));
3468
3469 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3470 probe_resp_len_aligned;
3471
3472 buf = wmi_buf_alloc(wmi_handle, len);
3473 if (!buf) {
3474 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3475 __func__);
3476 return QDF_STATUS_E_NOMEM;
3477 }
3478
3479 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3480 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3481
3482 WMITLV_SET_HDR(&cmd->tlv_header,
3483 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3484 WMITLV_GET_STRUCT_TLVLEN(
3485 wmi_p2p_lo_start_cmd_fixed_param));
3486
3487 cmd->vdev_id = param->vdev_id;
3488 cmd->ctl_flags = param->ctl_flags;
3489 cmd->channel = param->freq;
3490 cmd->period = param->period;
3491 cmd->interval = param->interval;
3492 cmd->count = param->count;
3493 cmd->device_types_len = param->dev_types_len;
3494 cmd->prob_resp_len = param->probe_resp_len;
3495
3496 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3497 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3498 device_types_len_aligned);
3499 buf_ptr += WMI_TLV_HDR_SIZE;
3500 qdf_mem_copy(buf_ptr, param->device_types,
3501 param->dev_types_len);
3502
3503 buf_ptr += device_types_len_aligned;
3504 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3505 probe_resp_len_aligned);
3506 buf_ptr += WMI_TLV_HDR_SIZE;
3507 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3508 param->probe_resp_len);
3509
3510 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3511 cmd->channel, cmd->period, cmd->interval, cmd->count);
3512
3513 status = wmi_unified_cmd_send(wmi_handle,
3514 buf, len,
3515 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3516 if (status != QDF_STATUS_SUCCESS) {
3517 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3518 __func__, status);
3519 wmi_buf_free(buf);
3520 return status;
3521 }
3522
3523 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3524
3525 return QDF_STATUS_SUCCESS;
3526}
3527
3528/**
3529 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3530 * @wmi_handle: wmi handle
3531 * @param: p2p listen offload stop parameters
3532 *
3533 * Return: QDF status
3534 */
3535static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3536 uint8_t vdev_id)
3537{
3538 wmi_buf_t buf;
3539 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3540 int32_t len;
3541 QDF_STATUS status;
3542
3543 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3544
3545 len = sizeof(*cmd);
3546 buf = wmi_buf_alloc(wmi_handle, len);
3547 if (!buf) {
3548 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3549 __func__);
3550 return QDF_STATUS_E_NOMEM;
3551 }
3552 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3553
3554 WMITLV_SET_HDR(&cmd->tlv_header,
3555 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3556 WMITLV_GET_STRUCT_TLVLEN(
3557 wmi_p2p_lo_stop_cmd_fixed_param));
3558
3559 cmd->vdev_id = vdev_id;
3560
3561 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3562
3563 status = wmi_unified_cmd_send(wmi_handle,
3564 buf, len,
3565 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3566 if (status != QDF_STATUS_SUCCESS) {
3567 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3568 __func__, status);
3569 wmi_buf_free(buf);
3570 return status;
3571 }
3572
3573 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3574
3575 return QDF_STATUS_SUCCESS;
3576}
3577#endif /* End of CONVERGED_P2P_ENABLE */
3578
Govind Singh427ee5a2016-02-26 18:09:36 +05303579/**
3580 * send_get_temperature_cmd_tlv() - get pdev temperature req
3581 * @wmi_handle: wmi handle
3582 *
Govind Singhb53420c2016-03-09 14:32:57 +05303583 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303585static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303586{
3587 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3588 wmi_buf_t wmi_buf;
3589 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3590 uint8_t *buf_ptr;
3591
3592 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303593 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3594 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303595 }
3596
3597 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3598 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303599 WMI_LOGE(FL("wmi_buf_alloc failed"));
3600 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303601 }
3602
3603 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3604
3605 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3606 WMITLV_SET_HDR(&cmd->tlv_header,
3607 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3608 WMITLV_GET_STRUCT_TLVLEN
3609 (wmi_pdev_get_temperature_cmd_fixed_param));
3610
3611 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3612 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303613 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303614 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303615 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303616 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303617
Govind Singhb53420c2016-03-09 14:32:57 +05303618 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303619}
3620
3621/**
3622 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3623 * @wmi_handle: wmi handle
3624 * @vdevid: vdev id
3625 * @peer_addr: peer mac address
3626 * @auto_triggerparam: auto trigger parameters
3627 * @num_ac: number of access category
3628 *
3629 * This function sets the trigger
3630 * uapsd params such as service interval, delay interval
3631 * and suspend interval which will be used by the firmware
3632 * to send trigger frames periodically when there is no
3633 * traffic on the transmit side.
3634 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303635 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303636 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303637static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303638 struct sta_uapsd_trig_params *param)
3639{
3640 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303641 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303642 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3643 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3644 uint32_t i;
3645 wmi_buf_t buf;
3646 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003647 struct sta_uapsd_params *uapsd_param;
3648 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303649
3650 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3651 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303653 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303654 }
3655
3656 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3657 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3658 WMITLV_SET_HDR(&cmd->tlv_header,
3659 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3660 WMITLV_GET_STRUCT_TLVLEN
3661 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3662 cmd->vdev_id = param->vdevid;
3663 cmd->num_ac = param->num_ac;
3664 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3665
3666 /* TLV indicating array of structures to follow */
3667 buf_ptr += sizeof(*cmd);
3668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3669
3670 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303671
3672 /*
3673 * Update tag and length for uapsd auto trigger params (this will take
3674 * care of updating tag and length if it is not pre-filled by caller).
3675 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003676 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3677 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303678 for (i = 0; i < param->num_ac; i++) {
3679 WMITLV_SET_HDR((buf_ptr +
3680 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3681 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3682 WMITLV_GET_STRUCT_TLVLEN
3683 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003684 trig_param->wmm_ac = uapsd_param->wmm_ac;
3685 trig_param->user_priority = uapsd_param->user_priority;
3686 trig_param->service_interval = uapsd_param->service_interval;
3687 trig_param->suspend_interval = uapsd_param->suspend_interval;
3688 trig_param->delay_interval = uapsd_param->delay_interval;
3689 trig_param++;
3690 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303691 }
3692
3693 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3694 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303695 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303696 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303697 wmi_buf_free(buf);
3698 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303699
Govind Singh427ee5a2016-02-26 18:09:36 +05303700 return ret;
3701}
3702
Govind Singh2edc80f2016-03-01 15:30:53 +05303703/**
3704 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3705 * @wmi_handle: pointer to the wmi handle
3706 * @utc: pointer to the UTC time struct
3707 *
3708 * Return: 0 on succes
3709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303710static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303711 struct ocb_utc_param *utc)
3712{
Govind Singh67922e82016-04-01 16:48:57 +05303713 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303714 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3715 uint8_t *buf_ptr;
3716 uint32_t len, i;
3717 wmi_buf_t buf;
3718
3719 len = sizeof(*cmd);
3720 buf = wmi_buf_alloc(wmi_handle, len);
3721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303722 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303723 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303724 }
3725
3726 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3727 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3728 WMITLV_SET_HDR(&cmd->tlv_header,
3729 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3730 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3731 cmd->vdev_id = utc->vdev_id;
3732
3733 for (i = 0; i < SIZE_UTC_TIME; i++)
3734 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3735
3736 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3737 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3738
3739 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3740 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303741 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303742 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303743 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303744 }
3745
Govind Singh67922e82016-04-01 16:48:57 +05303746 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303747}
3748
3749/**
3750 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3751 * frames on a channel
3752 * @wmi_handle: pointer to the wmi handle
3753 * @timing_advert: pointer to the timing advertisement struct
3754 *
3755 * Return: 0 on succes
3756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303757static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303758 struct ocb_timing_advert_param *timing_advert)
3759{
Govind Singh67922e82016-04-01 16:48:57 +05303760 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303761 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3762 uint8_t *buf_ptr;
3763 uint32_t len, len_template;
3764 wmi_buf_t buf;
3765
3766 len = sizeof(*cmd) +
3767 WMI_TLV_HDR_SIZE;
3768
3769 len_template = timing_advert->template_length;
3770 /* Add padding to the template if needed */
3771 if (len_template % 4 != 0)
3772 len_template += 4 - (len_template % 4);
3773 len += len_template;
3774
3775 buf = wmi_buf_alloc(wmi_handle, len);
3776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303778 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303779 }
3780
3781 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3782 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3783 WMITLV_SET_HDR(&cmd->tlv_header,
3784 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3785 WMITLV_GET_STRUCT_TLVLEN(
3786 wmi_ocb_start_timing_advert_cmd_fixed_param));
3787 cmd->vdev_id = timing_advert->vdev_id;
3788 cmd->repeat_rate = timing_advert->repeat_rate;
3789 cmd->channel_freq = timing_advert->chan_freq;
3790 cmd->timestamp_offset = timing_advert->timestamp_offset;
3791 cmd->time_value_offset = timing_advert->time_value_offset;
3792 cmd->timing_advert_template_length = timing_advert->template_length;
3793 buf_ptr += sizeof(*cmd);
3794
3795 /* Add the timing advert template */
3796 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3797 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303798 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303799 (uint8_t *)timing_advert->template_value,
3800 timing_advert->template_length);
3801
3802 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3803 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303804 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303805 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303806 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303807 }
3808
Govind Singh67922e82016-04-01 16:48:57 +05303809 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303810}
3811
3812/**
3813 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3814 * on a channel
3815 * @wmi_handle: pointer to the wmi handle
3816 * @timing_advert: pointer to the timing advertisement struct
3817 *
3818 * Return: 0 on succes
3819 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303820static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303821 struct ocb_timing_advert_param *timing_advert)
3822{
Govind Singh67922e82016-04-01 16:48:57 +05303823 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303824 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3825 uint8_t *buf_ptr;
3826 uint32_t len;
3827 wmi_buf_t buf;
3828
3829 len = sizeof(*cmd);
3830 buf = wmi_buf_alloc(wmi_handle, len);
3831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303832 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303833 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303834 }
3835
3836 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3837 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3838 WMITLV_SET_HDR(&cmd->tlv_header,
3839 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3840 WMITLV_GET_STRUCT_TLVLEN(
3841 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3842 cmd->vdev_id = timing_advert->vdev_id;
3843 cmd->channel_freq = timing_advert->chan_freq;
3844
3845 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3846 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303847 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303848 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303849 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303850 }
3851
Govind Singh67922e82016-04-01 16:48:57 +05303852 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303853}
3854
3855/**
3856 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3857 * @wmi_handle: pointer to the wmi handle
3858 * @request: pointer to the request
3859 *
3860 * Return: 0 on succes
3861 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303862static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303863 uint8_t vdev_id)
3864{
Govind Singhb53420c2016-03-09 14:32:57 +05303865 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303866 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3867 uint8_t *buf_ptr;
3868 wmi_buf_t buf;
3869 int32_t len;
3870
3871 len = sizeof(*cmd);
3872 buf = wmi_buf_alloc(wmi_handle, len);
3873 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303874 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303875 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303876 }
3877 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3878
3879 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303880 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303881 WMITLV_SET_HDR(&cmd->tlv_header,
3882 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3883 WMITLV_GET_STRUCT_TLVLEN(
3884 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3885 cmd->vdev_id = vdev_id;
3886
3887 /* Send the WMI command */
3888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3889 WMI_OCB_GET_TSF_TIMER_CMDID);
3890 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303891 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303892 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303893 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303894 }
3895
Govind Singh67922e82016-04-01 16:48:57 +05303896 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303897}
3898
3899/**
3900 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3901 * @wmi_handle: pointer to the wmi handle
3902 * @get_stats_param: pointer to the dcc stats
3903 *
3904 * Return: 0 on succes
3905 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303906static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303907 struct dcc_get_stats_param *get_stats_param)
3908{
Govind Singh67922e82016-04-01 16:48:57 +05303909 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303910 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3911 wmi_dcc_channel_stats_request *channel_stats_array;
3912 wmi_buf_t buf;
3913 uint8_t *buf_ptr;
3914 uint32_t len;
3915 uint32_t i;
3916
3917 /* Validate the input */
3918 if (get_stats_param->request_array_len !=
3919 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303920 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303921 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303922 }
3923
3924 /* Allocate memory for the WMI command */
3925 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3926 get_stats_param->request_array_len;
3927
3928 buf = wmi_buf_alloc(wmi_handle, len);
3929 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303930 WMI_LOGE(FL("wmi_buf_alloc failed"));
3931 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303932 }
3933
3934 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303935 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303936
3937 /* Populate the WMI command */
3938 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3939 buf_ptr += sizeof(*cmd);
3940
3941 WMITLV_SET_HDR(&cmd->tlv_header,
3942 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3943 WMITLV_GET_STRUCT_TLVLEN(
3944 wmi_dcc_get_stats_cmd_fixed_param));
3945 cmd->vdev_id = get_stats_param->vdev_id;
3946 cmd->num_channels = get_stats_param->channel_count;
3947
3948 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3949 get_stats_param->request_array_len);
3950 buf_ptr += WMI_TLV_HDR_SIZE;
3951
3952 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303953 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303954 get_stats_param->request_array_len);
3955 for (i = 0; i < cmd->num_channels; i++)
3956 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3957 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3958 WMITLV_GET_STRUCT_TLVLEN(
3959 wmi_dcc_channel_stats_request));
3960
3961 /* Send the WMI command */
3962 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3963 WMI_DCC_GET_STATS_CMDID);
3964
Govind Singh67922e82016-04-01 16:48:57 +05303965 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303966 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303967 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303968 }
3969
Govind Singh67922e82016-04-01 16:48:57 +05303970 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303971}
3972
3973/**
3974 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3975 * @wmi_handle: pointer to the wmi handle
3976 * @vdev_id: vdev id
3977 * @dcc_stats_bitmap: dcc status bitmap
3978 *
3979 * Return: 0 on succes
3980 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303981static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303982 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3983{
Govind Singh67922e82016-04-01 16:48:57 +05303984 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303985 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3986 wmi_buf_t buf;
3987 uint8_t *buf_ptr;
3988 uint32_t len;
3989
3990 /* Allocate memory for the WMI command */
3991 len = sizeof(*cmd);
3992
3993 buf = wmi_buf_alloc(wmi_handle, len);
3994 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303995 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303996 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303997 }
3998
3999 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304000 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304001
4002 /* Populate the WMI command */
4003 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4004
4005 WMITLV_SET_HDR(&cmd->tlv_header,
4006 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4007 WMITLV_GET_STRUCT_TLVLEN(
4008 wmi_dcc_clear_stats_cmd_fixed_param));
4009 cmd->vdev_id = vdev_id;
4010 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4011
4012 /* Send the WMI command */
4013 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4014 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304015 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304016 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304017 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304018 }
4019
Govind Singh67922e82016-04-01 16:48:57 +05304020 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304021}
4022
4023/**
4024 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4025 * @wmi_handle: pointer to the wmi handle
4026 * @update_ndl_param: pointer to the request parameters
4027 *
4028 * Return: 0 on success
4029 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304030static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304031 struct dcc_update_ndl_param *update_ndl_param)
4032{
Govind Singhb53420c2016-03-09 14:32:57 +05304033 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304034 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4035 wmi_dcc_ndl_chan *ndl_chan_array;
4036 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4037 uint32_t active_state_count;
4038 wmi_buf_t buf;
4039 uint8_t *buf_ptr;
4040 uint32_t len;
4041 uint32_t i;
4042
4043 /* validate the input */
4044 if (update_ndl_param->dcc_ndl_chan_list_len !=
4045 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304046 WMI_LOGE(FL("Invalid parameter"));
4047 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304048 }
4049 active_state_count = 0;
4050 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4051 for (i = 0; i < update_ndl_param->channel_count; i++)
4052 active_state_count +=
4053 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4054 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4055 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304056 WMI_LOGE(FL("Invalid parameter"));
4057 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304058 }
4059
4060 /* Allocate memory for the WMI command */
4061 len = sizeof(*cmd) +
4062 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4063 WMI_TLV_HDR_SIZE +
4064 update_ndl_param->dcc_ndl_active_state_list_len;
4065
4066 buf = wmi_buf_alloc(wmi_handle, len);
4067 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304068 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304069 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304070 }
4071
4072 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304073 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304074
4075 /* Populate the WMI command */
4076 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4077 buf_ptr += sizeof(*cmd);
4078
4079 WMITLV_SET_HDR(&cmd->tlv_header,
4080 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4081 WMITLV_GET_STRUCT_TLVLEN(
4082 wmi_dcc_update_ndl_cmd_fixed_param));
4083 cmd->vdev_id = update_ndl_param->vdev_id;
4084 cmd->num_channel = update_ndl_param->channel_count;
4085
4086 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4087 update_ndl_param->dcc_ndl_chan_list_len);
4088 buf_ptr += WMI_TLV_HDR_SIZE;
4089
4090 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304091 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304092 update_ndl_param->dcc_ndl_chan_list_len);
4093 for (i = 0; i < cmd->num_channel; i++)
4094 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4095 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4096 WMITLV_GET_STRUCT_TLVLEN(
4097 wmi_dcc_ndl_chan));
4098 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4099
4100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4101 update_ndl_param->dcc_ndl_active_state_list_len);
4102 buf_ptr += WMI_TLV_HDR_SIZE;
4103
4104 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304105 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304106 update_ndl_param->dcc_ndl_active_state_list,
4107 update_ndl_param->dcc_ndl_active_state_list_len);
4108 for (i = 0; i < active_state_count; i++) {
4109 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4110 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4111 WMITLV_GET_STRUCT_TLVLEN(
4112 wmi_dcc_ndl_active_state_config));
4113 }
4114 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4115
4116 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304117 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304118 WMI_DCC_UPDATE_NDL_CMDID);
4119 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304120 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304121 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304122 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304123 }
4124
Govind Singh67922e82016-04-01 16:48:57 +05304125 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304126}
4127
4128/**
4129 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4130 * @wmi_handle: pointer to the wmi handle
4131 * @config: the OCB configuration
4132 *
4133 * Return: 0 on success
4134 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304135static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304136 struct ocb_config_param *config, uint32_t *ch_mhz)
4137{
Govind Singh67922e82016-04-01 16:48:57 +05304138 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304139 wmi_ocb_set_config_cmd_fixed_param *cmd;
4140 wmi_channel *chan;
4141 wmi_ocb_channel *ocb_chan;
4142 wmi_qos_parameter *qos_param;
4143 wmi_dcc_ndl_chan *ndl_chan;
4144 wmi_dcc_ndl_active_state_config *ndl_active_config;
4145 wmi_ocb_schedule_element *sched_elem;
4146 uint8_t *buf_ptr;
4147 wmi_buf_t buf;
4148 int32_t len;
4149 int32_t i, j, active_state_count;
4150
4151 /*
4152 * Validate the dcc_ndl_chan_list_len and count the number of active
4153 * states. Validate dcc_ndl_active_state_list_len.
4154 */
4155 active_state_count = 0;
4156 if (config->dcc_ndl_chan_list_len) {
4157 if (!config->dcc_ndl_chan_list ||
4158 config->dcc_ndl_chan_list_len !=
4159 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304160 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304161 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304162 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304163 }
4164
4165 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4166 i < config->channel_count; ++i, ++ndl_chan)
4167 active_state_count +=
4168 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4169
4170 if (active_state_count) {
4171 if (!config->dcc_ndl_active_state_list ||
4172 config->dcc_ndl_active_state_list_len !=
4173 active_state_count *
4174 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304175 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304176 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304177 }
4178 }
4179 }
4180
4181 len = sizeof(*cmd) +
4182 WMI_TLV_HDR_SIZE + config->channel_count *
4183 sizeof(wmi_channel) +
4184 WMI_TLV_HDR_SIZE + config->channel_count *
4185 sizeof(wmi_ocb_channel) +
4186 WMI_TLV_HDR_SIZE + config->channel_count *
4187 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4188 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4189 WMI_TLV_HDR_SIZE + active_state_count *
4190 sizeof(wmi_dcc_ndl_active_state_config) +
4191 WMI_TLV_HDR_SIZE + config->schedule_size *
4192 sizeof(wmi_ocb_schedule_element);
4193 buf = wmi_buf_alloc(wmi_handle, len);
4194 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304195 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304196 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304197 }
4198
4199 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4200 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4201 WMITLV_SET_HDR(&cmd->tlv_header,
4202 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4203 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
4204 cmd->vdev_id = config->session_id;
4205 cmd->channel_count = config->channel_count;
4206 cmd->schedule_size = config->schedule_size;
4207 cmd->flags = config->flags;
4208 buf_ptr += sizeof(*cmd);
4209
4210 /* Add the wmi_channel info */
4211 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4212 config->channel_count*sizeof(wmi_channel));
4213 buf_ptr += WMI_TLV_HDR_SIZE;
4214 for (i = 0; i < config->channel_count; i++) {
4215 chan = (wmi_channel *)buf_ptr;
4216 WMITLV_SET_HDR(&chan->tlv_header,
4217 WMITLV_TAG_STRUC_wmi_channel,
4218 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4219 chan->mhz = config->channels[i].chan_freq;
4220 chan->band_center_freq1 = config->channels[i].chan_freq;
4221 chan->band_center_freq2 = 0;
4222 chan->info = 0;
4223
4224 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
4225 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4226 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4227 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4228 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4229 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4230 config->channels[i].antenna_max);
4231
4232 if (config->channels[i].bandwidth < 10)
4233 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4234 else if (config->channels[i].bandwidth < 20)
4235 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4236 buf_ptr += sizeof(*chan);
4237 }
4238
4239 /* Add the wmi_ocb_channel info */
4240 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4241 config->channel_count*sizeof(wmi_ocb_channel));
4242 buf_ptr += WMI_TLV_HDR_SIZE;
4243 for (i = 0; i < config->channel_count; i++) {
4244 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4245 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4246 WMITLV_TAG_STRUC_wmi_ocb_channel,
4247 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4248 ocb_chan->bandwidth = config->channels[i].bandwidth;
4249 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4250 config->channels[i].mac_address.bytes,
4251 &ocb_chan->mac_address);
4252 buf_ptr += sizeof(*ocb_chan);
4253 }
4254
4255 /* Add the wmi_qos_parameter info */
4256 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4257 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4258 buf_ptr += WMI_TLV_HDR_SIZE;
4259 /* WMI_MAX_NUM_AC parameters for each channel */
4260 for (i = 0; i < config->channel_count; i++) {
4261 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4262 qos_param = (wmi_qos_parameter *)buf_ptr;
4263 WMITLV_SET_HDR(&qos_param->tlv_header,
4264 WMITLV_TAG_STRUC_wmi_qos_parameter,
4265 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4266 qos_param->aifsn =
4267 config->channels[i].qos_params[j].aifsn;
4268 qos_param->cwmin =
4269 config->channels[i].qos_params[j].cwmin;
4270 qos_param->cwmax =
4271 config->channels[i].qos_params[j].cwmax;
4272 buf_ptr += sizeof(*qos_param);
4273 }
4274 }
4275
4276 /* Add the wmi_dcc_ndl_chan (per channel) */
4277 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4278 config->dcc_ndl_chan_list_len);
4279 buf_ptr += WMI_TLV_HDR_SIZE;
4280 if (config->dcc_ndl_chan_list_len) {
4281 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304282 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304283 config->dcc_ndl_chan_list_len);
4284 for (i = 0; i < config->channel_count; i++)
4285 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4286 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4287 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4288 buf_ptr += config->dcc_ndl_chan_list_len;
4289 }
4290
4291 /* Add the wmi_dcc_ndl_active_state_config */
4292 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4293 sizeof(wmi_dcc_ndl_active_state_config));
4294 buf_ptr += WMI_TLV_HDR_SIZE;
4295 if (active_state_count) {
4296 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304297 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304298 config->dcc_ndl_active_state_list,
4299 active_state_count * sizeof(*ndl_active_config));
4300 for (i = 0; i < active_state_count; ++i)
4301 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4302 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4303 WMITLV_GET_STRUCT_TLVLEN(
4304 wmi_dcc_ndl_active_state_config));
4305 buf_ptr += active_state_count *
4306 sizeof(*ndl_active_config);
4307 }
4308
4309 /* Add the wmi_ocb_schedule_element info */
4310 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4311 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4312 buf_ptr += WMI_TLV_HDR_SIZE;
4313 for (i = 0; i < config->schedule_size; i++) {
4314 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4315 WMITLV_SET_HDR(&sched_elem->tlv_header,
4316 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4317 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4318 sched_elem->channel_freq = config->schedule[i].chan_freq;
4319 sched_elem->total_duration = config->schedule[i].total_duration;
4320 sched_elem->guard_interval = config->schedule[i].guard_interval;
4321 buf_ptr += sizeof(*sched_elem);
4322 }
4323
4324
4325 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4326 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304327 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304328 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304329 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304330 }
4331
Govind Singh67922e82016-04-01 16:48:57 +05304332 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304333}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304334
4335/**
4336 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4337 * @wmi_handle: wmi handle
4338 * @mcc_adaptive_scheduler: enable/disable
4339 *
4340 * This function enable/disable mcc adaptive scheduler in fw.
4341 *
Govind Singhb53420c2016-03-09 14:32:57 +05304342 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304343 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304344static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004345 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4346 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304347{
Govind Singh67922e82016-04-01 16:48:57 +05304348 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304349 wmi_buf_t buf = 0;
4350 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4351 uint16_t len =
4352 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4353
4354 buf = wmi_buf_alloc(wmi_handle, len);
4355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304356 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4357 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304358 }
4359 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4360 wmi_buf_data(buf);
4361
4362 WMITLV_SET_HDR(&cmd->tlv_header,
4363 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4364 WMITLV_GET_STRUCT_TLVLEN
4365 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4366 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304367 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304368
4369 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4370 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304371 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304372 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304373 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304374 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304375 }
Govind Singh67922e82016-04-01 16:48:57 +05304376
4377 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304378}
4379
4380/**
4381 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4382 * @wmi: wmi handle
4383 * @mcc_channel: mcc channel
4384 * @mcc_channel_time_latency: MCC channel time latency.
4385 *
4386 * Currently used to set time latency for an MCC vdev/adapter using operating
4387 * channel of it and channel number. The info is provided run time using
4388 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4389 *
4390 * Return: CDF status
4391 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304392static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304393 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4394{
Govind Singh67922e82016-04-01 16:48:57 +05304395 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304396 wmi_buf_t buf = 0;
4397 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4398 uint16_t len = 0;
4399 uint8_t *buf_ptr = NULL;
4400 wmi_resmgr_chan_latency chan_latency;
4401 /* Note: we only support MCC time latency for a single channel */
4402 uint32_t num_channels = 1;
4403 uint32_t chan1_freq = mcc_channel_freq;
4404 uint32_t latency_chan1 = mcc_channel_time_latency;
4405
4406
4407 /* If 0ms latency is provided, then FW will set to a default.
4408 * Otherwise, latency must be at least 30ms.
4409 */
4410 if ((latency_chan1 > 0) &&
4411 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304412 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304413 "Minimum is 30ms (or 0 to use default value by "
4414 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304415 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304416 }
4417
4418 /* Set WMI CMD for channel time latency here */
4419 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4420 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4421 num_channels * sizeof(wmi_resmgr_chan_latency);
4422 buf = wmi_buf_alloc(wmi_handle, len);
4423 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304424 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4425 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304426 }
4427 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4428 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4429 wmi_buf_data(buf);
4430 WMITLV_SET_HDR(&cmdTL->tlv_header,
4431 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4432 WMITLV_GET_STRUCT_TLVLEN
4433 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4434 cmdTL->num_chans = num_channels;
4435 /* Update channel time latency information for home channel(s) */
4436 buf_ptr += sizeof(*cmdTL);
4437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4438 num_channels * sizeof(wmi_resmgr_chan_latency));
4439 buf_ptr += WMI_TLV_HDR_SIZE;
4440 chan_latency.chan_mhz = chan1_freq;
4441 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304442 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304443 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4444 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304445 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304446 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304447 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304448 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304449 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304450 }
Govind Singh67922e82016-04-01 16:48:57 +05304451
4452 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304453}
4454
4455/**
4456 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4457 * @wmi: wmi handle
4458 * @adapter_1_chan_number: adapter 1 channel number
4459 * @adapter_1_quota: adapter 1 quota
4460 * @adapter_2_chan_number: adapter 2 channel number
4461 *
4462 * Return: CDF status
4463 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304464static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304465 uint32_t adapter_1_chan_freq,
4466 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4467{
Govind Singh67922e82016-04-01 16:48:57 +05304468 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304469 wmi_buf_t buf = 0;
4470 uint16_t len = 0;
4471 uint8_t *buf_ptr = NULL;
4472 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4473 wmi_resmgr_chan_time_quota chan_quota;
4474 uint32_t quota_chan1 = adapter_1_quota;
4475 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4476 uint32_t quota_chan2 = 100 - quota_chan1;
4477 /* Note: setting time quota for MCC requires info for 2 channels */
4478 uint32_t num_channels = 2;
4479 uint32_t chan1_freq = adapter_1_chan_freq;
4480 uint32_t chan2_freq = adapter_2_chan_freq;
4481
Govind Singhb53420c2016-03-09 14:32:57 +05304482 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304483 "freq2:%dMHz, Quota2:%dms", __func__,
4484 chan1_freq, quota_chan1, chan2_freq,
4485 quota_chan2);
4486
4487 /*
4488 * Perform sanity check on time quota values provided.
4489 */
4490 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4491 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304492 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304493 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304494 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304495 }
4496 /* Set WMI CMD for channel time quota here */
4497 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4498 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4499 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4500 buf = wmi_buf_alloc(wmi_handle, len);
4501 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304502 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4503 QDF_ASSERT(0);
4504 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304505 }
4506 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4507 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4508 wmi_buf_data(buf);
4509 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4510 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4511 WMITLV_GET_STRUCT_TLVLEN
4512 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4513 cmdTQ->num_chans = num_channels;
4514
4515 /* Update channel time quota information for home channel(s) */
4516 buf_ptr += sizeof(*cmdTQ);
4517 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4518 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4519 buf_ptr += WMI_TLV_HDR_SIZE;
4520 chan_quota.chan_mhz = chan1_freq;
4521 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304522 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304523 /* Construct channel and quota record for the 2nd MCC mode. */
4524 buf_ptr += sizeof(chan_quota);
4525 chan_quota.chan_mhz = chan2_freq;
4526 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304527 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304528
4529 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4530 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304531 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304532 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304533 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304534 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304535 }
Govind Singh67922e82016-04-01 16:48:57 +05304536
4537 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304538}
4539
4540/**
4541 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4542 * @wmi_handle: Pointer to wmi handle
4543 * @thermal_info: Thermal command information
4544 *
4545 * This function sends the thermal management command
4546 * to the firmware
4547 *
Govind Singhb53420c2016-03-09 14:32:57 +05304548 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304550static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304551 struct thermal_cmd_params *thermal_info)
4552{
4553 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4554 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304555 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304556 uint32_t len = 0;
4557
4558 len = sizeof(*cmd);
4559
4560 buf = wmi_buf_alloc(wmi_handle, len);
4561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304562 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4563 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304564 }
4565
4566 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4567
4568 WMITLV_SET_HDR(&cmd->tlv_header,
4569 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4570 WMITLV_GET_STRUCT_TLVLEN
4571 (wmi_thermal_mgmt_cmd_fixed_param));
4572
4573 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4574 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4575 cmd->enable = thermal_info->thermal_enable;
4576
Govind Singhb53420c2016-03-09 14:32:57 +05304577 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304578 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4579
4580 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4581 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304582 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304583 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304584 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304585 }
4586
Govind Singh67922e82016-04-01 16:48:57 +05304587 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304588}
4589
4590
4591/**
4592 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304593 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304594 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4595 *
4596 * This function sends down the LRO configuration parameters to
4597 * the firmware to enable LRO, sets the TCP flags and sets the
4598 * seed values for the toeplitz hash generation
4599 *
Govind Singhb53420c2016-03-09 14:32:57 +05304600 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304601 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304602static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304603 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4604{
4605 wmi_lro_info_cmd_fixed_param *cmd;
4606 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304607 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304608
4609
4610 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304612 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4613 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304614 }
4615
4616 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4617
4618 WMITLV_SET_HDR(&cmd->tlv_header,
4619 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4620 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4621
4622 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4623 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4624 wmi_lro_cmd->tcp_flag);
4625 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4626 wmi_lro_cmd->tcp_flag_mask);
4627 cmd->toeplitz_hash_ipv4_0_3 =
4628 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4629 cmd->toeplitz_hash_ipv4_4_7 =
4630 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4631 cmd->toeplitz_hash_ipv4_8_11 =
4632 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4633 cmd->toeplitz_hash_ipv4_12_15 =
4634 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4635 cmd->toeplitz_hash_ipv4_16 =
4636 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4637
4638 cmd->toeplitz_hash_ipv6_0_3 =
4639 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4640 cmd->toeplitz_hash_ipv6_4_7 =
4641 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4642 cmd->toeplitz_hash_ipv6_8_11 =
4643 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4644 cmd->toeplitz_hash_ipv6_12_15 =
4645 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4646 cmd->toeplitz_hash_ipv6_16_19 =
4647 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4648 cmd->toeplitz_hash_ipv6_20_23 =
4649 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4650 cmd->toeplitz_hash_ipv6_24_27 =
4651 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4652 cmd->toeplitz_hash_ipv6_28_31 =
4653 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4654 cmd->toeplitz_hash_ipv6_32_35 =
4655 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4656 cmd->toeplitz_hash_ipv6_36_39 =
4657 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4658 cmd->toeplitz_hash_ipv6_40 =
4659 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4660
Govind Singhb53420c2016-03-09 14:32:57 +05304661 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304662 cmd->lro_enable, cmd->tcp_flag_u32);
4663
4664 status = wmi_unified_cmd_send(wmi_handle, buf,
4665 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304666 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304667 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304668 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304669 }
4670
Govind Singh67922e82016-04-01 16:48:57 +05304671 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304672}
4673
Govind Singh4eacd2b2016-03-07 14:24:22 +05304674/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304675 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4676 * @wmi_handle: Pointer to wmi handle
4677 * @rate_report_params: Pointer to peer rate report parameters
4678 *
4679 *
4680 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4681 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304682static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304683 struct wmi_peer_rate_report_params *rate_report_params)
4684{
4685 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4686 wmi_buf_t buf = NULL;
4687 QDF_STATUS status = 0;
4688 uint32_t len = 0;
4689 uint32_t i, j;
4690
4691 len = sizeof(*cmd);
4692
4693 buf = wmi_buf_alloc(wmi_handle, len);
4694 if (!buf) {
4695 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4696 return QDF_STATUS_E_FAILURE;
4697 }
4698
4699 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4700 wmi_buf_data(buf);
4701
4702 WMITLV_SET_HDR(
4703 &cmd->tlv_header,
4704 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4705 WMITLV_GET_STRUCT_TLVLEN(
4706 wmi_peer_set_rate_report_condition_fixed_param));
4707
4708 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4709 cmd->report_backoff_time = rate_report_params->backoff_time;
4710 cmd->report_timer_period = rate_report_params->timer_period;
4711 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4712 cmd->cond_per_phy[i].val_cond_flags =
4713 rate_report_params->report_per_phy[i].cond_flags;
4714 cmd->cond_per_phy[i].rate_delta.min_delta =
4715 rate_report_params->report_per_phy[i].delta.delta_min;
4716 cmd->cond_per_phy[i].rate_delta.percentage =
4717 rate_report_params->report_per_phy[i].delta.percent;
4718 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4719 cmd->cond_per_phy[i].rate_threshold[j] =
4720 rate_report_params->report_per_phy[i].
4721 report_rate_threshold[j];
4722 }
4723 }
4724
4725 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4726 cmd->enable_rate_report,
4727 cmd->report_backoff_time, cmd->report_timer_period);
4728
4729 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4730 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4731 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304732 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304733 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4734 __func__);
4735 }
4736 return status;
4737}
4738
4739/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304740 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4741 * @wmi_handle: wmi handle
4742 * @param: bcn ll cmd parameter
4743 *
Govind Singhb53420c2016-03-09 14:32:57 +05304744 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304745 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304746static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304747 wmi_bcn_send_from_host_cmd_fixed_param *param)
4748{
4749 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4750 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304751 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304752
4753 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4754 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304755 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4756 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304757 }
4758
4759 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4760 WMITLV_SET_HDR(&cmd->tlv_header,
4761 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4762 WMITLV_GET_STRUCT_TLVLEN
4763 (wmi_bcn_send_from_host_cmd_fixed_param));
4764 cmd->vdev_id = param->vdev_id;
4765 cmd->data_len = param->data_len;
4766 cmd->frame_ctrl = param->frame_ctrl;
4767 cmd->frag_ptr = param->frag_ptr;
4768 cmd->dtim_flag = param->dtim_flag;
4769
4770 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4771 WMI_PDEV_SEND_BCN_CMDID);
4772
Govind Singh67922e82016-04-01 16:48:57 +05304773 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304774 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304775 wmi_buf_free(wmi_buf);
4776 }
4777
4778 return ret;
4779}
4780
4781/**
4782 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4783 * @wmi_handle: wmi handle
4784 * @vdev_id: vdev id
4785 * @max_retries: max retries
4786 * @retry_interval: retry interval
4787 * This function sets sta query related parameters in fw.
4788 *
Govind Singhb53420c2016-03-09 14:32:57 +05304789 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304790 */
4791
Sathish Kumarfd347372017-02-13 12:29:09 +05304792static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304793 uint8_t vdev_id, uint32_t max_retries,
4794 uint32_t retry_interval)
4795{
4796 wmi_buf_t buf;
4797 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4798 int len;
4799
4800 len = sizeof(*cmd);
4801 buf = wmi_buf_alloc(wmi_handle, len);
4802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304803 WMI_LOGE(FL("wmi_buf_alloc failed"));
4804 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304805 }
4806
4807 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4808 WMITLV_SET_HDR(&cmd->tlv_header,
4809 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4810 WMITLV_GET_STRUCT_TLVLEN
4811 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4812
4813
4814 cmd->vdev_id = vdev_id;
4815 cmd->sa_query_max_retry_count = max_retries;
4816 cmd->sa_query_retry_interval = retry_interval;
4817
Govind Singhb53420c2016-03-09 14:32:57 +05304818 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304819 vdev_id, retry_interval, max_retries);
4820
4821 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4822 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304823 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304824 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304825 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304826 }
4827
Govind Singhb53420c2016-03-09 14:32:57 +05304828 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304829 return 0;
4830}
4831
4832/**
4833 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4834 * @wmi_handle: wmi handle
4835 * @params: sta keep alive parameter
4836 *
4837 * This function sets keep alive related parameters in fw.
4838 *
4839 * Return: CDF status
4840 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304841static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304842 struct sta_params *params)
4843{
4844 wmi_buf_t buf;
4845 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4846 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4847 uint8_t *buf_ptr;
4848 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304849 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304850
Govind Singhb53420c2016-03-09 14:32:57 +05304851 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304852
Govind Singh4eacd2b2016-03-07 14:24:22 +05304853 len = sizeof(*cmd) + sizeof(*arp_rsp);
4854 buf = wmi_buf_alloc(wmi_handle, len);
4855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304856 WMI_LOGE("wmi_buf_alloc failed");
4857 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304858 }
4859
4860 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4861 buf_ptr = (uint8_t *) cmd;
4862 WMITLV_SET_HDR(&cmd->tlv_header,
4863 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4864 WMITLV_GET_STRUCT_TLVLEN
4865 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4866 cmd->interval = params->timeperiod;
4867 cmd->enable = (params->timeperiod) ? 1 : 0;
4868 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304869 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304870 params->timeperiod, params->method);
4871 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4872 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4873 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4874 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4875
c_manjee2772b9c2017-01-23 15:14:13 +05304876 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
4877 (params->method ==
4878 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05304879 if ((NULL == params->hostv4addr) ||
4880 (NULL == params->destv4addr) ||
4881 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07004882 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
4883 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304884 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304885 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304886 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304887 }
c_manjee2772b9c2017-01-23 15:14:13 +05304888 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05304889 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304890 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304891 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304892 WMI_IPV4_ADDR_LEN);
4893 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4894 } else {
4895 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4896 }
4897
Govind Singh67922e82016-04-01 16:48:57 +05304898 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4899 WMI_STA_KEEPALIVE_CMDID);
4900 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304901 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304902 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304903 }
4904
Govind Singhb53420c2016-03-09 14:32:57 +05304905 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304906 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304907}
4908
4909/**
4910 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4911 * @wmi_handle: wmi handle
4912 * @if_id: vdev id
4913 * @gtx_info: GTX config params
4914 *
4915 * This function set GTX related params in firmware.
4916 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304917 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304919static 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 +05304920 struct wmi_gtx_config *gtx_info)
4921{
4922 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4923 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304924 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304925 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304926
Govind Singh4eacd2b2016-03-07 14:24:22 +05304927 buf = wmi_buf_alloc(wmi_handle, len);
4928 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304929 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304930 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304931 }
4932 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4933 WMITLV_SET_HDR(&cmd->tlv_header,
4934 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4935 WMITLV_GET_STRUCT_TLVLEN
4936 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4937 cmd->vdev_id = if_id;
4938
4939 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4940 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4941 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4942 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4943 cmd->gtxPERMargin = gtx_info->gtx_margin;
4944 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4945 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4946 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4947
Govind Singhb53420c2016-03-09 14:32:57 +05304948 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304949 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4950 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4951 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4952 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4953
Abhishek Singh716c46c2016-05-04 16:24:07 +05304954 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304955 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304956 if (QDF_IS_STATUS_ERROR(ret)) {
4957 WMI_LOGE("Failed to set GTX PARAMS");
4958 wmi_buf_free(buf);
4959 }
4960 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304961}
4962
4963/**
4964 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4965 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304966 * @vdev_id: vdev id.
4967 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05304968 *
4969 * This function updates EDCA parameters to the target
4970 *
4971 * Return: CDF Status
4972 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304973static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304974 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304975 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05304976{
4977 uint8_t *buf_ptr;
4978 wmi_buf_t buf;
4979 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304980 wmi_wmm_vparams *wmm_param;
4981 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304982 int len = sizeof(*cmd);
4983 int ac;
4984
4985 buf = wmi_buf_alloc(wmi_handle, len);
4986
4987 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304988 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4989 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304990 }
4991
4992 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4993 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4994 WMITLV_SET_HDR(&cmd->tlv_header,
4995 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4996 WMITLV_GET_STRUCT_TLVLEN
4997 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4998 cmd->vdev_id = vdev_id;
4999
5000 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5001 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305002 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305003 WMITLV_SET_HDR(&wmm_param->tlv_header,
5004 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5005 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5006 wmm_param->cwmin = twmm_param->cwmin;
5007 wmm_param->cwmax = twmm_param->cwmax;
5008 wmm_param->aifs = twmm_param->aifs;
5009 wmm_param->txoplimit = twmm_param->txoplimit;
5010 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305011 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305012 }
5013
5014 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5015 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5016 goto fail;
5017
Govind Singhb53420c2016-03-09 14:32:57 +05305018 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305019
5020fail:
5021 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305022 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5023 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305024}
5025
5026/**
5027 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5028 * @wmi_handle: wmi handle
5029 * @vdev_id: vdev id
5030 * @probe_rsp_info: probe response info
5031 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305032 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305033 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305034static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305035 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005036 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305037{
5038 wmi_prb_tmpl_cmd_fixed_param *cmd;
5039 wmi_bcn_prb_info *bcn_prb_info;
5040 wmi_buf_t wmi_buf;
5041 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5042 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305043 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305044
Govind Singhb53420c2016-03-09 14:32:57 +05305045 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305046
Krunal Soni89426862017-11-14 15:42:48 -08005047 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305048 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
5049
5050 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5051 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5052 tmpl_len_aligned;
5053
5054 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305055 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305056 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305057 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305058 }
5059
5060 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5061 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305062 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305063 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305064 }
5065
5066 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5067
5068 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5069 WMITLV_SET_HDR(&cmd->tlv_header,
5070 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5071 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5072 cmd->vdev_id = vdev_id;
5073 cmd->buf_len = tmpl_len;
5074 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5075
5076 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5077 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5078 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5079 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5080 bcn_prb_info->caps = 0;
5081 bcn_prb_info->erp = 0;
5082 buf_ptr += sizeof(wmi_bcn_prb_info);
5083
5084 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5085 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005086 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305087
5088 ret = wmi_unified_cmd_send(wmi_handle,
5089 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305090 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305091 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305092 wmi_buf_free(wmi_buf);
5093 }
5094
5095 return ret;
5096}
5097
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305098#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305099#define WPI_IV_LEN 16
5100
5101/**
5102 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5103 *
5104 * @dest_tx: destination address of tsc key counter
5105 * @src_tx: source address of tsc key counter
5106 * @dest_rx: destination address of rsc key counter
5107 * @src_rx: source address of rsc key counter
5108 *
5109 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5110 *
5111 * Return: None
5112 *
5113 */
5114static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5115 uint8_t *dest_rx, uint8_t *src_rx)
5116{
5117 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5118 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5119}
5120#else
5121static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5122 uint8_t *dest_rx, uint8_t *src_rx)
5123{
5124 return;
5125}
5126#endif
5127
5128/**
5129 * send_setup_install_key_cmd_tlv() - set key parameters
5130 * @wmi_handle: wmi handle
5131 * @key_params: key parameters
5132 *
5133 * This function fills structure from information
5134 * passed in key_params.
5135 *
5136 * Return: QDF_STATUS_SUCCESS - success
5137 * QDF_STATUS_E_FAILURE - failure
5138 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5139 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305140static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305141 struct set_key_params *key_params)
5142{
5143 wmi_vdev_install_key_cmd_fixed_param *cmd;
5144 wmi_buf_t buf;
5145 uint8_t *buf_ptr;
5146 uint32_t len;
5147 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305148 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305149
5150 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5151 WMI_TLV_HDR_SIZE;
5152
5153 buf = wmi_buf_alloc(wmi_handle, len);
5154 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305155 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305156 return QDF_STATUS_E_NOMEM;
5157 }
5158
5159 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5160 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5161 WMITLV_SET_HDR(&cmd->tlv_header,
5162 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5163 WMITLV_GET_STRUCT_TLVLEN
5164 (wmi_vdev_install_key_cmd_fixed_param));
5165 cmd->vdev_id = key_params->vdev_id;
5166 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305167
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305168
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305169 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5170 cmd->key_flags |= key_params->key_flags;
5171 cmd->key_cipher = key_params->key_cipher;
5172 if ((key_params->key_txmic_len) &&
5173 (key_params->key_rxmic_len)) {
5174 cmd->key_txmic_len = key_params->key_txmic_len;
5175 cmd->key_rxmic_len = key_params->key_rxmic_len;
5176 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305177#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305178 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5179 key_params->tx_iv,
5180 cmd->wpi_key_rsc_counter,
5181 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305182#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305183 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5185 roundup(key_params->key_len, sizeof(uint32_t)));
5186 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
5187 qdf_mem_copy((void *)key_data,
5188 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005189 if (key_params->key_rsc_counter)
5190 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5191 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305192 cmd->key_len = key_params->key_len;
5193
5194 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5195 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305196 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305197 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305198
Govind Singh67922e82016-04-01 16:48:57 +05305199 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305200}
5201
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305202/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005203 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5204 * @wmi_handle: wmi handle
5205 * @params: sar limit params
5206 *
5207 * Return: QDF_STATUS_SUCCESS for success or error code
5208 */
5209static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5210 struct sar_limit_cmd_params *sar_limit_params)
5211{
5212 wmi_buf_t buf;
5213 QDF_STATUS qdf_status;
5214 wmi_sar_limits_cmd_fixed_param *cmd;
5215 int i;
5216 uint8_t *buf_ptr;
5217 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5218 struct sar_limit_cmd_row *sar_rows_list;
5219 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5220
5221 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5222 buf = wmi_buf_alloc(wmi_handle, len);
5223 if (!buf) {
5224 WMI_LOGE("Failed to allocate memory");
5225 qdf_status = QDF_STATUS_E_NOMEM;
5226 goto end;
5227 }
5228
5229 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5230 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5231 WMITLV_SET_HDR(&cmd->tlv_header,
5232 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5233 WMITLV_GET_STRUCT_TLVLEN
5234 (wmi_sar_limits_cmd_fixed_param));
5235 cmd->sar_enable = sar_limit_params->sar_enable;
5236 cmd->commit_limits = sar_limit_params->commit_limits;
5237 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5238
5239 WMI_LOGD("no of sar rows = %d, len = %d",
5240 sar_limit_params->num_limit_rows, len);
5241 buf_ptr += sizeof(*cmd);
5242 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5243 sizeof(wmi_sar_limit_cmd_row) *
5244 sar_limit_params->num_limit_rows);
5245 if (cmd->num_limit_rows == 0)
5246 goto send_sar_limits;
5247
5248 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5249 (buf_ptr + WMI_TLV_HDR_SIZE);
5250 sar_rows_list = sar_limit_params->sar_limit_row_list;
5251
5252 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5253 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5254 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5255 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5256 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5257 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5258 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5259 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5260 wmi_sar_rows_list->validity_bitmap =
5261 sar_rows_list->validity_bitmap;
5262 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5263 i, wmi_sar_rows_list->band_id,
5264 wmi_sar_rows_list->chain_id,
5265 wmi_sar_rows_list->mod_id,
5266 wmi_sar_rows_list->limit_value,
5267 wmi_sar_rows_list->validity_bitmap);
5268 sar_rows_list++;
5269 wmi_sar_rows_list++;
5270 }
5271send_sar_limits:
5272 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5273 WMI_SAR_LIMITS_CMDID);
5274
5275 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5276 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5277 wmi_buf_free(buf);
5278 }
5279
5280end:
5281 return qdf_status;
5282}
5283
Jeff Johnson4783f902017-12-14 15:50:16 -08005284static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5285{
5286 wmi_sar_get_limits_cmd_fixed_param *cmd;
5287 wmi_buf_t wmi_buf;
5288 uint32_t len;
5289 QDF_STATUS status;
5290
5291 WMI_LOGD(FL("Enter"));
5292
5293 len = sizeof(*cmd);
5294 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5295 if (!wmi_buf) {
5296 WMI_LOGP(FL("failed to allocate memory for msg"));
5297 return QDF_STATUS_E_NOMEM;
5298 }
5299
5300 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5301
5302 WMITLV_SET_HDR(&cmd->tlv_header,
5303 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5304 WMITLV_GET_STRUCT_TLVLEN
5305 (wmi_sar_get_limits_cmd_fixed_param));
5306
5307 cmd->reserved = 0;
5308
5309 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5310 WMI_SAR_GET_LIMITS_CMDID);
5311 if (QDF_IS_STATUS_ERROR(status)) {
5312 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5313 wmi_buf_free(wmi_buf);
5314 }
5315
5316 WMI_LOGD(FL("Exit"));
5317
5318 return status;
5319}
5320
5321static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5322 uint8_t *evt_buf,
5323 struct sar_limit_event *event)
5324{
5325 wmi_sar_get_limits_event_fixed_param *fixed_param;
5326 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5327 wmi_sar_get_limit_event_row *row_in;
5328 struct sar_limit_event_row *row_out;
5329 uint32_t row;
5330
5331 if (!evt_buf) {
5332 WMI_LOGE(FL("input event is NULL"));
5333 return QDF_STATUS_E_INVAL;
5334 }
5335 if (!event) {
5336 WMI_LOGE(FL("output event is NULL"));
5337 return QDF_STATUS_E_INVAL;
5338 }
5339
5340 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5341
5342 fixed_param = param_buf->fixed_param;
5343 if (!fixed_param) {
5344 WMI_LOGE(FL("Invalid fixed param"));
5345 return QDF_STATUS_E_INVAL;
5346 }
5347
5348 event->sar_enable = fixed_param->sar_enable;
5349 event->num_limit_rows = fixed_param->num_limit_rows;
5350
5351 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5352 QDF_ASSERT(0);
5353 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5354 event->num_limit_rows,
5355 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5356 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5357 }
5358
5359 row_in = param_buf->sar_get_limits;
5360 row_out = &event->sar_limit_row[0];
5361 for (row = 0; row < event->num_limit_rows; row++) {
5362 row_out->band_id = row_in->band_id;
5363 row_out->chain_id = row_in->chain_id;
5364 row_out->mod_id = row_in->mod_id;
5365 row_out->limit_value = row_in->limit_value;
5366 row_out++;
5367 row_in++;
5368 }
5369
5370 return QDF_STATUS_SUCCESS;
5371}
5372
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305373#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005374/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305375 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5376 * @wmi_handle: wmi handle
5377 * @params: encrypt/decrypt params
5378 *
5379 * Return: QDF_STATUS_SUCCESS for success or error code
5380 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005381static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305382QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305383 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305384{
5385 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5386 wmi_buf_t wmi_buf;
5387 uint8_t *buf_ptr;
5388 QDF_STATUS ret;
5389 uint32_t len;
5390
5391 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5392
5393 len = sizeof(*cmd) +
5394 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5395 WMI_TLV_HDR_SIZE;
5396 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5397 if (!wmi_buf) {
5398 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5399 __func__);
5400 return QDF_STATUS_E_NOMEM;
5401 }
5402
5403 buf_ptr = wmi_buf_data(wmi_buf);
5404 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5405
5406 WMITLV_SET_HDR(&cmd->tlv_header,
5407 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5408 WMITLV_GET_STRUCT_TLVLEN(
5409 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5410
5411 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5412 cmd->key_flag = encrypt_decrypt_params->key_flag;
5413 cmd->key_idx = encrypt_decrypt_params->key_idx;
5414 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5415 cmd->key_len = encrypt_decrypt_params->key_len;
5416 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5417 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5418
5419 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5420 encrypt_decrypt_params->key_len);
5421
5422 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5423 MAX_MAC_HEADER_LEN);
5424
5425 cmd->data_len = encrypt_decrypt_params->data_len;
5426
5427 if (cmd->data_len) {
5428 buf_ptr += sizeof(*cmd);
5429 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5430 roundup(encrypt_decrypt_params->data_len,
5431 sizeof(A_UINT32)));
5432 buf_ptr += WMI_TLV_HDR_SIZE;
5433 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5434 encrypt_decrypt_params->data_len);
5435 }
5436
5437 /* This conversion is to facilitate data to FW in little endian */
5438 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5439 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5440 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5441 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5442 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5443 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5444
5445 ret = wmi_unified_cmd_send(wmi_handle,
5446 wmi_buf, len,
5447 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5448 if (QDF_IS_STATUS_ERROR(ret)) {
5449 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5450 wmi_buf_free(wmi_buf);
5451 }
5452
5453 return ret;
5454}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305455
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305456/**
5457 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5458 * params from event
5459 * @wmi_handle: wmi handle
5460 * @evt_buf: pointer to event buffer
5461 * @resp: Pointer to hold resp parameters
5462 *
5463 * Return: QDF_STATUS_SUCCESS for success or error code
5464 */
5465static
5466QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5467 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5468{
5469 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5470 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5471
5472 param_buf = evt_buf;
5473 if (!param_buf) {
5474 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5475 return QDF_STATUS_E_INVAL;
5476 }
5477
5478 data_event = param_buf->fixed_param;
5479
5480 resp->vdev_id = data_event->vdev_id;
5481 resp->status = data_event->status;
5482
5483 if (data_event->data_length > param_buf->num_enc80211_frame) {
5484 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5485 data_event->data_length,
5486 param_buf->num_enc80211_frame);
5487 return QDF_STATUS_E_INVAL;
5488 }
5489
5490 resp->data_len = data_event->data_length;
5491
5492 if (resp->data_len)
5493 resp->data = (uint8_t *)param_buf->enc80211_frame;
5494
5495 return QDF_STATUS_SUCCESS;
5496}
5497#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305498
Govind Singh4eacd2b2016-03-07 14:24:22 +05305499/**
5500 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5501 * @wmi_handle: wmi handle
5502 * @vdev_id: vdev id
5503 * @p2p_ie: p2p IE
5504 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305505 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305506 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305507static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305508 A_UINT32 vdev_id, uint8_t *p2p_ie)
5509{
Govind Singh67922e82016-04-01 16:48:57 +05305510 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305511 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5512 wmi_buf_t wmi_buf;
5513 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5514 uint8_t *buf_ptr;
5515
5516 ie_len = (uint32_t) (p2p_ie[1] + 2);
5517
5518 /* More than one P2P IE may be included in a single frame.
5519 If multiple P2P IEs are present, the complete P2P attribute
5520 data consists of the concatenation of the P2P Attribute
5521 fields of the P2P IEs. The P2P Attributes field of each
5522 P2P IE may be any length up to the maximum (251 octets).
5523 In this case host sends one P2P IE to firmware so the length
5524 should not exceed more than 251 bytes
5525 */
5526 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305527 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305528 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305529 }
5530
5531 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5532
5533 wmi_buf_len =
5534 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5535 WMI_TLV_HDR_SIZE;
5536
5537 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5538 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305539 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305540 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305541 }
5542
5543 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5544
5545 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5546 WMITLV_SET_HDR(&cmd->tlv_header,
5547 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5548 WMITLV_GET_STRUCT_TLVLEN
5549 (wmi_p2p_go_set_beacon_ie_fixed_param));
5550 cmd->vdev_id = vdev_id;
5551 cmd->ie_buf_len = ie_len;
5552
5553 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5554 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5555 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305556 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305557
Govind Singhb53420c2016-03-09 14:32:57 +05305558 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305559
5560 ret = wmi_unified_cmd_send(wmi_handle,
5561 wmi_buf, wmi_buf_len,
5562 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305563 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305564 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305565 wmi_buf_free(wmi_buf);
5566 }
5567
Govind Singhb53420c2016-03-09 14:32:57 +05305568 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305569 return ret;
5570}
5571
5572/**
5573 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5574 * @wmi_handle: wmi handle
5575 * @req: gateway parameter update request structure
5576 *
5577 * This function reads the incoming @req and fill in the destination
5578 * WMI structure and sends down the gateway configs down to the firmware
5579 *
Govind Singhb53420c2016-03-09 14:32:57 +05305580 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305581 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305582static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305583 struct gateway_update_req_param *req)
5584{
5585 wmi_roam_subnet_change_config_fixed_param *cmd;
5586 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305587 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305588 int len = sizeof(*cmd);
5589
5590 buf = wmi_buf_alloc(wmi_handle, len);
5591 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305592 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5593 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305594 }
5595
5596 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5597 WMITLV_SET_HDR(&cmd->tlv_header,
5598 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5599 WMITLV_GET_STRUCT_TLVLEN(
5600 wmi_roam_subnet_change_config_fixed_param));
5601
5602 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305603 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5604 QDF_IPV4_ADDR_SIZE);
5605 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5606 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305607 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5608 &cmd->inet_gw_mac_addr);
5609 cmd->max_retries = req->max_retries;
5610 cmd->timeout = req->timeout;
5611 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5612 cmd->flag = 0;
5613 if (req->ipv4_addr_type)
5614 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5615
5616 if (req->ipv6_addr_type)
5617 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5618
5619 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5620 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305621 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305622 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305623 ret);
5624 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305625 }
5626
Govind Singh67922e82016-04-01 16:48:57 +05305627 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305628}
5629
5630/**
5631 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5632 * @wmi_handle: wmi handle
5633 * @req: rssi monitoring request structure
5634 *
5635 * This function reads the incoming @req and fill in the destination
5636 * WMI structure and send down the rssi monitoring configs down to the firmware
5637 *
5638 * Return: 0 on success; error number otherwise
5639 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305640static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305641 struct rssi_monitor_param *req)
5642{
5643 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5644 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305645 QDF_STATUS ret;
5646 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305647
5648 buf = wmi_buf_alloc(wmi_handle, len);
5649 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305650 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5651 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305652 }
5653
5654 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5655 WMITLV_SET_HDR(&cmd->tlv_header,
5656 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5657 WMITLV_GET_STRUCT_TLVLEN(
5658 wmi_rssi_breach_monitor_config_fixed_param));
5659
5660 cmd->vdev_id = req->session_id;
5661 cmd->request_id = req->request_id;
5662 cmd->lo_rssi_reenable_hysteresis = 0;
5663 cmd->hi_rssi_reenable_histeresis = 0;
5664 cmd->min_report_interval = 0;
5665 cmd->max_num_report = 1;
5666 if (req->control) {
5667 /* enable one threshold for each min/max */
5668 cmd->enabled_bitmap = 0x09;
5669 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5670 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5671 } else {
5672 cmd->enabled_bitmap = 0;
5673 cmd->low_rssi_breach_threshold[0] = 0;
5674 cmd->hi_rssi_breach_threshold[0] = 0;
5675 }
5676
5677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5678 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305679 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305680 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305681 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305682 }
5683
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005684 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5685
Govind Singh67922e82016-04-01 16:48:57 +05305686 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305687}
5688
5689/**
5690 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5691 * @wmi_handle: wmi handle
5692 * @psetoui: OUI parameters
5693 *
5694 * set scan probe OUI parameters in firmware
5695 *
5696 * Return: CDF status
5697 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305698static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305699 struct scan_mac_oui *psetoui)
5700{
5701 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5702 wmi_buf_t wmi_buf;
5703 uint32_t len;
5704 uint8_t *buf_ptr;
5705 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305706 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305707
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305708 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5709 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5710
Govind Singh4eacd2b2016-03-07 14:24:22 +05305711 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5712 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305713 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5714 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305715 }
5716 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5717 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5718 WMITLV_SET_HDR(&cmd->tlv_header,
5719 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5720 WMITLV_GET_STRUCT_TLVLEN
5721 (wmi_scan_prob_req_oui_cmd_fixed_param));
5722
5723 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305724 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305725 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5726 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305727 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305728 cmd->prob_req_oui);
5729
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305730 cmd->vdev_id = psetoui->vdev_id;
5731 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5732 if (psetoui->enb_probe_req_sno_randomization)
5733 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5734
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305735 if (ie_whitelist->white_list) {
5736 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5737 &cmd->num_vendor_oui,
5738 ie_whitelist);
5739 cmd->flags |=
5740 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5741 }
5742
5743 buf_ptr += sizeof(*cmd);
5744 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5745 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5746 buf_ptr += WMI_TLV_HDR_SIZE;
5747
5748 if (cmd->num_vendor_oui != 0) {
5749 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5750 ie_whitelist->voui);
5751 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5752 }
5753
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5755 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305756 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305757 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305758 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305759 }
Govind Singhb53420c2016-03-09 14:32:57 +05305760 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305761}
5762
5763/**
5764 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5765 * @wmi_handle: wmi handle
5766 * @req: passpoint network request structure
5767 *
5768 * This function sends down WMI command with network id set to wildcard id.
5769 * firmware shall clear all the config entries
5770 *
Govind Singhb53420c2016-03-09 14:32:57 +05305771 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305772 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305773static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305774 struct wifi_passpoint_req_param *req)
5775{
5776 wmi_passpoint_config_cmd_fixed_param *cmd;
5777 wmi_buf_t buf;
5778 uint32_t len;
5779 int ret;
5780
5781 len = sizeof(*cmd);
5782 buf = wmi_buf_alloc(wmi_handle, len);
5783 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305784 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5785 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305786 }
5787
5788 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5789
5790 WMITLV_SET_HDR(&cmd->tlv_header,
5791 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5792 WMITLV_GET_STRUCT_TLVLEN(
5793 wmi_passpoint_config_cmd_fixed_param));
5794 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5795
5796 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5797 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5798 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305799 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305800 __func__);
5801 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305802 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305803 }
5804
Govind Singhb53420c2016-03-09 14:32:57 +05305805 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305806}
5807
5808/**
5809 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5810 * @wmi_handle: wmi handle
5811 * @req: passpoint network request structure
5812 *
5813 * This function reads the incoming @req and fill in the destination
5814 * WMI structure and send down the passpoint configs down to the firmware
5815 *
Govind Singhb53420c2016-03-09 14:32:57 +05305816 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305818static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305819 struct wifi_passpoint_req_param *req)
5820{
5821 wmi_passpoint_config_cmd_fixed_param *cmd;
5822 u_int8_t i, j, *bytes;
5823 wmi_buf_t buf;
5824 uint32_t len;
5825 int ret;
5826
5827 len = sizeof(*cmd);
5828 for (i = 0; i < req->num_networks; i++) {
5829 buf = wmi_buf_alloc(wmi_handle, len);
5830 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305831 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5832 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833 }
5834
5835 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5836 wmi_buf_data(buf);
5837
5838 WMITLV_SET_HDR(&cmd->tlv_header,
5839 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5840 WMITLV_GET_STRUCT_TLVLEN(
5841 wmi_passpoint_config_cmd_fixed_param));
5842 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305843 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5844 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305845 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305846 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305847 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5848 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305849 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305850 j, bytes[0], bytes[1], bytes[2], bytes[3],
5851 bytes[4], bytes[5], bytes[6], bytes[7]);
5852
Govind Singhb53420c2016-03-09 14:32:57 +05305853 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305854 &req->networks[i].roaming_consortium_ids[j],
5855 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5856 }
Govind Singhb53420c2016-03-09 14:32:57 +05305857 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305858 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305859 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305860 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5861
5862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5863 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5864 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305865 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305866 __func__);
5867 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305868 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305869 }
5870 }
5871
Govind Singhb53420c2016-03-09 14:32:57 +05305872 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305873}
5874
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05305875#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305876/**
5877 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
5878 * @wmi_handle: wmi handle
5879 * @roam_req: Roam scan offload params
5880 * @buf_ptr: command buffer to send
5881 * @fils_tlv_len: fils tlv length
5882 *
5883 * Return: Updated buffer pointer
5884 */
5885static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5886 struct roam_offload_scan_params *roam_req,
5887 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5888{
5889 wmi_roam_fils_offload_tlv_param *fils_tlv;
5890 wmi_erp_info *erp_info;
5891 struct roam_fils_params *roam_fils_params;
5892
5893 if (!roam_req->add_fils_tlv)
5894 return buf_ptr;
5895
5896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5897 sizeof(*fils_tlv));
5898 buf_ptr += WMI_TLV_HDR_SIZE;
5899
5900 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
5901 WMITLV_SET_HDR(&fils_tlv->tlv_header,
5902 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
5903 WMITLV_GET_STRUCT_TLVLEN
5904 (wmi_roam_fils_offload_tlv_param));
5905
5906 roam_fils_params = &roam_req->roam_fils_params;
5907 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
5908
5909 erp_info->username_length = roam_fils_params->username_length;
5910 qdf_mem_copy(erp_info->username, roam_fils_params->username,
5911 erp_info->username_length);
5912
5913 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
5914
5915 erp_info->rRk_length = roam_fils_params->rrk_length;
5916 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
5917 erp_info->rRk_length);
5918
5919 erp_info->rIk_length = roam_fils_params->rik_length;
5920 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
5921 erp_info->rIk_length);
5922
5923 erp_info->realm_len = roam_fils_params->realm_len;
5924 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
5925 erp_info->realm_len);
5926
5927 buf_ptr += sizeof(*fils_tlv);
5928 return buf_ptr;
5929}
5930#else
5931static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
5932 struct roam_offload_scan_params *roam_req,
5933 uint8_t *buf_ptr, uint32_t fils_tlv_len)
5934{
5935 return buf_ptr;
5936}
5937#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305938/**
5939 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5940 * @wmi_handle: wmi handle
5941 * @scan_cmd_fp: start scan command ptr
5942 * @roam_req: roam request param
5943 *
5944 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5945 * of WMI_ROAM_SCAN_MODE.
5946 *
5947 * Return: QDF status
5948 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305949static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305950 wmi_start_scan_cmd_fixed_param *
5951 scan_cmd_fp,
5952 struct roam_offload_scan_params *roam_req)
5953{
5954 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305955 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305956 int len;
5957 uint8_t *buf_ptr;
5958 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305959
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305960#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5961 int auth_mode = roam_req->auth_mode;
5962 wmi_roam_offload_tlv_param *roam_offload_params;
5963 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5964 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5965 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305966 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05305967 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305968#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5969 /* Need to create a buf with roam_scan command at
5970 * front and piggyback with scan command */
5971 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5972#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5973 (2 * WMI_TLV_HDR_SIZE) +
5974#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5975 sizeof(wmi_start_scan_cmd_fixed_param);
5976#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07005977 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305978 if (roam_req->is_roam_req_valid &&
5979 roam_req->roam_offload_enabled) {
5980 len += sizeof(wmi_roam_offload_tlv_param);
5981 len += WMI_TLV_HDR_SIZE;
5982 if ((auth_mode != WMI_AUTH_NONE) &&
5983 ((auth_mode != WMI_AUTH_OPEN) ||
5984 (auth_mode == WMI_AUTH_OPEN &&
5985 roam_req->mdid.mdie_present) ||
5986 roam_req->is_ese_assoc)) {
5987 len += WMI_TLV_HDR_SIZE;
5988 if (roam_req->is_ese_assoc)
5989 len +=
5990 sizeof(wmi_roam_ese_offload_tlv_param);
5991 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5992 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5993 (auth_mode == WMI_AUTH_OPEN &&
5994 roam_req->mdid.mdie_present))
5995 len +=
5996 sizeof(wmi_roam_11r_offload_tlv_param);
5997 else
5998 len +=
5999 sizeof(wmi_roam_11i_offload_tlv_param);
6000 } else {
6001 len += WMI_TLV_HDR_SIZE;
6002 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306003
6004 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6005 + roundup(roam_req->assoc_ie_length,
6006 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306007
6008 if (roam_req->add_fils_tlv) {
6009 fils_tlv_len = sizeof(
6010 wmi_roam_fils_offload_tlv_param);
6011 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6012 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306013 } else {
6014 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306015 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306016 __func__, roam_req->roam_offload_enabled);
6017 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306018 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306019 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306020 }
6021 if (roam_req->is_roam_req_valid &&
6022 roam_req->roam_offload_enabled) {
6023 roam_req->mode = roam_req->mode |
6024 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6025 }
6026#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6027
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306028 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6029 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6030 len = sizeof(wmi_roam_scan_mode_fixed_param);
6031
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306032 buf = wmi_buf_alloc(wmi_handle, len);
6033 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306034 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306035 return QDF_STATUS_E_NOMEM;
6036 }
6037
6038 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6039 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6040 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6041 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6042 WMITLV_GET_STRUCT_TLVLEN
6043 (wmi_roam_scan_mode_fixed_param));
6044
6045 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6046 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306047 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6048 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6049 roam_scan_mode_fp->flags |=
6050 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306051 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306052 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306053
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306054 /* Fill in scan parameters suitable for roaming scan */
6055 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306056
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306057 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6058 sizeof(wmi_start_scan_cmd_fixed_param));
6059 /* Ensure there is no additional IEs */
6060 scan_cmd_fp->ie_len = 0;
6061 WMITLV_SET_HDR(buf_ptr,
6062 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6063 WMITLV_GET_STRUCT_TLVLEN
6064 (wmi_start_scan_cmd_fixed_param));
6065#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6066 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6067 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6069 sizeof(wmi_roam_offload_tlv_param));
6070 buf_ptr += WMI_TLV_HDR_SIZE;
6071 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6072 WMITLV_SET_HDR(buf_ptr,
6073 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6074 WMITLV_GET_STRUCT_TLVLEN
6075 (wmi_roam_offload_tlv_param));
6076 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6077 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6078 roam_offload_params->select_5g_margin =
6079 roam_req->select_5ghz_margin;
6080 roam_offload_params->reassoc_failure_timeout =
6081 roam_req->reassoc_failure_timeout;
6082
6083 /* Fill the capabilities */
6084 roam_offload_params->capability =
6085 roam_req->roam_offload_params.capability;
6086 roam_offload_params->ht_caps_info =
6087 roam_req->roam_offload_params.ht_caps_info;
6088 roam_offload_params->ampdu_param =
6089 roam_req->roam_offload_params.ampdu_param;
6090 roam_offload_params->ht_ext_cap =
6091 roam_req->roam_offload_params.ht_ext_cap;
6092 roam_offload_params->ht_txbf =
6093 roam_req->roam_offload_params.ht_txbf;
6094 roam_offload_params->asel_cap =
6095 roam_req->roam_offload_params.asel_cap;
6096 roam_offload_params->qos_caps =
6097 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006098 roam_offload_params->qos_enabled =
6099 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306100 roam_offload_params->wmm_caps =
6101 roam_req->roam_offload_params.wmm_caps;
6102 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6103 (uint8_t *)roam_req->roam_offload_params.mcsset,
6104 ROAM_OFFLOAD_NUM_MCS_SET);
6105
6106 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6107 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6108 * they are filled in the same order.Depending on the
6109 * authentication type, the other mode TLV's are nullified
6110 * and only headers are filled.*/
6111 if ((auth_mode != WMI_AUTH_NONE) &&
6112 ((auth_mode != WMI_AUTH_OPEN) ||
6113 (auth_mode == WMI_AUTH_OPEN
6114 && roam_req->mdid.mdie_present) ||
6115 roam_req->is_ese_assoc)) {
6116 if (roam_req->is_ese_assoc) {
6117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6118 WMITLV_GET_STRUCT_TLVLEN(0));
6119 buf_ptr += WMI_TLV_HDR_SIZE;
6120 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6121 WMITLV_GET_STRUCT_TLVLEN(0));
6122 buf_ptr += WMI_TLV_HDR_SIZE;
6123 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6124 sizeof(wmi_roam_ese_offload_tlv_param));
6125 buf_ptr += WMI_TLV_HDR_SIZE;
6126 roam_offload_ese =
6127 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6128 qdf_mem_copy(roam_offload_ese->krk,
6129 roam_req->krk,
6130 sizeof(roam_req->krk));
6131 qdf_mem_copy(roam_offload_ese->btk,
6132 roam_req->btk,
6133 sizeof(roam_req->btk));
6134 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6135 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6136 WMITLV_GET_STRUCT_TLVLEN
6137 (wmi_roam_ese_offload_tlv_param));
6138 buf_ptr +=
6139 sizeof(wmi_roam_ese_offload_tlv_param);
6140 } else if (auth_mode == WMI_AUTH_FT_RSNA
6141 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6142 || (auth_mode == WMI_AUTH_OPEN
6143 && roam_req->mdid.mdie_present)) {
6144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6145 0);
6146 buf_ptr += WMI_TLV_HDR_SIZE;
6147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6148 sizeof(wmi_roam_11r_offload_tlv_param));
6149 buf_ptr += WMI_TLV_HDR_SIZE;
6150 roam_offload_11r =
6151 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6152 roam_offload_11r->r0kh_id_len =
6153 roam_req->rokh_id_length;
6154 qdf_mem_copy(roam_offload_11r->r0kh_id,
6155 roam_req->rokh_id,
6156 roam_offload_11r->r0kh_id_len);
6157 qdf_mem_copy(roam_offload_11r->psk_msk,
6158 roam_req->psk_pmk,
6159 sizeof(roam_req->psk_pmk));
6160 roam_offload_11r->psk_msk_len =
6161 roam_req->pmk_len;
6162 roam_offload_11r->mdie_present =
6163 roam_req->mdid.mdie_present;
6164 roam_offload_11r->mdid =
6165 roam_req->mdid.mobility_domain;
6166 if (auth_mode == WMI_AUTH_OPEN) {
6167 /* If FT-Open ensure pmk length
6168 and r0khid len are zero */
6169 roam_offload_11r->r0kh_id_len = 0;
6170 roam_offload_11r->psk_msk_len = 0;
6171 }
6172 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6173 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6174 WMITLV_GET_STRUCT_TLVLEN
6175 (wmi_roam_11r_offload_tlv_param));
6176 buf_ptr +=
6177 sizeof(wmi_roam_11r_offload_tlv_param);
6178 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6179 WMITLV_GET_STRUCT_TLVLEN(0));
6180 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006181 WMI_LOGD("psk_msk_len = %d",
6182 roam_offload_11r->psk_msk_len);
6183 if (roam_offload_11r->psk_msk_len)
6184 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6185 QDF_TRACE_LEVEL_DEBUG,
6186 roam_offload_11r->psk_msk,
6187 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306188 } else {
6189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6190 sizeof(wmi_roam_11i_offload_tlv_param));
6191 buf_ptr += WMI_TLV_HDR_SIZE;
6192 roam_offload_11i =
6193 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006194
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006195 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006196 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306197 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6198 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006199 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306200 } else {
6201 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6202 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006203 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006204 }
6205 if (roam_req->roam_key_mgmt_offload_enabled &&
6206 roam_req->fw_pmksa_cache) {
6207 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6208 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006209 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006210 } else {
6211 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6212 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006213 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306214 }
6215
6216 qdf_mem_copy(roam_offload_11i->pmk,
6217 roam_req->psk_pmk,
6218 sizeof(roam_req->psk_pmk));
6219 roam_offload_11i->pmk_len = roam_req->pmk_len;
6220 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6221 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6222 WMITLV_GET_STRUCT_TLVLEN
6223 (wmi_roam_11i_offload_tlv_param));
6224 buf_ptr +=
6225 sizeof(wmi_roam_11i_offload_tlv_param);
6226 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6227 0);
6228 buf_ptr += WMI_TLV_HDR_SIZE;
6229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6230 0);
6231 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006232 WMI_LOGD("pmk_len = %d",
6233 roam_offload_11i->pmk_len);
6234 if (roam_offload_11i->pmk_len)
6235 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6236 QDF_TRACE_LEVEL_DEBUG,
6237 roam_offload_11i->pmk,
6238 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306239 }
6240 } else {
6241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6242 WMITLV_GET_STRUCT_TLVLEN(0));
6243 buf_ptr += WMI_TLV_HDR_SIZE;
6244 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6245 WMITLV_GET_STRUCT_TLVLEN(0));
6246 buf_ptr += WMI_TLV_HDR_SIZE;
6247 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6248 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306249 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306250 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306251
6252 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6253 sizeof(*assoc_ies));
6254 buf_ptr += WMI_TLV_HDR_SIZE;
6255
6256 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6257 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6258 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6259 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6260 assoc_ies->buf_len = roam_req->assoc_ie_length;
6261
6262 buf_ptr += sizeof(*assoc_ies);
6263
6264 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6265 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6266 buf_ptr += WMI_TLV_HDR_SIZE;
6267
6268 if (assoc_ies->buf_len != 0) {
6269 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6270 assoc_ies->buf_len);
6271 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306272 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6273 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6274 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306275 } else {
6276 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6277 WMITLV_GET_STRUCT_TLVLEN(0));
6278 buf_ptr += WMI_TLV_HDR_SIZE;
6279 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6280 WMITLV_GET_STRUCT_TLVLEN(0));
6281 buf_ptr += WMI_TLV_HDR_SIZE;
6282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6283 WMITLV_GET_STRUCT_TLVLEN(0));
6284 buf_ptr += WMI_TLV_HDR_SIZE;
6285 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6286 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306287 buf_ptr += WMI_TLV_HDR_SIZE;
6288 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6289 WMITLV_GET_STRUCT_TLVLEN(0));
6290 buf_ptr += WMI_TLV_HDR_SIZE;
6291 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6292 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306293 }
6294#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306295
6296send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306297 status = wmi_unified_cmd_send(wmi_handle, buf,
6298 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306299 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306300 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306301 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6302 status);
6303 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306304 }
6305
Govind Singh67922e82016-04-01 16:48:57 +05306306 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306307}
6308
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006309static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6310 struct wmi_mawc_roam_params *params)
6311{
6312 wmi_buf_t buf = NULL;
6313 QDF_STATUS status;
6314 int len;
6315 uint8_t *buf_ptr;
6316 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6317
6318 len = sizeof(*wmi_roam_mawc_params);
6319 buf = wmi_buf_alloc(wmi_handle, len);
6320 if (!buf) {
6321 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6322 return QDF_STATUS_E_NOMEM;
6323 }
6324
6325 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6326 wmi_roam_mawc_params =
6327 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6328 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6329 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6330 WMITLV_GET_STRUCT_TLVLEN
6331 (wmi_roam_configure_mawc_cmd_fixed_param));
6332 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6333 if (params->enable)
6334 wmi_roam_mawc_params->enable = 1;
6335 else
6336 wmi_roam_mawc_params->enable = 0;
6337 wmi_roam_mawc_params->traffic_load_threshold =
6338 params->traffic_load_threshold;
6339 wmi_roam_mawc_params->best_ap_rssi_threshold =
6340 params->best_ap_rssi_threshold;
6341 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6342 params->rssi_stationary_high_adjust;
6343 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6344 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006345 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6346 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6347 wmi_roam_mawc_params->traffic_load_threshold,
6348 wmi_roam_mawc_params->best_ap_rssi_threshold,
6349 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6350 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006351
6352 status = wmi_unified_cmd_send(wmi_handle, buf,
6353 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6354 if (QDF_IS_STATUS_ERROR(status)) {
6355 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6356 status);
6357 wmi_buf_free(buf);
6358 return status;
6359 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006360
6361 return QDF_STATUS_SUCCESS;
6362}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306363
6364/**
6365 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6366 * rssi threashold
6367 * @wmi_handle: wmi handle
6368 * @roam_req: Roaming request buffer
6369 *
6370 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6371 *
6372 * Return: QDF status
6373 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306374static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306375 struct roam_offload_scan_rssi_params *roam_req)
6376{
6377 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306378 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306379 int len;
6380 uint8_t *buf_ptr;
6381 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6382 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6383 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306384 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006385 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306386
6387 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6388 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6389 len += sizeof(wmi_roam_scan_extended_threshold_param);
6390 len += WMI_TLV_HDR_SIZE;
6391 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306392 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6393 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006394 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6395 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306396 buf = wmi_buf_alloc(wmi_handle, len);
6397 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306398 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306399 return QDF_STATUS_E_NOMEM;
6400 }
6401
6402 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6403 rssi_threshold_fp =
6404 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6405 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6406 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6407 WMITLV_GET_STRUCT_TLVLEN
6408 (wmi_roam_scan_rssi_threshold_fixed_param));
6409 /* fill in threshold values */
6410 rssi_threshold_fp->vdev_id = roam_req->session_id;
6411 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6412 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6413 rssi_threshold_fp->hirssi_scan_max_count =
6414 roam_req->hi_rssi_scan_max_count;
6415 rssi_threshold_fp->hirssi_scan_delta =
6416 roam_req->hi_rssi_scan_rssi_delta;
6417 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006418 rssi_threshold_fp->rssi_thresh_offset_5g =
6419 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306420
6421 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6422 WMITLV_SET_HDR(buf_ptr,
6423 WMITLV_TAG_ARRAY_STRUC,
6424 sizeof(wmi_roam_scan_extended_threshold_param));
6425 buf_ptr += WMI_TLV_HDR_SIZE;
6426 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6427
6428 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6429 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6430 ext_thresholds->boost_threshold_5g =
6431 roam_req->boost_threshold_5g;
6432
6433 ext_thresholds->boost_algorithm_5g =
6434 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6435 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6436 ext_thresholds->penalty_algorithm_5g =
6437 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6438 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6439 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6440 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6441 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6442
6443 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6444 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6445 WMITLV_GET_STRUCT_TLVLEN
6446 (wmi_roam_scan_extended_threshold_param));
6447 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6448 WMITLV_SET_HDR(buf_ptr,
6449 WMITLV_TAG_ARRAY_STRUC,
6450 sizeof(wmi_roam_earlystop_rssi_thres_param));
6451 buf_ptr += WMI_TLV_HDR_SIZE;
6452 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6453 early_stop_thresholds->roam_earlystop_thres_min =
6454 roam_req->roam_earlystop_thres_min;
6455 early_stop_thresholds->roam_earlystop_thres_max =
6456 roam_req->roam_earlystop_thres_max;
6457 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6458 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6459 WMITLV_GET_STRUCT_TLVLEN
6460 (wmi_roam_earlystop_rssi_thres_param));
6461
Gupta, Kapil7e652922016-04-12 15:02:00 +05306462 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6464 sizeof(wmi_roam_dense_thres_param));
6465 buf_ptr += WMI_TLV_HDR_SIZE;
6466 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6467 dense_thresholds->roam_dense_rssi_thres_offset =
6468 roam_req->dense_rssi_thresh_offset;
6469 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6470 dense_thresholds->roam_dense_traffic_thres =
6471 roam_req->traffic_threshold;
6472 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6473 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6474 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6475 WMITLV_GET_STRUCT_TLVLEN
6476 (wmi_roam_dense_thres_param));
6477
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006478 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6479 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6480 sizeof(wmi_roam_bg_scan_roaming_param));
6481 buf_ptr += WMI_TLV_HDR_SIZE;
6482 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6483 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6484 roam_req->bg_scan_bad_rssi_thresh;
6485 bg_scan_params->roam_bg_scan_client_bitmap =
6486 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306487 bg_scan_params->bad_rssi_thresh_offset_2g =
6488 roam_req->roam_bad_rssi_thresh_offset_2g;
6489 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006490 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6491 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6492 WMITLV_GET_STRUCT_TLVLEN
6493 (wmi_roam_bg_scan_roaming_param));
6494
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306495 status = wmi_unified_cmd_send(wmi_handle, buf,
6496 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306497 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306498 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306499 status);
6500 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306501 }
6502
Govind Singh67922e82016-04-01 16:48:57 +05306503 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306504}
6505
6506/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306507 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6508 * configuration params
6509 * @wma_handle: wma handler
6510 * @dwelltime_params: pointer to dwelltime_params
6511 *
6512 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6513 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006514static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306515QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6516 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6517{
6518 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6519 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6520 wmi_buf_t buf;
6521 uint8_t *buf_ptr;
6522 int32_t err;
6523 int len;
6524
6525 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6526 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6527 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6528 buf = wmi_buf_alloc(wmi_handle, len);
6529 if (!buf) {
6530 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6531 __func__);
6532 return QDF_STATUS_E_NOMEM;
6533 }
6534 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6535 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6536 WMITLV_SET_HDR(&dwell_param->tlv_header,
6537 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6538 WMITLV_GET_STRUCT_TLVLEN
6539 (wmi_scan_adaptive_dwell_config_fixed_param));
6540
6541 dwell_param->enable = dwelltime_params->is_enabled;
6542 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6543 WMITLV_SET_HDR(buf_ptr,
6544 WMITLV_TAG_ARRAY_STRUC,
6545 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6546 buf_ptr += WMI_TLV_HDR_SIZE;
6547
6548 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6549 WMITLV_SET_HDR(&cmd->tlv_header,
6550 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6551 WMITLV_GET_STRUCT_TLVLEN(
6552 wmi_scan_adaptive_dwell_parameters_tlv));
6553
6554 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6555 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6556 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6557 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6558 err = wmi_unified_cmd_send(wmi_handle, buf,
6559 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6560 if (err) {
6561 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6562 wmi_buf_free(buf);
6563 return QDF_STATUS_E_FAILURE;
6564 }
6565
6566 return QDF_STATUS_SUCCESS;
6567}
6568
Nitesh Shah52323d02017-05-22 15:49:00 +05306569/**
6570 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6571 * configuration params
6572 * @wmi_handle: wmi handler
6573 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6574 *
6575 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6576 */
6577static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6578 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6579{
6580 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6581 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6582 wmi_buf_t buf;
6583 uint8_t *buf_ptr;
6584 QDF_STATUS err;
6585 uint32_t i;
6586 int len;
6587
6588 len = sizeof(*dbs_scan_param);
6589 len += WMI_TLV_HDR_SIZE;
6590 len += dbs_scan_params->num_clients * sizeof(*cmd);
6591
6592 buf = wmi_buf_alloc(wmi_handle, len);
6593 if (!buf) {
6594 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6595 return QDF_STATUS_E_NOMEM;
6596 }
6597
6598 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6599 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6600 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6601 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6602 WMITLV_GET_STRUCT_TLVLEN
6603 (wmi_scan_dbs_duty_cycle_fixed_param));
6604
6605 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6606 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6607 buf_ptr += sizeof(*dbs_scan_param);
6608 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6609 (sizeof(*cmd) * dbs_scan_params->num_clients));
6610 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6611
6612 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6613 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6614 WMITLV_SET_HDR(&cmd->tlv_header,
6615 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6616 WMITLV_GET_STRUCT_TLVLEN(
6617 wmi_scan_dbs_duty_cycle_tlv_param));
6618 cmd->module_id = dbs_scan_params->module_id[i];
6619 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6620 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6621 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6622 }
6623
6624 err = wmi_unified_cmd_send(wmi_handle, buf,
6625 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6626 if (QDF_IS_STATUS_ERROR(err)) {
6627 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6628 wmi_buf_free(buf);
6629 return QDF_STATUS_E_FAILURE;
6630 }
6631
6632 return QDF_STATUS_SUCCESS;
6633}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306634
6635/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306636 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6637 * @wmi_handle: wmi handle
6638 * @roam_req: Request which contains the filters
6639 *
6640 * There are filters such as whitelist, blacklist and preferred
6641 * list that need to be applied to the scan results to form the
6642 * probable candidates for roaming.
6643 *
6644 * Return: Return success upon succesfully passing the
6645 * parameters to the firmware, otherwise failure.
6646 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306647static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306648 struct roam_scan_filter_params *roam_req)
6649{
6650 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306651 QDF_STATUS status;
6652 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306653 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306654 uint8_t *buf_ptr;
6655 wmi_roam_filter_fixed_param *roam_filter;
6656 uint8_t *bssid_src_ptr = NULL;
6657 wmi_mac_addr *bssid_dst_ptr = NULL;
6658 wmi_ssid *ssid_ptr = NULL;
6659 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306660 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306661 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306662
6663 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306664
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306665 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306666 if (roam_req->num_bssid_black_list)
6667 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6668 len += WMI_TLV_HDR_SIZE;
6669 if (roam_req->num_ssid_white_list)
6670 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6671 len += 2 * WMI_TLV_HDR_SIZE;
6672 if (roam_req->num_bssid_preferred_list) {
6673 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6674 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6675 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306676 len += WMI_TLV_HDR_SIZE;
6677 if (roam_req->lca_disallow_config_present) {
6678 len += sizeof(*blist_param);
6679 blist_len = sizeof(*blist_param);
6680 }
6681
6682 len += WMI_TLV_HDR_SIZE;
6683 if (roam_req->num_rssi_rejection_ap)
6684 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306685
6686 buf = wmi_buf_alloc(wmi_handle, len);
6687 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306688 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306689 return QDF_STATUS_E_NOMEM;
6690 }
6691
6692 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6693 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6694 WMITLV_SET_HDR(&roam_filter->tlv_header,
6695 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6696 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6697 /* fill in fixed values */
6698 roam_filter->vdev_id = roam_req->session_id;
6699 roam_filter->flags = 0;
6700 roam_filter->op_bitmap = roam_req->op_bitmap;
6701 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6702 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6703 roam_filter->num_bssid_preferred_list =
6704 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306705 roam_filter->num_rssi_rejection_ap =
6706 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306707 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6708
6709 WMITLV_SET_HDR((buf_ptr),
6710 WMITLV_TAG_ARRAY_FIXED_STRUC,
6711 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6712 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6713 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6714 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6715 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6716 bssid_src_ptr += ATH_MAC_LEN;
6717 bssid_dst_ptr++;
6718 }
6719 buf_ptr += WMI_TLV_HDR_SIZE +
6720 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6721 WMITLV_SET_HDR((buf_ptr),
6722 WMITLV_TAG_ARRAY_FIXED_STRUC,
6723 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6724 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6725 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6726 qdf_mem_copy(&ssid_ptr->ssid,
6727 &roam_req->ssid_allowed_list[i].mac_ssid,
6728 roam_req->ssid_allowed_list[i].length);
6729 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6730 ssid_ptr++;
6731 }
6732 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6733 sizeof(wmi_ssid));
6734 WMITLV_SET_HDR((buf_ptr),
6735 WMITLV_TAG_ARRAY_FIXED_STRUC,
6736 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6737 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6738 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6739 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6740 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6741 (wmi_mac_addr *)bssid_dst_ptr);
6742 bssid_src_ptr += ATH_MAC_LEN;
6743 bssid_dst_ptr++;
6744 }
6745 buf_ptr += WMI_TLV_HDR_SIZE +
6746 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6747 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6748 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6749 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6750 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6751 *bssid_preferred_factor_ptr =
6752 roam_req->bssid_favored_factor[i];
6753 bssid_preferred_factor_ptr++;
6754 }
6755 buf_ptr += WMI_TLV_HDR_SIZE +
6756 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6757
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306758 WMITLV_SET_HDR(buf_ptr,
6759 WMITLV_TAG_ARRAY_STRUC, blist_len);
6760 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306761 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306762 blist_param =
6763 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6764 WMITLV_SET_HDR(&blist_param->tlv_header,
6765 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6766 WMITLV_GET_STRUCT_TLVLEN(
6767 wmi_roam_lca_disallow_config_tlv_param));
6768
6769 blist_param->disallow_duration = roam_req->disallow_duration;
6770 blist_param->rssi_channel_penalization =
6771 roam_req->rssi_channel_penalization;
6772 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306773 blist_param->disallow_lca_enable_source_bitmap =
6774 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6775 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306776 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6777 }
6778
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306779 WMITLV_SET_HDR(buf_ptr,
6780 WMITLV_TAG_ARRAY_STRUC,
6781 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6782 buf_ptr += WMI_TLV_HDR_SIZE;
6783 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6784 rssi_rej =
6785 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6786 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6787 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6788 WMITLV_GET_STRUCT_TLVLEN(
6789 wmi_roam_rssi_rejection_oce_config_param));
6790 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6791 roam_req->rssi_rejection_ap[i].bssid.bytes,
6792 &rssi_rej->bssid);
6793 rssi_rej->remaining_disallow_duration =
6794 roam_req->rssi_rejection_ap[i].remaining_duration;
6795 rssi_rej->requested_rssi =
6796 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6797 buf_ptr +=
6798 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6799 }
6800
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306801 status = wmi_unified_cmd_send(wmi_handle, buf,
6802 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306803 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306804 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306805 status);
6806 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306807 }
Govind Singh67922e82016-04-01 16:48:57 +05306808
6809 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306810}
6811
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306812#if defined(WLAN_FEATURE_FILS_SK)
6813static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
6814 struct hlp_params *params)
6815{
6816 uint32_t len;
6817 uint8_t *buf_ptr;
6818 wmi_buf_t buf = NULL;
6819 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
6820
6821 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
6822 len += WMI_TLV_HDR_SIZE;
6823 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
6824
6825 buf = wmi_buf_alloc(wmi_handle, len);
6826 if (!buf) {
6827 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6828 return QDF_STATUS_E_NOMEM;
6829 }
6830
6831 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6832 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
6833 WMITLV_SET_HDR(&hlp_params->tlv_header,
6834 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
6835 WMITLV_GET_STRUCT_TLVLEN(
6836 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
6837
6838 hlp_params->vdev_id = params->vdev_id;
6839 hlp_params->size = params->hlp_ie_len;
6840 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
6841
6842 buf_ptr += sizeof(*hlp_params);
6843
6844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6845 round_up(params->hlp_ie_len,
6846 sizeof(uint32_t)));
6847 buf_ptr += WMI_TLV_HDR_SIZE;
6848 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
6849
6850 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
6851 hlp_params->vdev_id, hlp_params->size);
6852 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6853 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
6854 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
6855 wmi_buf_free(buf);
6856 return QDF_STATUS_E_FAILURE;
6857 }
6858
6859 return QDF_STATUS_SUCCESS;
6860}
6861#endif
6862
Govind Singh4eacd2b2016-03-07 14:24:22 +05306863/** send_set_epno_network_list_cmd_tlv() - set epno network list
6864 * @wmi_handle: wmi handle
6865 * @req: epno config params request structure
6866 *
6867 * This function reads the incoming epno config request structure
6868 * and constructs the WMI message to the firmware.
6869 *
6870 * Returns: 0 on success, error number otherwise
6871 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306872static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306873 struct wifi_enhanched_pno_params *req)
6874{
6875 wmi_nlo_config_cmd_fixed_param *cmd;
6876 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306877 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306878 u_int8_t i, *buf_ptr;
6879 wmi_buf_t buf;
6880 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306881 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306882
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306883 /* Fixed Params */
6884 len = sizeof(*cmd);
6885 if (req->num_networks) {
6886 /* TLV place holder for array of structures
6887 * then each nlo_configured_parameters(nlo_list) TLV.
6888 */
6889 len += WMI_TLV_HDR_SIZE;
6890 len += (sizeof(nlo_configured_parameters)
6891 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6892 /* TLV for array of uint32 channel_list */
6893 len += WMI_TLV_HDR_SIZE;
6894 /* TLV for nlo_channel_prediction_cfg */
6895 len += WMI_TLV_HDR_SIZE;
6896 /* TLV for candidate score params */
6897 len += sizeof(enlo_candidate_score_params);
6898 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306899
6900 buf = wmi_buf_alloc(wmi_handle, len);
6901 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306902 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6903 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306904 }
6905
6906 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6907
6908 buf_ptr = (u_int8_t *) cmd;
6909 WMITLV_SET_HDR(&cmd->tlv_header,
6910 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6911 WMITLV_GET_STRUCT_TLVLEN(
6912 wmi_nlo_config_cmd_fixed_param));
6913 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306914
6915 /* set flag to reset if num of networks are 0 */
6916 cmd->flags = (req->num_networks == 0 ?
6917 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918
6919 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6920
Govind Singhb53420c2016-03-09 14:32:57 +05306921 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306922 WMI_LOGD("SSID count: %d flags: %d",
6923 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306924
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306925 /* Fill nlo_config only when num_networks are non zero */
6926 if (cmd->no_of_ssids) {
6927 /* Fill networks */
6928 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6929 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6930 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306931
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306932 nlo_list = (nlo_configured_parameters *) buf_ptr;
6933 for (i = 0; i < cmd->no_of_ssids; i++) {
6934 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6935 WMITLV_TAG_ARRAY_BYTE,
6936 WMITLV_GET_STRUCT_TLVLEN(
6937 nlo_configured_parameters));
6938 /* Copy ssid and it's length */
6939 nlo_list[i].ssid.valid = true;
6940 nlo_list[i].ssid.ssid.ssid_len =
6941 req->networks[i].ssid.length;
6942 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6943 req->networks[i].ssid.mac_ssid,
6944 nlo_list[i].ssid.ssid.ssid_len);
6945 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6946 nlo_list[i].ssid.ssid.ssid_len,
6947 (char *) nlo_list[i].ssid.ssid.ssid,
6948 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306949
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306950 /* Copy pno flags */
6951 nlo_list[i].bcast_nw_type.valid = true;
6952 nlo_list[i].bcast_nw_type.bcast_nw_type =
6953 req->networks[i].flags;
6954 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306955 nlo_list[i].bcast_nw_type.bcast_nw_type);
6956
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306957 /* Copy auth bit field */
6958 nlo_list[i].auth_type.valid = true;
6959 nlo_list[i].auth_type.auth_type =
6960 req->networks[i].auth_bit_field;
6961 WMI_LOGD("Auth bit field (%u)",
6962 nlo_list[i].auth_type.auth_type);
6963 }
6964
6965 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6966 /* Fill the channel list */
6967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6968 buf_ptr += WMI_TLV_HDR_SIZE;
6969
6970 /* Fill prediction_param */
6971 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6972 buf_ptr += WMI_TLV_HDR_SIZE;
6973
6974 /* Fill epno candidate score params */
6975 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6976 WMITLV_SET_HDR(buf_ptr,
6977 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6978 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6979 cand_score_params->min5GHz_rssi =
6980 req->min_5ghz_rssi;
6981 cand_score_params->min24GHz_rssi =
6982 req->min_24ghz_rssi;
6983 cand_score_params->initial_score_max =
6984 req->initial_score_max;
6985 cand_score_params->current_connection_bonus =
6986 req->current_connection_bonus;
6987 cand_score_params->same_network_bonus =
6988 req->same_network_bonus;
6989 cand_score_params->secure_bonus =
6990 req->secure_bonus;
6991 cand_score_params->band5GHz_bonus =
6992 req->band_5ghz_bonus;
6993 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306994 }
6995
Govind Singh4eacd2b2016-03-07 14:24:22 +05306996 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306997 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306998 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306999 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307000 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307001 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307002 }
7003
Govind Singhb53420c2016-03-09 14:32:57 +05307004 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307005 req->session_id);
7006
Govind Singh67922e82016-04-01 16:48:57 +05307007 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307008}
7009
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307010
Govind Singh4eacd2b2016-03-07 14:24:22 +05307011/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7012 * @wmi_handle: wmi handle
7013 * @ipa_offload: ipa offload control parameter
7014 *
7015 * Returns: 0 on success, error number otherwise
7016 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307017static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307018 struct ipa_offload_control_params *ipa_offload)
7019{
7020 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7021 wmi_buf_t wmi_buf;
7022 uint32_t len;
7023 u_int8_t *buf_ptr;
7024
7025 len = sizeof(*cmd);
7026 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7027 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307028 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7029 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307030 }
7031
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007032 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307033 ipa_offload->offload_type, ipa_offload->enable);
7034
7035 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7036
7037 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7038 WMITLV_SET_HDR(&cmd->tlv_header,
7039 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7040 WMITLV_GET_STRUCT_TLVLEN(
7041 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7042
7043 cmd->offload_type = ipa_offload->offload_type;
7044 cmd->vdev_id = ipa_offload->vdev_id;
7045 cmd->enable = ipa_offload->enable;
7046
7047 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7048 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307049 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307050 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307051 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307052 }
7053
Govind Singhb53420c2016-03-09 14:32:57 +05307054 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307055}
7056
7057/**
7058 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7059 * @wmi_handle: wmi handle
7060 * @pgetcapab: get capabilities params
7061 *
7062 * This function send request to fw to get extscan capabilities.
7063 *
7064 * Return: CDF status
7065 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307066static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307067 struct extscan_capabilities_params *pgetcapab)
7068{
7069 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7070 wmi_buf_t wmi_buf;
7071 uint32_t len;
7072 uint8_t *buf_ptr;
7073
7074 len = sizeof(*cmd);
7075 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7076 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307077 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7078 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079 }
7080 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7081
7082 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7083 WMITLV_SET_HDR(&cmd->tlv_header,
7084 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7085 WMITLV_GET_STRUCT_TLVLEN
7086 (wmi_extscan_get_capabilities_cmd_fixed_param));
7087
7088 cmd->request_id = pgetcapab->request_id;
7089
7090 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7091 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307092 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307093 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307094 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307095 }
Govind Singhb53420c2016-03-09 14:32:57 +05307096 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307097}
7098
7099/**
7100 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7101 * @wmi_handle: wmi handle
7102 * @pcached_results: cached results parameters
7103 *
7104 * This function send request to fw to get cached results.
7105 *
7106 * Return: CDF status
7107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307108static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307109 struct extscan_cached_result_params *pcached_results)
7110{
7111 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7112 wmi_buf_t wmi_buf;
7113 uint32_t len;
7114 uint8_t *buf_ptr;
7115
7116 len = sizeof(*cmd);
7117 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7118 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307119 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7120 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307121 }
7122 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7123
7124 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7125 WMITLV_SET_HDR(&cmd->tlv_header,
7126 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7127 WMITLV_GET_STRUCT_TLVLEN
7128 (wmi_extscan_get_cached_results_cmd_fixed_param));
7129
7130 cmd->request_id = pcached_results->request_id;
7131 cmd->vdev_id = pcached_results->session_id;
7132 cmd->control_flags = pcached_results->flush;
7133
7134 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7135 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307136 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307137 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307138 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307139 }
Govind Singhb53420c2016-03-09 14:32:57 +05307140 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307141}
7142
7143/**
7144 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7145 * @wmi_handle: wmi handle
7146 * @reset_req: Reset change request params
7147 *
7148 * This function sends stop change monitor request to fw.
7149 *
7150 * Return: CDF status
7151 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307152static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307153 struct extscan_capabilities_reset_params *reset_req)
7154{
7155 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7156 wmi_buf_t wmi_buf;
7157 uint32_t len;
7158 uint8_t *buf_ptr;
7159 int change_list = 0;
7160
7161 len = sizeof(*cmd);
7162
7163 /* reset significant change tlv is set to 0 */
7164 len += WMI_TLV_HDR_SIZE;
7165 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7166 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7167 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307168 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7169 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307170 }
7171 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7172
7173 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7174 buf_ptr;
7175 WMITLV_SET_HDR(&cmd->tlv_header,
7176 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7177 WMITLV_GET_STRUCT_TLVLEN
7178 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7179
7180 cmd->request_id = reset_req->request_id;
7181 cmd->vdev_id = reset_req->session_id;
7182 cmd->mode = 0;
7183
7184 buf_ptr += sizeof(*cmd);
7185 WMITLV_SET_HDR(buf_ptr,
7186 WMITLV_TAG_ARRAY_STRUC,
7187 change_list *
7188 sizeof(wmi_extscan_wlan_change_bssid_param));
7189 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7190 sizeof
7191 (wmi_extscan_wlan_change_bssid_param));
7192
7193 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7194 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307195 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307196 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307197 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307198 }
Govind Singhb53420c2016-03-09 14:32:57 +05307199 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307200}
7201
7202/**
7203 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7204 * @wmi_handle: wmi handle
7205 * @psigchange: change monitor request params
7206 * @buf: wmi buffer
7207 * @buf_len: buffer length
7208 *
7209 * This function fills elements of change monitor request buffer.
7210 *
7211 * Return: CDF status
7212 */
Govind Singhb53420c2016-03-09 14:32:57 +05307213static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307214 struct extscan_set_sig_changereq_params
7215 *psigchange, wmi_buf_t *buf, int *buf_len)
7216{
7217 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7218 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7219 uint8_t *buf_ptr;
7220 int j;
7221 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007222 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307223 struct ap_threshold_params *src_ap = psigchange->ap;
7224
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007225 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307226 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7227 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307228 }
7229 len += WMI_TLV_HDR_SIZE;
7230 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7231
7232 *buf = wmi_buf_alloc(wmi_handle, len);
7233 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307234 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307235 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307236 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307237 }
7238 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7239 cmd =
7240 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7241 buf_ptr;
7242 WMITLV_SET_HDR(&cmd->tlv_header,
7243 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7244 WMITLV_GET_STRUCT_TLVLEN
7245 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7246
7247 cmd->request_id = psigchange->request_id;
7248 cmd->vdev_id = psigchange->session_id;
7249 cmd->total_entries = numap;
7250 cmd->mode = 1;
7251 cmd->num_entries_in_page = numap;
7252 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7253 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7254 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7255 cmd->max_out_of_range_count = psigchange->min_breaching;
7256
7257 buf_ptr += sizeof(*cmd);
7258 WMITLV_SET_HDR(buf_ptr,
7259 WMITLV_TAG_ARRAY_STRUC,
7260 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7261 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7262 (buf_ptr + WMI_TLV_HDR_SIZE);
7263
7264 for (j = 0; j < numap; j++) {
7265 WMITLV_SET_HDR(dest_chglist,
7266 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7267 WMITLV_GET_STRUCT_TLVLEN
7268 (wmi_extscan_wlan_change_bssid_param));
7269
7270 dest_chglist->lower_rssi_limit = src_ap->low;
7271 dest_chglist->upper_rssi_limit = src_ap->high;
7272 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7273 &dest_chglist->bssid);
7274
Govind Singhb53420c2016-03-09 14:32:57 +05307275 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307276 dest_chglist->lower_rssi_limit);
7277 dest_chglist++;
7278 src_ap++;
7279 }
7280 buf_ptr += WMI_TLV_HDR_SIZE +
7281 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7282 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307283 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307284}
7285
7286/**
7287 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7288 * @wmi_handle: wmi handle
7289 * @psigchange: change monitor request params
7290 *
7291 * This function sends start change monitor request to fw.
7292 *
7293 * Return: CDF status
7294 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307295static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307296 struct extscan_set_sig_changereq_params *
7297 psigchange)
7298{
Govind Singhb53420c2016-03-09 14:32:57 +05307299 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307300 wmi_buf_t buf;
7301 int len;
7302
7303
Govind Singhb53420c2016-03-09 14:32:57 +05307304 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307305 psigchange, &buf,
7306 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307307 if (qdf_status != QDF_STATUS_SUCCESS) {
7308 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307309 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307310 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307311 }
7312 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307313 WMI_LOGE("%s: Failed to get buffer", __func__);
7314 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307315 }
7316 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7317 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307318 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307319 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307320 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307321 }
Govind Singhb53420c2016-03-09 14:32:57 +05307322 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307323}
7324
7325/**
7326 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7327 * @wmi_handle: wmi handle
7328 * @photlist_reset: hotlist reset params
7329 *
7330 * This function configures hotlist monitor to stop in fw.
7331 *
7332 * Return: CDF status
7333 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307334static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307335 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7336{
7337 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7338 wmi_buf_t wmi_buf;
7339 uint32_t len;
7340 uint8_t *buf_ptr;
7341 int hotlist_entries = 0;
7342
7343 len = sizeof(*cmd);
7344
7345 /* reset bssid hotlist with tlv set to 0 */
7346 len += WMI_TLV_HDR_SIZE;
7347 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7348
7349 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7350 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307351 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7352 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307353 }
7354
7355 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7356 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7357 buf_ptr;
7358 WMITLV_SET_HDR(&cmd->tlv_header,
7359 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7360 WMITLV_GET_STRUCT_TLVLEN
7361 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7362
7363 cmd->request_id = photlist_reset->request_id;
7364 cmd->vdev_id = photlist_reset->session_id;
7365 cmd->mode = 0;
7366
7367 buf_ptr += sizeof(*cmd);
7368 WMITLV_SET_HDR(buf_ptr,
7369 WMITLV_TAG_ARRAY_STRUC,
7370 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7371 buf_ptr += WMI_TLV_HDR_SIZE +
7372 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7373
7374 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7375 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307376 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307377 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307378 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307379 }
Govind Singhb53420c2016-03-09 14:32:57 +05307380 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307381}
7382
7383/**
7384 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7385 * @wmi_handle: wmi handle
7386 * @pstopcmd: stop scan command request params
7387 *
7388 * This function sends stop extscan request to fw.
7389 *
7390 * Return: CDF Status.
7391 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307392static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307393 struct extscan_stop_req_params *pstopcmd)
7394{
7395 wmi_extscan_stop_cmd_fixed_param *cmd;
7396 wmi_buf_t wmi_buf;
7397 uint32_t len;
7398 uint8_t *buf_ptr;
7399
7400 len = sizeof(*cmd);
7401 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7402 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307403 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7404 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307405 }
7406 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7407 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7408 WMITLV_SET_HDR(&cmd->tlv_header,
7409 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7410 WMITLV_GET_STRUCT_TLVLEN
7411 (wmi_extscan_stop_cmd_fixed_param));
7412
7413 cmd->request_id = pstopcmd->request_id;
7414 cmd->vdev_id = pstopcmd->session_id;
7415
7416 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7417 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307418 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307419 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307420 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307421 }
7422
Govind Singhb53420c2016-03-09 14:32:57 +05307423 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307424}
7425
7426/**
7427 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7428 * @wmi_handle: wmi handle
7429 * @pstart: scan command request params
7430 * @buf: event buffer
7431 * @buf_len: length of buffer
7432 *
7433 * This function fills individual elements of extscan request and
7434 * TLV for buckets, channel list.
7435 *
7436 * Return: CDF Status.
7437 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007438static
Govind Singhb53420c2016-03-09 14:32:57 +05307439QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307440 struct wifi_scan_cmd_req_params *pstart,
7441 wmi_buf_t *buf, int *buf_len)
7442{
7443 wmi_extscan_start_cmd_fixed_param *cmd;
7444 wmi_extscan_bucket *dest_blist;
7445 wmi_extscan_bucket_channel *dest_clist;
7446 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7447 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7448 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7449
7450 uint8_t *buf_ptr;
7451 int i, k, count = 0;
7452 int len = sizeof(*cmd);
7453 int nbuckets = pstart->numBuckets;
7454 int nchannels = 0;
7455
7456 /* These TLV's are are NULL by default */
7457 uint32_t ie_len_with_pad = 0;
7458 int num_ssid = 0;
7459 int num_bssid = 0;
7460 int ie_len = 0;
7461
7462 uint32_t base_period = pstart->basePeriod;
7463
7464 /* TLV placeholder for ssid_list (NULL) */
7465 len += WMI_TLV_HDR_SIZE;
7466 len += num_ssid * sizeof(wmi_ssid);
7467
7468 /* TLV placeholder for bssid_list (NULL) */
7469 len += WMI_TLV_HDR_SIZE;
7470 len += num_bssid * sizeof(wmi_mac_addr);
7471
7472 /* TLV placeholder for ie_data (NULL) */
7473 len += WMI_TLV_HDR_SIZE;
7474 len += ie_len * sizeof(uint32_t);
7475
7476 /* TLV placeholder for bucket */
7477 len += WMI_TLV_HDR_SIZE;
7478 len += nbuckets * sizeof(wmi_extscan_bucket);
7479
7480 /* TLV channel placeholder */
7481 len += WMI_TLV_HDR_SIZE;
7482 for (i = 0; i < nbuckets; i++) {
7483 nchannels += src_bucket->numChannels;
7484 src_bucket++;
7485 }
7486
Govind Singhb53420c2016-03-09 14:32:57 +05307487 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307488 __func__, nbuckets, nchannels);
7489 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7490 /* Allocate the memory */
7491 *buf = wmi_buf_alloc(wmi_handle, len);
7492 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307493 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307494 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307495 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307496 }
7497 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7498 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7499 WMITLV_SET_HDR(&cmd->tlv_header,
7500 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7501 WMITLV_GET_STRUCT_TLVLEN
7502 (wmi_extscan_start_cmd_fixed_param));
7503
7504 cmd->request_id = pstart->requestId;
7505 cmd->vdev_id = pstart->sessionId;
7506 cmd->base_period = pstart->basePeriod;
7507 cmd->num_buckets = nbuckets;
7508 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307509 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307510 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307511 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307512 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307513#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307514 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7515 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307516 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7517 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7518#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7520
7521 /* The max dwell time is retrieved from the first channel
7522 * of the first bucket and kept common for all channels.
7523 */
7524 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7525 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7526 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7527 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7528 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7529 cmd->max_table_usage = pstart->report_threshold_percent;
7530 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7531
7532 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307533 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307534 cmd->probe_delay = 0;
7535 cmd->probe_spacing_time = 0;
7536 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307537 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7538 WMI_SCAN_ADD_CCK_RATES |
7539 WMI_SCAN_ADD_OFDM_RATES |
7540 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7541 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307542 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7543 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307544 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307545 cmd->num_ssids = 0;
7546 cmd->num_bssid = 0;
7547 cmd->ie_len = 0;
7548 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7549 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7550
7551 buf_ptr += sizeof(*cmd);
7552 WMITLV_SET_HDR(buf_ptr,
7553 WMITLV_TAG_ARRAY_FIXED_STRUC,
7554 num_ssid * sizeof(wmi_ssid));
7555 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7556
7557 WMITLV_SET_HDR(buf_ptr,
7558 WMITLV_TAG_ARRAY_FIXED_STRUC,
7559 num_bssid * sizeof(wmi_mac_addr));
7560 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7561
7562 ie_len_with_pad = 0;
7563 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7564 ie_len_with_pad);
7565 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7566
7567 WMITLV_SET_HDR(buf_ptr,
7568 WMITLV_TAG_ARRAY_STRUC,
7569 nbuckets * sizeof(wmi_extscan_bucket));
7570 dest_blist = (wmi_extscan_bucket *)
7571 (buf_ptr + WMI_TLV_HDR_SIZE);
7572 src_bucket = pstart->buckets;
7573
7574 /* Retrieve scanning information from each bucket and
7575 * channels and send it to the target
7576 */
7577 for (i = 0; i < nbuckets; i++) {
7578 WMITLV_SET_HDR(dest_blist,
7579 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7580 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7581
7582 dest_blist->bucket_id = src_bucket->bucket;
7583 dest_blist->base_period_multiplier =
7584 src_bucket->period / base_period;
7585 dest_blist->min_period = src_bucket->period;
7586 dest_blist->max_period = src_bucket->max_period;
7587 dest_blist->exp_backoff = src_bucket->exponent;
7588 dest_blist->exp_max_step_count = src_bucket->step_count;
7589 dest_blist->channel_band = src_bucket->band;
7590 dest_blist->num_channels = src_bucket->numChannels;
7591 dest_blist->notify_extscan_events = 0;
7592
7593 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7594 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007595 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7596 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307597
7598 if (src_bucket->reportEvents &
7599 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7600 dest_blist->forwarding_flags =
7601 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7602 dest_blist->notify_extscan_events |=
7603 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7604 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7605 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7606 } else {
7607 dest_blist->forwarding_flags =
7608 WMI_EXTSCAN_NO_FORWARDING;
7609 }
7610
7611 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7612 dest_blist->configuration_flags = 0;
7613 else
7614 dest_blist->configuration_flags =
7615 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7616
Govind Singhb53420c2016-03-09 14:32:57 +05307617 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618 __func__, dest_blist->notify_extscan_events,
7619 dest_blist->configuration_flags,
7620 dest_blist->forwarding_flags);
7621
7622 dest_blist->min_dwell_time_active =
7623 src_bucket->min_dwell_time_active;
7624 dest_blist->max_dwell_time_active =
7625 src_bucket->max_dwell_time_active;
7626 dest_blist->min_dwell_time_passive =
7627 src_bucket->min_dwell_time_passive;
7628 dest_blist->max_dwell_time_passive =
7629 src_bucket->max_dwell_time_passive;
7630 src_channel = src_bucket->channels;
7631
7632 /* save the channel info to later populate
7633 * the channel TLV
7634 */
7635 for (k = 0; k < src_bucket->numChannels; k++) {
7636 save_channel[count++].channel = src_channel->channel;
7637 src_channel++;
7638 }
7639 dest_blist++;
7640 src_bucket++;
7641 }
7642 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7643 WMITLV_SET_HDR(buf_ptr,
7644 WMITLV_TAG_ARRAY_STRUC,
7645 nchannels * sizeof(wmi_extscan_bucket_channel));
7646 dest_clist = (wmi_extscan_bucket_channel *)
7647 (buf_ptr + WMI_TLV_HDR_SIZE);
7648
7649 /* Active or passive scan is based on the bucket dwell time
7650 * and channel specific active,passive scans are not
7651 * supported yet
7652 */
7653 for (i = 0; i < nchannels; i++) {
7654 WMITLV_SET_HDR(dest_clist,
7655 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7656 WMITLV_GET_STRUCT_TLVLEN
7657 (wmi_extscan_bucket_channel));
7658 dest_clist->channel = save_channel[i].channel;
7659 dest_clist++;
7660 }
7661 buf_ptr += WMI_TLV_HDR_SIZE +
7662 (nchannels * sizeof(wmi_extscan_bucket_channel));
7663 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307664 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307665}
7666
7667/**
7668 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7669 * @wmi_handle: wmi handle
7670 * @pstart: scan command request params
7671 *
7672 * This function sends start extscan request to fw.
7673 *
7674 * Return: CDF Status.
7675 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307676static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307677 struct wifi_scan_cmd_req_params *pstart)
7678{
Govind Singhb53420c2016-03-09 14:32:57 +05307679 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307680 wmi_buf_t buf;
7681 int len;
7682
7683 /* Fill individual elements of extscan request and
7684 * TLV for buckets, channel list.
7685 */
Govind Singhb53420c2016-03-09 14:32:57 +05307686 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307687 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307688 if (qdf_status != QDF_STATUS_SUCCESS) {
7689 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7690 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307691 }
7692 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307693 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307694 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307695 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307696 }
7697 if (wmi_unified_cmd_send(wmi_handle, buf,
7698 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307699 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307700 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307701 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307702 }
7703
Govind Singhb53420c2016-03-09 14:32:57 +05307704 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307705}
7706
7707/**
7708 * send_plm_stop_cmd_tlv() - plm stop request
7709 * @wmi_handle: wmi handle
7710 * @plm: plm request parameters
7711 *
7712 * This function request FW to stop PLM.
7713 *
7714 * Return: CDF status
7715 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307716static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307717 const struct plm_req_params *plm)
7718{
7719 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7720 int32_t len;
7721 wmi_buf_t buf;
7722 uint8_t *buf_ptr;
7723 int ret;
7724
7725 len = sizeof(*cmd);
7726 buf = wmi_buf_alloc(wmi_handle, len);
7727 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307728 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7729 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307730 }
7731
7732 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7733
7734 buf_ptr = (uint8_t *) cmd;
7735
7736 WMITLV_SET_HDR(&cmd->tlv_header,
7737 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7738 WMITLV_GET_STRUCT_TLVLEN
7739 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7740
7741 cmd->vdev_id = plm->session_id;
7742
7743 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307744 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307745
7746 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7747 WMI_VDEV_PLMREQ_STOP_CMDID);
7748 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307749 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307750 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307751 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307752 }
7753
Govind Singhb53420c2016-03-09 14:32:57 +05307754 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307755}
7756
7757/**
7758 * send_plm_start_cmd_tlv() - plm start request
7759 * @wmi_handle: wmi handle
7760 * @plm: plm request parameters
7761 *
7762 * This function request FW to start PLM.
7763 *
7764 * Return: CDF status
7765 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307766static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307767 const struct plm_req_params *plm,
7768 uint32_t *gchannel_list)
7769{
7770 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7771 uint32_t *channel_list;
7772 int32_t len;
7773 wmi_buf_t buf;
7774 uint8_t *buf_ptr;
7775 uint8_t count;
7776 int ret;
7777
7778 /* TLV place holder for channel_list */
7779 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7780 len += sizeof(uint32_t) * plm->plm_num_ch;
7781
7782 buf = wmi_buf_alloc(wmi_handle, len);
7783 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307784 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7785 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307786 }
7787 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7788
7789 buf_ptr = (uint8_t *) cmd;
7790
7791 WMITLV_SET_HDR(&cmd->tlv_header,
7792 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7793 WMITLV_GET_STRUCT_TLVLEN
7794 (wmi_vdev_plmreq_start_cmd_fixed_param));
7795
7796 cmd->vdev_id = plm->session_id;
7797
7798 cmd->meas_token = plm->meas_token;
7799 cmd->dialog_token = plm->diag_token;
7800 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307801 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307802 cmd->off_duration = plm->meas_duration;
7803 cmd->burst_cycle = plm->burst_len;
7804 cmd->tx_power = plm->desired_tx_pwr;
7805 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7806 cmd->num_chans = plm->plm_num_ch;
7807
7808 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7809
Govind Singhb53420c2016-03-09 14:32:57 +05307810 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7811 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7812 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7813 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7814 WMI_LOGD("off_duration: %d", cmd->off_duration);
7815 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7816 WMI_LOGD("tx_power: %d", cmd->tx_power);
7817 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307818
7819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7820 (cmd->num_chans * sizeof(uint32_t)));
7821
7822 buf_ptr += WMI_TLV_HDR_SIZE;
7823 if (cmd->num_chans) {
7824 channel_list = (uint32_t *) buf_ptr;
7825 for (count = 0; count < cmd->num_chans; count++) {
7826 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307827 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307828 channel_list[count] =
7829 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307830 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307831 }
7832 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7833 }
7834
7835 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7836 WMI_VDEV_PLMREQ_START_CMDID);
7837 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307838 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307840 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307841 }
7842
Govind Singhb53420c2016-03-09 14:32:57 +05307843 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307844}
7845
7846/**
7847 * send_pno_stop_cmd_tlv() - PNO stop request
7848 * @wmi_handle: wmi handle
7849 * @vdev_id: vdev id
7850 *
7851 * This function request FW to stop ongoing PNO operation.
7852 *
7853 * Return: CDF status
7854 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307855static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307856{
7857 wmi_nlo_config_cmd_fixed_param *cmd;
7858 int32_t len = sizeof(*cmd);
7859 wmi_buf_t buf;
7860 uint8_t *buf_ptr;
7861 int ret;
7862
7863 /*
7864 * TLV place holder for array of structures nlo_configured_parameters
7865 * TLV place holder for array of uint32_t channel_list
7866 * TLV place holder for chnl prediction cfg
7867 */
7868 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7869 buf = wmi_buf_alloc(wmi_handle, len);
7870 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307871 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7872 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307873 }
7874
7875 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7876 buf_ptr = (uint8_t *) cmd;
7877
7878 WMITLV_SET_HDR(&cmd->tlv_header,
7879 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7880 WMITLV_GET_STRUCT_TLVLEN
7881 (wmi_nlo_config_cmd_fixed_param));
7882
7883 cmd->vdev_id = vdev_id;
7884 cmd->flags = WMI_NLO_CONFIG_STOP;
7885 buf_ptr += sizeof(*cmd);
7886
7887 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7888 buf_ptr += WMI_TLV_HDR_SIZE;
7889
7890 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7891 buf_ptr += WMI_TLV_HDR_SIZE;
7892
7893 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7894 buf_ptr += WMI_TLV_HDR_SIZE;
7895
7896
7897 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7898 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7899 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307900 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307901 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307902 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307903 }
7904
Govind Singhb53420c2016-03-09 14:32:57 +05307905 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307906}
7907
7908/**
Govind Singhccb0c272016-04-01 16:30:08 +05307909 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7910 * @buf_ptr: Buffer passed by upper layers
7911 * @pno: Buffer to be sent to the firmware
7912 *
7913 * Copy the PNO Channel prediction configuration parameters
7914 * passed by the upper layers to a WMI format TLV and send it
7915 * down to the firmware.
7916 *
7917 * Return: None
7918 */
7919static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7920 struct pno_scan_req_params *pno)
7921{
7922 nlo_channel_prediction_cfg *channel_prediction_cfg =
7923 (nlo_channel_prediction_cfg *) buf_ptr;
7924 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7925 WMITLV_TAG_ARRAY_BYTE,
7926 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307927#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307928 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7929 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7930 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7931 channel_prediction_cfg->full_scan_period_ms =
7932 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307933#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307934 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7935 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7936 channel_prediction_cfg->enable,
7937 channel_prediction_cfg->top_k_num,
7938 channel_prediction_cfg->stationary_threshold,
7939 channel_prediction_cfg->full_scan_period_ms);
7940}
7941
7942/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007943 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7944 * @wmi_handle: wmi handle
7945 * @params: configuration parameters
7946 *
7947 * Return: QDF_STATUS
7948 */
7949static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7950 struct nlo_mawc_params *params)
7951{
7952 wmi_buf_t buf = NULL;
7953 QDF_STATUS status;
7954 int len;
7955 uint8_t *buf_ptr;
7956 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7957
7958 len = sizeof(*wmi_nlo_mawc_params);
7959 buf = wmi_buf_alloc(wmi_handle, len);
7960 if (!buf) {
7961 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7962 return QDF_STATUS_E_NOMEM;
7963 }
7964
7965 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7966 wmi_nlo_mawc_params =
7967 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7968 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7969 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7970 WMITLV_GET_STRUCT_TLVLEN
7971 (wmi_nlo_configure_mawc_cmd_fixed_param));
7972 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7973 if (params->enable)
7974 wmi_nlo_mawc_params->enable = 1;
7975 else
7976 wmi_nlo_mawc_params->enable = 0;
7977 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7978 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7979 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007980 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7981 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7982 wmi_nlo_mawc_params->exp_backoff_ratio,
7983 wmi_nlo_mawc_params->init_scan_interval,
7984 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007985
7986 status = wmi_unified_cmd_send(wmi_handle, buf,
7987 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7988 if (QDF_IS_STATUS_ERROR(status)) {
7989 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7990 status);
7991 wmi_buf_free(buf);
7992 return QDF_STATUS_E_FAILURE;
7993 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007994
7995 return QDF_STATUS_SUCCESS;
7996}
7997
7998/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307999 * send_pno_start_cmd_tlv() - PNO start request
8000 * @wmi_handle: wmi handle
8001 * @pno: PNO request
8002 *
8003 * This function request FW to start PNO request.
8004 * Request: CDF status
8005 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308006static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308007 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308008{
8009 wmi_nlo_config_cmd_fixed_param *cmd;
8010 nlo_configured_parameters *nlo_list;
8011 uint32_t *channel_list;
8012 int32_t len;
8013 wmi_buf_t buf;
8014 uint8_t *buf_ptr;
8015 uint8_t i;
8016 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308017 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308018 connected_nlo_rssi_params *nlo_relative_rssi;
8019 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308020
8021 /*
8022 * TLV place holder for array nlo_configured_parameters(nlo_list)
8023 * TLV place holder for array of uint32_t channel_list
8024 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308025 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308026 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308027 */
8028 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308029 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308030 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308031
Abhishek Singh5987b632017-03-03 22:09:07 +05308032 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308033 WMI_NLO_MAX_CHAN);
8034 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308035 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308036 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308037 len += sizeof(enlo_candidate_score_params);
8038 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308039 len += sizeof(connected_nlo_rssi_params);
8040 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308041
8042 buf = wmi_buf_alloc(wmi_handle, len);
8043 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308044 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8045 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308046 }
8047
8048 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8049
8050 buf_ptr = (uint8_t *) cmd;
8051 WMITLV_SET_HDR(&cmd->tlv_header,
8052 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8053 WMITLV_GET_STRUCT_TLVLEN
8054 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308055 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308056 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8057
Govind Singh87542482016-06-08 19:40:11 +05308058#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308059 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308060 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308061#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308062 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308063 cmd->active_dwell_time = pno->active_dwell_time;
8064 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308065
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308066 if (pno->do_passive_scan)
8067 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308068 /* Copy scan interval */
8069 cmd->fast_scan_period = pno->fast_scan_period;
8070 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008071 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308072 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008073 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308074 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308075 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308076 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308077
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308078 /* mac randomization attributes */
8079 if (pno->scan_random.randomize) {
8080 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8081 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8082 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8083 pno->scan_random.mac_mask,
8084 &cmd->mac_addr,
8085 &cmd->mac_mask);
8086 }
8087
Govind Singh4eacd2b2016-03-07 14:24:22 +05308088 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8089
Abhishek Singh5987b632017-03-03 22:09:07 +05308090 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308091 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308092 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8093 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8094 buf_ptr += WMI_TLV_HDR_SIZE;
8095
8096 nlo_list = (nlo_configured_parameters *) buf_ptr;
8097 for (i = 0; i < cmd->no_of_ssids; i++) {
8098 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8099 WMITLV_TAG_ARRAY_BYTE,
8100 WMITLV_GET_STRUCT_TLVLEN
8101 (nlo_configured_parameters));
8102 /* Copy ssid and it's length */
8103 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308104 nlo_list[i].ssid.ssid.ssid_len =
8105 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308106 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308107 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308108 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308109 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308110 nlo_list[i].ssid.ssid.ssid_len,
8111 (char *)nlo_list[i].ssid.ssid.ssid,
8112 nlo_list[i].ssid.ssid.ssid_len);
8113
8114 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308115 if (pno->networks_list[i].rssi_thresh &&
8116 pno->networks_list[i].rssi_thresh >
8117 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308118 nlo_list[i].rssi_cond.valid = true;
8119 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308120 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308121 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308122 nlo_list[i].rssi_cond.rssi);
8123 }
8124 nlo_list[i].bcast_nw_type.valid = true;
8125 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308126 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008127 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308128 nlo_list[i].bcast_nw_type.bcast_nw_type);
8129 }
8130 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8131
8132 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308133 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308134 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308135 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308136 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8137 (cmd->num_of_channels * sizeof(uint32_t)));
8138 buf_ptr += WMI_TLV_HDR_SIZE;
8139
8140 channel_list = (uint32_t *) buf_ptr;
8141 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308142 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308143
8144 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308145 channel_list[i] =
8146 wlan_chan_to_freq(pno->
8147 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308148
Govind Singhb53420c2016-03-09 14:32:57 +05308149 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308150 }
8151 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8153 sizeof(nlo_channel_prediction_cfg));
8154 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308155 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308156 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308157 /** TODO: Discrete firmware doesn't have command/option to configure
8158 * App IE which comes from wpa_supplicant as of part PNO start request.
8159 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308160 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8161 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8162 buf_ptr += sizeof(enlo_candidate_score_params);
8163
8164 if (ie_whitelist->white_list) {
8165 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8166 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8167 &cmd->num_vendor_oui,
8168 ie_whitelist);
8169 }
8170
8171 /* ie white list */
8172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8173 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8174 buf_ptr += WMI_TLV_HDR_SIZE;
8175 if (cmd->num_vendor_oui != 0) {
8176 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8177 ie_whitelist->voui);
8178 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8179 }
8180
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308181 if (pno->relative_rssi_set)
8182 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8183
8184 /*
8185 * Firmware calculation using connected PNO params:
8186 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8187 * deduction of rssi_pref for chosen band_pref and
8188 * addition of rssi_pref for remaining bands (other than chosen band).
8189 */
8190 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8191 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8192 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8193 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8194 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8195 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8196 buf_ptr += sizeof(*nlo_relative_rssi);
8197
8198 /*
8199 * As of now Kernel and Host supports one band and rssi preference.
8200 * Firmware supports array of band and rssi preferences
8201 */
8202 cmd->num_cnlo_band_pref = 1;
8203 WMITLV_SET_HDR(buf_ptr,
8204 WMITLV_TAG_ARRAY_STRUC,
8205 cmd->num_cnlo_band_pref *
8206 sizeof(connected_nlo_bss_band_rssi_pref));
8207 buf_ptr += WMI_TLV_HDR_SIZE;
8208
8209 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8210 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8211 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8212 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8213 WMITLV_GET_STRUCT_TLVLEN(
8214 connected_nlo_bss_band_rssi_pref));
8215 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8216 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8217 WMI_LOGI("band_pref %d, rssi_pref %d",
8218 nlo_band_rssi[i].band,
8219 nlo_band_rssi[i].rssi_pref);
8220 }
8221 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8222
Govind Singh4eacd2b2016-03-07 14:24:22 +05308223 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8224 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8225 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308226 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308227 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308228 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308229 }
8230
Govind Singhb53420c2016-03-09 14:32:57 +05308231 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308232}
8233
8234/* send_set_ric_req_cmd_tlv() - set ric request element
8235 * @wmi_handle: wmi handle
8236 * @msg: message
8237 * @is_add_ts: is addts required
8238 *
8239 * This function sets ric request element for 11r roaming.
8240 *
8241 * Return: CDF status
8242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308243static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308244 void *msg, uint8_t is_add_ts)
8245{
8246 wmi_ric_request_fixed_param *cmd;
8247 wmi_ric_tspec *tspec_param;
8248 wmi_buf_t buf;
8249 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308250 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308251 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8252 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8253
8254 buf = wmi_buf_alloc(wmi_handle, len);
8255 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308256 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8257 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308258 }
8259
8260 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8261
8262 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8263 WMITLV_SET_HDR(&cmd->tlv_header,
8264 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8265 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8266 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008267 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308268 else
8269 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8270 cmd->num_ric_request = 1;
8271 cmd->is_add_ric = is_add_ts;
8272
8273 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8275
8276 buf_ptr += WMI_TLV_HDR_SIZE;
8277 tspec_param = (wmi_ric_tspec *) buf_ptr;
8278 WMITLV_SET_HDR(&tspec_param->tlv_header,
8279 WMITLV_TAG_STRUC_wmi_ric_tspec,
8280 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8281
8282 if (is_add_ts)
8283 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308284#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308285 else
8286 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308287#endif
8288 if (ptspecIE) {
8289 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308290#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308291 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8292 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308293#else
Govind Singh87542482016-06-08 19:40:11 +05308294 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8295 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308296#endif /* ANI_LITTLE_BIT_ENDIAN */
8297
Govind Singh87542482016-06-08 19:40:11 +05308298 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8299 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8300 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8301 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8302 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8303 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8304 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8305 tspec_param->min_data_rate = ptspecIE->minDataRate;
8306 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8307 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8308 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8309 tspec_param->delay_bound = ptspecIE->delayBound;
8310 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8311 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8312 tspec_param->medium_time = 0;
8313 }
Govind Singhb53420c2016-03-09 14:32:57 +05308314 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308315
8316 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8317 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308318 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308319 __func__);
8320 if (is_add_ts)
8321 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308322 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308323 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308324 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308325 }
8326
Govind Singhb53420c2016-03-09 14:32:57 +05308327 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308328}
8329
8330/**
8331 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8332 * @wmi_handle: wmi handle
8333 * @clear_req: ll stats clear request command params
8334 *
Govind Singhb53420c2016-03-09 14:32:57 +05308335 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308336 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308337static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308338 const struct ll_stats_clear_params *clear_req,
8339 uint8_t addr[IEEE80211_ADDR_LEN])
8340{
8341 wmi_clear_link_stats_cmd_fixed_param *cmd;
8342 int32_t len;
8343 wmi_buf_t buf;
8344 uint8_t *buf_ptr;
8345 int ret;
8346
8347 len = sizeof(*cmd);
8348 buf = wmi_buf_alloc(wmi_handle, len);
8349
8350 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308351 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8352 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308353 }
8354
8355 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308356 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308357 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8358
8359 WMITLV_SET_HDR(&cmd->tlv_header,
8360 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8361 WMITLV_GET_STRUCT_TLVLEN
8362 (wmi_clear_link_stats_cmd_fixed_param));
8363
8364 cmd->stop_stats_collection_req = clear_req->stop_req;
8365 cmd->vdev_id = clear_req->sta_id;
8366 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8367
8368 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8369 &cmd->peer_macaddr);
8370
Govind Singhb53420c2016-03-09 14:32:57 +05308371 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8372 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8373 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8374 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8375 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308376 cmd->peer_macaddr); */
8377
8378 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8379 WMI_CLEAR_LINK_STATS_CMDID);
8380 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308381 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308382 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308383 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308384 }
8385
Govind Singhb53420c2016-03-09 14:32:57 +05308386 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8387 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308388}
8389
8390/**
8391 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8392 * @wmi_handle: wmi handle
8393 * @setReq: ll stats set request command params
8394 *
Govind Singhb53420c2016-03-09 14:32:57 +05308395 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308396 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308397static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308398 const struct ll_stats_set_params *set_req)
8399{
8400 wmi_start_link_stats_cmd_fixed_param *cmd;
8401 int32_t len;
8402 wmi_buf_t buf;
8403 uint8_t *buf_ptr;
8404 int ret;
8405
8406 len = sizeof(*cmd);
8407 buf = wmi_buf_alloc(wmi_handle, len);
8408
8409 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308410 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8411 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308412 }
8413
8414 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308415 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308416 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8417
8418 WMITLV_SET_HDR(&cmd->tlv_header,
8419 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8420 WMITLV_GET_STRUCT_TLVLEN
8421 (wmi_start_link_stats_cmd_fixed_param));
8422
8423 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8424 cmd->aggressive_statistics_gathering =
8425 set_req->aggressive_statistics_gathering;
8426
Govind Singhb53420c2016-03-09 14:32:57 +05308427 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8428 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8429 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308430
8431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8432 WMI_START_LINK_STATS_CMDID);
8433 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308434 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308435 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308436 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308437 }
8438
Govind Singhb53420c2016-03-09 14:32:57 +05308439 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308440}
8441
8442/**
8443 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8444 * @wmi_handle:wmi handle
8445 * @get_req:ll stats get request command params
8446 * @addr: mac address
8447 *
Govind Singhb53420c2016-03-09 14:32:57 +05308448 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308449 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308450static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308451 const struct ll_stats_get_params *get_req,
8452 uint8_t addr[IEEE80211_ADDR_LEN])
8453{
8454 wmi_request_link_stats_cmd_fixed_param *cmd;
8455 int32_t len;
8456 wmi_buf_t buf;
8457 uint8_t *buf_ptr;
8458 int ret;
8459
8460 len = sizeof(*cmd);
8461 buf = wmi_buf_alloc(wmi_handle, len);
8462
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308463 if (!buf) {
8464 WMI_LOGE("%s: buf allocation failed", __func__);
8465 return QDF_STATUS_E_NOMEM;
8466 }
8467
Govind Singh4eacd2b2016-03-07 14:24:22 +05308468 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308469 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308470 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8471
8472 WMITLV_SET_HDR(&cmd->tlv_header,
8473 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8474 WMITLV_GET_STRUCT_TLVLEN
8475 (wmi_request_link_stats_cmd_fixed_param));
8476
8477 cmd->request_id = get_req->req_id;
8478 cmd->stats_type = get_req->param_id_mask;
8479 cmd->vdev_id = get_req->sta_id;
8480
8481 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8482 &cmd->peer_macaddr);
8483
Govind Singhb53420c2016-03-09 14:32:57 +05308484 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008485 WMI_LOGD("Request ID : %u", cmd->request_id);
8486 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308487 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8488 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308489
8490 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8491 WMI_REQUEST_LINK_STATS_CMDID);
8492 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308493 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308494 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308495 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308496 }
8497
Govind Singhb53420c2016-03-09 14:32:57 +05308498 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308499}
8500
Govind Singh4eacd2b2016-03-07 14:24:22 +05308501
Govind Singh20c5dac2016-03-07 15:33:31 +05308502/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308503 * send_congestion_cmd_tlv() - send request to fw to get CCA
8504 * @wmi_handle: wmi handle
8505 * @vdev_id: vdev id
8506 *
8507 * Return: CDF status
8508 */
8509static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
8510 A_UINT8 vdev_id)
8511{
8512 wmi_buf_t buf;
8513 wmi_request_stats_cmd_fixed_param *cmd;
8514 uint8_t len;
8515 uint8_t *buf_ptr;
8516
8517 len = sizeof(*cmd);
8518 buf = wmi_buf_alloc(wmi_handle, len);
8519 if (!buf) {
8520 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8521 return QDF_STATUS_E_FAILURE;
8522 }
8523
8524 buf_ptr = wmi_buf_data(buf);
8525 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8526 WMITLV_SET_HDR(&cmd->tlv_header,
8527 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8528 WMITLV_GET_STRUCT_TLVLEN
8529 (wmi_request_stats_cmd_fixed_param));
8530
8531 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8532 cmd->vdev_id = vdev_id;
8533 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8534 cmd->vdev_id, cmd->stats_id);
8535
8536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8537 WMI_REQUEST_STATS_CMDID)) {
8538 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8539 __func__);
8540 wmi_buf_free(buf);
8541 return QDF_STATUS_E_FAILURE;
8542 }
8543
8544 return QDF_STATUS_SUCCESS;
8545}
8546
8547/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308548 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8549 * @wmi_handle: wmi handle
8550 * @rssi_req: get RSSI request
8551 *
8552 * Return: CDF status
8553 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308554static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308555{
8556 wmi_buf_t buf;
8557 wmi_request_stats_cmd_fixed_param *cmd;
8558 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8559
8560 buf = wmi_buf_alloc(wmi_handle, len);
8561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308562 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8563 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308564 }
8565
8566 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8567 WMITLV_SET_HDR(&cmd->tlv_header,
8568 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8569 WMITLV_GET_STRUCT_TLVLEN
8570 (wmi_request_stats_cmd_fixed_param));
8571 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8572 if (wmi_unified_cmd_send
8573 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308574 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308575 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308576 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308577 }
8578
Govind Singhb53420c2016-03-09 14:32:57 +05308579 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308580}
8581
8582/**
8583 * send_snr_cmd_tlv() - get RSSI from fw
8584 * @wmi_handle: wmi handle
8585 * @vdev_id: vdev id
8586 *
8587 * Return: CDF status
8588 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308589static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308590{
8591 wmi_buf_t buf;
8592 wmi_request_stats_cmd_fixed_param *cmd;
8593 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8594
8595 buf = wmi_buf_alloc(wmi_handle, len);
8596 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308597 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8598 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308599 }
8600
8601 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8602 cmd->vdev_id = vdev_id;
8603
8604 WMITLV_SET_HDR(&cmd->tlv_header,
8605 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8606 WMITLV_GET_STRUCT_TLVLEN
8607 (wmi_request_stats_cmd_fixed_param));
8608 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8609 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8610 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308611 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308612 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308613 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308614 }
8615
Govind Singhb53420c2016-03-09 14:32:57 +05308616 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308617}
8618
8619/**
8620 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8621 * @wmi_handle: wmi handle
8622 * @link_status: get link params
8623 *
8624 * Return: CDF status
8625 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308626static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308627 struct link_status_params *link_status)
8628{
8629 wmi_buf_t buf;
8630 wmi_request_stats_cmd_fixed_param *cmd;
8631 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8632
8633 buf = wmi_buf_alloc(wmi_handle, len);
8634 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308635 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8636 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308637 }
8638
8639 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8640 WMITLV_SET_HDR(&cmd->tlv_header,
8641 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8642 WMITLV_GET_STRUCT_TLVLEN
8643 (wmi_request_stats_cmd_fixed_param));
8644 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8645 cmd->vdev_id = link_status->session_id;
8646 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8647 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308648 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308649 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308650 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308651 }
8652
Govind Singhb53420c2016-03-09 14:32:57 +05308653 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308654}
8655
Govind Singh20c5dac2016-03-07 15:33:31 +05308656/**
8657 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8658 * @wmi_handle: wmi handle
8659 * @ta_dhcp_ind: DHCP indication parameter
8660 *
8661 * Return: CDF Status
8662 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308663static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308664 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8665{
Govind Singh67922e82016-04-01 16:48:57 +05308666 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308667 wmi_buf_t buf = NULL;
8668 uint8_t *buf_ptr;
8669 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8670 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8671
8672
8673 buf = wmi_buf_alloc(wmi_handle, len);
8674 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308675 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8676 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308677 }
8678
8679 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8680 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8681 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8682 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8683 WMITLV_GET_STRUCT_TLVLEN
8684 (wmi_peer_set_param_cmd_fixed_param));
8685
8686 /* fill in values */
8687 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8688 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8689 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308690 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308691 &ta_dhcp_ind->peer_macaddr,
8692 sizeof(ta_dhcp_ind->peer_macaddr));
8693
8694 status = wmi_unified_cmd_send(wmi_handle, buf,
8695 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308696 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308697 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308698 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308699 wmi_buf_free(buf);
8700 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308701
Govind Singh67922e82016-04-01 16:48:57 +05308702 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308703}
8704
8705/**
8706 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8707 * @wmi_handle: wmi handle
8708 * @pLinkSpeed: link speed info
8709 *
8710 * Return: CDF status
8711 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308712static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308713 wmi_mac_addr peer_macaddr)
8714{
8715 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8716 wmi_buf_t wmi_buf;
8717 uint32_t len;
8718 uint8_t *buf_ptr;
8719
8720 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8721 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8722 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308723 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8724 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308725 }
8726 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8727
8728 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8729 WMITLV_SET_HDR(&cmd->tlv_header,
8730 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8731 WMITLV_GET_STRUCT_TLVLEN
8732 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8733
8734 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308735 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308736 &peer_macaddr,
8737 sizeof(peer_macaddr));
8738
8739
8740 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8741 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308742 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308743 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308744 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 }
Govind Singhb53420c2016-03-09 14:32:57 +05308746 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308747}
8748
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308749#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308750/**
8751 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8752 * @wmi_handle: wmi handler
8753 * @egap_params: pointer to egap_params
8754 *
8755 * Return: 0 for success, otherwise appropriate error code
8756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308757static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308758 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308759{
8760 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8761 wmi_buf_t buf;
8762 int32_t err;
8763
8764 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308766 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8767 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308768 }
8769 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8770 WMITLV_SET_HDR(&cmd->tlv_header,
8771 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8772 WMITLV_GET_STRUCT_TLVLEN(
8773 wmi_ap_ps_egap_param_cmd_fixed_param));
8774
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308775 cmd->enable = egap_params->host_enable_egap;
8776 cmd->inactivity_time = egap_params->egap_inactivity_time;
8777 cmd->wait_time = egap_params->egap_wait_time;
8778 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308779 err = wmi_unified_cmd_send(wmi_handle, buf,
8780 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8781 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308782 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308783 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308784 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308785 }
8786
Govind Singhb53420c2016-03-09 14:32:57 +05308787 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308788}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308789#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308790
8791/**
8792 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8793 * @wmi_handl: wmi handle
8794 * @cmd: Profiling command index
8795 * @value1: parameter1 value
8796 * @value2: parameter2 value
8797 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308798 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308799 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308800static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308801 uint32_t cmd, uint32_t value1, uint32_t value2)
8802{
8803 wmi_buf_t buf;
8804 int32_t len = 0;
8805 int ret;
8806 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8807 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8808 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8809 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8810
8811 switch (cmd) {
8812 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8813 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8814 buf = wmi_buf_alloc(wmi_handle, len);
8815 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308816 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308817 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308818 }
8819 prof_trig_cmd =
8820 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8821 wmi_buf_data(buf);
8822 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8823 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8824 WMITLV_GET_STRUCT_TLVLEN
8825 (wmi_wlan_profile_trigger_cmd_fixed_param));
8826 prof_trig_cmd->enable = value1;
8827 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8828 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8829 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308830 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308831 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308832 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308833 return ret;
8834 }
8835 break;
8836
8837 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8838 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8839 buf = wmi_buf_alloc(wmi_handle, len);
8840 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308841 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308842 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308843 }
8844 profile_getdata_cmd =
8845 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8846 wmi_buf_data(buf);
8847 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8848 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8849 WMITLV_GET_STRUCT_TLVLEN
8850 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8851 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8852 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8853 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308854 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308856 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308857 return ret;
8858 }
8859 break;
8860
8861 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8862 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8863 buf = wmi_buf_alloc(wmi_handle, len);
8864 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308865 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308866 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308867 }
8868 hist_intvl_cmd =
8869 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8870 wmi_buf_data(buf);
8871 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8872 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8873 WMITLV_GET_STRUCT_TLVLEN
8874 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8875 hist_intvl_cmd->profile_id = value1;
8876 hist_intvl_cmd->value = value2;
8877 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8878 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8879 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308880 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308881 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308882 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308883 return ret;
8884 }
8885 break;
8886
8887 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8888 len =
8889 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8890 buf = wmi_buf_alloc(wmi_handle, len);
8891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308892 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308893 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 }
8895 profile_enable_cmd =
8896 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8897 wmi_buf_data(buf);
8898 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8899 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8900 WMITLV_GET_STRUCT_TLVLEN
8901 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8902 profile_enable_cmd->profile_id = value1;
8903 profile_enable_cmd->enable = value2;
8904 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8905 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8906 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308907 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308908 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308909 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308910 return ret;
8911 }
8912 break;
8913
8914 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308915 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308916 break;
8917 }
8918
8919 return 0;
8920}
8921
Paul Zhang92ab8d32017-12-08 16:08:00 +08008922static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8923 struct wlm_latency_level_param *params)
8924{
8925 wmi_wlm_config_cmd_fixed_param *cmd;
8926 wmi_buf_t buf;
8927 uint32_t len = sizeof(*cmd);
8928 static uint32_t ll[4] = {100, 60, 40, 20};
8929
8930 buf = wmi_buf_alloc(wmi_handle, len);
8931 if (!buf) {
8932 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8933 return QDF_STATUS_E_NOMEM;
8934 }
8935 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8936 WMITLV_SET_HDR(&cmd->tlv_header,
8937 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8938 WMITLV_GET_STRUCT_TLVLEN
8939 (wmi_wlm_config_cmd_fixed_param));
8940 cmd->vdev_id = params->vdev_id;
8941 cmd->latency_level = params->wlm_latency_level;
8942 cmd->ul_latency = ll[params->wlm_latency_level];
8943 cmd->dl_latency = ll[params->wlm_latency_level];
8944 cmd->flags = params->wlm_latency_flags;
8945 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8946 WMI_WLM_CONFIG_CMDID)) {
8947 WMI_LOGE("%s: Failed to send setting latency config command",
8948 __func__);
8949 wmi_buf_free(buf);
8950 return QDF_STATUS_E_FAILURE;
8951 }
8952
8953 return 0;
8954}
Govind Singh20c5dac2016-03-07 15:33:31 +05308955/**
8956 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8957 * @wmi_handle: wmi handle
8958 * @vdev_id: vdev id
8959 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308960 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308961 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308962static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308963{
8964 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8965 wmi_buf_t buf;
8966 int32_t len = sizeof(*cmd);
8967
Govind Singhb53420c2016-03-09 14:32:57 +05308968 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308969 buf = wmi_buf_alloc(wmi_handle, len);
8970 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308971 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308972 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 }
8974 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8975 wmi_buf_data(buf);
8976 WMITLV_SET_HDR(&cmd->tlv_header,
8977 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8978 WMITLV_GET_STRUCT_TLVLEN
8979 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8980 cmd->vdev_id = vdev_id;
8981 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8982 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8983 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308984 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308985 __func__);
8986 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308987 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 }
8989
8990 return 0;
8991}
8992
8993/**
8994 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8995 * @wmi_handle: wmi handle
8996 * @vdev_id: vdev id
8997 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308998 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308999 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309000static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309001 uint8_t vdev_id)
9002{
9003 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9004 wmi_buf_t buf;
9005 int32_t len = sizeof(*cmd);
9006
Govind Singhb53420c2016-03-09 14:32:57 +05309007 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309008 buf = wmi_buf_alloc(wmi_handle, len);
9009 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309010 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309011 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309012 }
9013 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9014 WMITLV_SET_HDR(&cmd->tlv_header,
9015 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9016 WMITLV_GET_STRUCT_TLVLEN
9017 (wmi_csa_offload_enable_cmd_fixed_param));
9018 cmd->vdev_id = vdev_id;
9019 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9020 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9021 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309022 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309023 __func__);
9024 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309025 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309026 }
9027
9028 return 0;
9029}
9030
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009031#ifdef WLAN_FEATURE_CIF_CFR
9032/**
9033 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9034 * @wmi_handle: wmi handle
9035 * @data_len: len of dma cfg req
9036 * @data: dma cfg req
9037 *
9038 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9039 */
9040static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9041 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9042{
9043 wmi_buf_t buf;
9044 uint8_t *cmd;
9045 QDF_STATUS ret;
9046
9047 WMITLV_SET_HDR(cfg,
9048 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9049 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9050
9051 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9052 if (!buf) {
9053 WMI_LOGE(FL("wmi_buf_alloc failed"));
9054 return QDF_STATUS_E_FAILURE;
9055 }
9056
9057 cmd = (uint8_t *) wmi_buf_data(buf);
9058 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9059 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9060 sizeof(*cfg));
9061 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9062 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9063 if (QDF_IS_STATUS_ERROR(ret)) {
9064 WMI_LOGE(FL(":wmi cmd send failed"));
9065 wmi_buf_free(buf);
9066 }
9067
9068 return ret;
9069}
9070#endif
9071
Govind Singh20c5dac2016-03-07 15:33:31 +05309072/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309073 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9074 * @wmi_handle: wmi handle
9075 * @data_len: len of dma cfg req
9076 * @data: dma cfg req
9077 *
9078 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9079 */
9080static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9081 struct direct_buf_rx_cfg_req *cfg)
9082{
9083 wmi_buf_t buf;
9084 wmi_dma_ring_cfg_req_fixed_param *cmd;
9085 QDF_STATUS ret;
9086 int32_t len = sizeof(*cmd);
9087
9088 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9089 if (!buf) {
9090 WMI_LOGE(FL("wmi_buf_alloc failed"));
9091 return QDF_STATUS_E_FAILURE;
9092 }
9093
9094 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9095
9096 WMITLV_SET_HDR(&cmd->tlv_header,
9097 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9098 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9099
9100 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9101 cfg->pdev_id);
9102 cmd->mod_id = cfg->mod_id;
9103 cmd->base_paddr_lo = cfg->base_paddr_lo;
9104 cmd->base_paddr_hi = cfg->base_paddr_hi;
9105 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9106 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9107 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9108 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9109 cmd->num_elems = cfg->num_elems;
9110 cmd->buf_size = cfg->buf_size;
9111 cmd->num_resp_per_event = cfg->num_resp_per_event;
9112 cmd->event_timeout_ms = cfg->event_timeout_ms;
9113
9114 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9115 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9116 "head idx paddr hi %x tail idx paddr lo %x"
9117 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9118 "event timeout %d\n", __func__, cmd->pdev_id,
9119 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9120 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9121 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9122 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9123 cmd->event_timeout_ms);
9124 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9125 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9126 if (QDF_IS_STATUS_ERROR(ret)) {
9127 WMI_LOGE(FL(":wmi cmd send failed"));
9128 wmi_buf_free(buf);
9129 }
9130
9131 return ret;
9132}
9133
9134/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009135 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9136 * @wmi_handle: wmi handle
9137 * @start_11d_scan: 11d scan start request parameters
9138 *
9139 * This function request FW to start 11d scan.
9140 *
9141 * Return: QDF status
9142 */
9143static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9144 struct reg_start_11d_scan_req *start_11d_scan)
9145{
9146 wmi_11d_scan_start_cmd_fixed_param *cmd;
9147 int32_t len;
9148 wmi_buf_t buf;
9149 int ret;
9150
9151 len = sizeof(*cmd);
9152 buf = wmi_buf_alloc(wmi_handle, len);
9153 if (!buf) {
9154 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9155 return QDF_STATUS_E_NOMEM;
9156 }
9157
9158 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9159
9160 WMITLV_SET_HDR(&cmd->tlv_header,
9161 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9162 WMITLV_GET_STRUCT_TLVLEN
9163 (wmi_11d_scan_start_cmd_fixed_param));
9164
9165 cmd->vdev_id = start_11d_scan->vdev_id;
9166 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9167 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9168
9169 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9170
9171 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9172 WMI_11D_SCAN_START_CMDID);
9173 if (ret) {
9174 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9175 wmi_buf_free(buf);
9176 return QDF_STATUS_E_FAILURE;
9177 }
9178
9179 return QDF_STATUS_SUCCESS;
9180}
9181
9182/**
9183 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9184 * @wmi_handle: wmi handle
9185 * @start_11d_scan: 11d scan stop request parameters
9186 *
9187 * This function request FW to stop 11d scan.
9188 *
9189 * Return: QDF status
9190 */
9191static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9192 struct reg_stop_11d_scan_req *stop_11d_scan)
9193{
9194 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9195 int32_t len;
9196 wmi_buf_t buf;
9197 int ret;
9198
9199 len = sizeof(*cmd);
9200 buf = wmi_buf_alloc(wmi_handle, len);
9201 if (!buf) {
9202 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9203 return QDF_STATUS_E_NOMEM;
9204 }
9205
9206 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9207
9208 WMITLV_SET_HDR(&cmd->tlv_header,
9209 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9210 WMITLV_GET_STRUCT_TLVLEN
9211 (wmi_11d_scan_stop_cmd_fixed_param));
9212
9213 cmd->vdev_id = stop_11d_scan->vdev_id;
9214
9215 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9216
9217 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9218 WMI_11D_SCAN_STOP_CMDID);
9219 if (ret) {
9220 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9221 wmi_buf_free(buf);
9222 return QDF_STATUS_E_FAILURE;
9223 }
9224
9225 return QDF_STATUS_SUCCESS;
9226}
9227
9228/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309229 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9230 * @wmi_handle: wmi handle
9231 * @startOemDataReq: start request params
9232 *
9233 * Return: CDF status
9234 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309235static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009236 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309237 uint8_t *data)
9238{
9239 wmi_buf_t buf;
9240 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309241 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309242
9243 buf = wmi_buf_alloc(wmi_handle,
9244 (data_len + WMI_TLV_HDR_SIZE));
9245 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309246 WMI_LOGE(FL("wmi_buf_alloc failed"));
9247 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309248 }
9249
9250 cmd = (uint8_t *) wmi_buf_data(buf);
9251
9252 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9253 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309254 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309255 data_len);
9256
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009257 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309258 data_len);
9259
9260 ret = wmi_unified_cmd_send(wmi_handle, buf,
9261 (data_len +
9262 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9263
Govind Singh67922e82016-04-01 16:48:57 +05309264 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309266 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 }
9268
Govind Singh67922e82016-04-01 16:48:57 +05309269 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309270}
9271
9272/**
9273 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9274 * @wmi_handle: wmi handle
9275 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9276 *
9277 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9278 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9279 * to firmware based on phyerr filtering
9280 * offload status.
9281 *
9282 * Return: 1 success, 0 failure
9283 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309284static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309285send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9286 bool dfs_phyerr_filter_offload)
9287{
9288 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9289 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9290 wmi_buf_t buf;
9291 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309292 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309293
9294
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009295 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309296 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309297 __func__);
9298 len = sizeof(*disable_phyerr_offload_cmd);
9299 buf = wmi_buf_alloc(wmi_handle, len);
9300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309301 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309302 return 0;
9303 }
9304 disable_phyerr_offload_cmd =
9305 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9306 wmi_buf_data(buf);
9307
9308 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9309 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9310 WMITLV_GET_STRUCT_TLVLEN
9311 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9312
9313 /*
9314 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9315 * to the firmware to disable the phyerror
9316 * filtering offload.
9317 */
9318 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9319 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309320 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309321 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309322 __func__, ret);
9323 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309324 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309325 }
Govind Singhb53420c2016-03-09 14:32:57 +05309326 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 __func__);
9328 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309329 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309330 __func__);
9331
9332 len = sizeof(*enable_phyerr_offload_cmd);
9333 buf = wmi_buf_alloc(wmi_handle, len);
9334 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309335 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9336 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309337 }
9338
9339 enable_phyerr_offload_cmd =
9340 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9341 wmi_buf_data(buf);
9342
9343 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9344 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9345 WMITLV_GET_STRUCT_TLVLEN
9346 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9347
9348 /*
9349 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9350 * to the firmware to enable the phyerror
9351 * filtering offload.
9352 */
9353 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9354 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9355
Govind Singh67922e82016-04-01 16:48:57 +05309356 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309357 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309358 __func__, ret);
9359 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309360 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309361 }
Govind Singhb53420c2016-03-09 14:32:57 +05309362 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309363 __func__);
9364 }
9365
Govind Singhb53420c2016-03-09 14:32:57 +05309366 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309367}
9368
Naveen Rawata5817e72017-10-26 18:50:19 -07009369/**
9370 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9371 * will wake up host after specified time is elapsed
9372 * @wmi_handle: wmi handle
9373 * @vdev_id: vdev id
9374 * @cookie: value to identify reason why host set up wake call.
9375 * @time: time in ms
9376 *
9377 * Return: QDF status
9378 */
9379static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9380 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9381{
9382 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9383 wmi_buf_t buf;
9384 uint8_t *buf_ptr;
9385 int32_t len;
9386 int ret;
9387
9388 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9389 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9390 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9391 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9392 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
9393 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) +
9394 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
9395
9396 buf = wmi_buf_alloc(wmi_handle, len);
9397 if (!buf) {
9398 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9399 return QDF_STATUS_E_NOMEM;
9400 }
9401
9402 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9403 buf_ptr = (uint8_t *) cmd;
9404
9405 WMITLV_SET_HDR(&cmd->tlv_header,
9406 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9407 WMITLV_GET_STRUCT_TLVLEN
9408 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9409 cmd->vdev_id = vdev_id;
9410 cmd->pattern_id = cookie,
9411 cmd->pattern_type = WOW_TIMER_PATTERN;
9412 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9413
9414 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9415 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9416 buf_ptr += WMI_TLV_HDR_SIZE;
9417
9418 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9420 buf_ptr += WMI_TLV_HDR_SIZE;
9421
9422 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9424 buf_ptr += WMI_TLV_HDR_SIZE;
9425
9426 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9427 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9428 buf_ptr += WMI_TLV_HDR_SIZE;
9429
9430 /* Fill TLV for pattern_info_timeout, and time value */
9431 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9432 buf_ptr += WMI_TLV_HDR_SIZE;
9433 *((A_UINT32 *) buf_ptr) = time;
9434 buf_ptr += sizeof(A_UINT32);
9435
9436 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
9437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9438 buf_ptr += WMI_TLV_HDR_SIZE;
9439 *((A_UINT32 *) buf_ptr) = 0;
9440
9441 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9442 __func__, time, vdev_id);
9443
9444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9445 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9446 if (ret) {
9447 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9448 __func__);
9449 wmi_buf_free(buf);
9450 return QDF_STATUS_E_FAILURE;
9451 }
9452
9453 return QDF_STATUS_SUCCESS;
9454}
9455
Govind Singh20c5dac2016-03-07 15:33:31 +05309456#if !defined(REMOVE_PKT_LOG)
9457/**
9458 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9459 * @wmi_handle: wmi handle
9460 * @pktlog_event: pktlog event
9461 * @cmd_id: pktlog cmd id
9462 *
9463 * Return: CDF status
9464 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309465static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309466 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309467 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309468{
9469 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9470 WMI_CMD_ID CMD_ID;
9471 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9472 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9473 int len = 0;
9474 wmi_buf_t buf;
9475
9476 PKTLOG_EVENT = pktlog_event;
9477 CMD_ID = cmd_id;
9478
9479 switch (CMD_ID) {
9480 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9481 len = sizeof(*cmd);
9482 buf = wmi_buf_alloc(wmi_handle, len);
9483 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309484 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9485 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309486 }
9487 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9488 wmi_buf_data(buf);
9489 WMITLV_SET_HDR(&cmd->tlv_header,
9490 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9491 WMITLV_GET_STRUCT_TLVLEN
9492 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9493 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309494 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9495 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309496 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9497 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309498 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9499 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309500 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 goto wmi_send_failed;
9502 }
9503 break;
9504 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9505 len = sizeof(*disable_cmd);
9506 buf = wmi_buf_alloc(wmi_handle, len);
9507 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309508 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9509 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309510 }
9511 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9512 wmi_buf_data(buf);
9513 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9514 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9515 WMITLV_GET_STRUCT_TLVLEN
9516 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309517 disable_cmd->pdev_id =
9518 wmi_handle->ops->convert_pdev_id_host_to_target(
9519 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309520 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9521 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309522 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309523 goto wmi_send_failed;
9524 }
9525 break;
9526 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309527 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309528 break;
9529 }
9530
Govind Singhb53420c2016-03-09 14:32:57 +05309531 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309532
9533wmi_send_failed:
9534 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309535 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309536}
9537#endif /* REMOVE_PKT_LOG */
9538
9539/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9541 * @wmi_handle: wmi handle
9542 * @ptrn_id: pattern id
9543 * @vdev_id: vdev id
9544 *
9545 * Return: CDF status
9546 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309547static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9548 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309549{
9550 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9551 wmi_buf_t buf;
9552 int32_t len;
9553 int ret;
9554
9555 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9556
9557
9558 buf = wmi_buf_alloc(wmi_handle, len);
9559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309560 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9561 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309562 }
9563
9564 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9565
9566 WMITLV_SET_HDR(&cmd->tlv_header,
9567 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9568 WMITLV_GET_STRUCT_TLVLEN(
9569 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9570 cmd->vdev_id = vdev_id;
9571 cmd->pattern_id = ptrn_id;
9572 cmd->pattern_type = WOW_BITMAP_PATTERN;
9573
Govind Singhb53420c2016-03-09 14:32:57 +05309574 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309575 cmd->pattern_id, vdev_id);
9576
9577 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9578 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9579 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309580 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309581 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309582 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309583 }
9584
Govind Singhb53420c2016-03-09 14:32:57 +05309585 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309586}
9587
9588/**
9589 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9590 * @wmi_handle: wmi handle
9591 *
9592 * Sends host wakeup indication to FW. On receiving this indication,
9593 * FW will come out of WOW.
9594 *
9595 * Return: CDF status
9596 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309597static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309598{
9599 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9600 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309601 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309602 int32_t len;
9603 int ret;
9604
9605 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9606
9607 buf = wmi_buf_alloc(wmi_handle, len);
9608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309609 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9610 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309611 }
9612
9613 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9614 wmi_buf_data(buf);
9615 WMITLV_SET_HDR(&cmd->tlv_header,
9616 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9617 WMITLV_GET_STRUCT_TLVLEN
9618 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9619
9620
9621 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9622 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9623 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309624 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309625 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309626 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309627 }
9628
Govind Singhb53420c2016-03-09 14:32:57 +05309629 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309630}
9631
9632/**
9633 * send_del_ts_cmd_tlv() - send DELTS request to fw
9634 * @wmi_handle: wmi handle
9635 * @msg: delts params
9636 *
9637 * Return: CDF status
9638 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309639static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309640 uint8_t ac)
9641{
9642 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9643 wmi_buf_t buf;
9644 int32_t len = sizeof(*cmd);
9645
9646 buf = wmi_buf_alloc(wmi_handle, len);
9647 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309648 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9649 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309650 }
9651 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9652 WMITLV_SET_HDR(&cmd->tlv_header,
9653 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9654 WMITLV_GET_STRUCT_TLVLEN
9655 (wmi_vdev_wmm_delts_cmd_fixed_param));
9656 cmd->vdev_id = vdev_id;
9657 cmd->ac = ac;
9658
Govind Singhb53420c2016-03-09 14:32:57 +05309659 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309660 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9661 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9662 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309663 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309664 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309665 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309666 }
9667
Govind Singhb53420c2016-03-09 14:32:57 +05309668 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309669}
9670
9671/**
9672 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9673 * @wmi_handle: handle to wmi
9674 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9675 *
Govind Singhb53420c2016-03-09 14:32:57 +05309676 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309677 * ADD_TS requestes to firmware in loop for all the ACs with
9678 * active flow.
9679 *
9680 * Return: CDF status
9681 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309682static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309683 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9684{
9685 int i = 0;
9686 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9687 wmi_buf_t buf;
9688 int32_t len = sizeof(*cmd);
9689
9690 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9691 /* if flow in this AC is active */
9692 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9693 /*
9694 * as per implementation of wma_add_ts_req() we
9695 * are not waiting any response from firmware so
9696 * apart from sending ADDTS to firmware just send
9697 * success to upper layers
9698 */
Govind Singhb53420c2016-03-09 14:32:57 +05309699 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309700
9701 buf = wmi_buf_alloc(wmi_handle, len);
9702 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309703 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9704 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309705 }
9706 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9707 wmi_buf_data(buf);
9708 WMITLV_SET_HDR(&cmd->tlv_header,
9709 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9710 WMITLV_GET_STRUCT_TLVLEN
9711 (wmi_vdev_wmm_addts_cmd_fixed_param));
9712 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9713 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309714 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309715 traffic.userPrio);
9716 cmd->medium_time_us =
9717 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9718 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309719 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309720 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9721 cmd->medium_time_us, cmd->downgrade_type);
9722 if (wmi_unified_cmd_send
9723 (wmi_handle, buf, len,
9724 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309725 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309726 __func__);
9727 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309728 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309729 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309730 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309731 }
9732 }
9733 }
9734
Govind Singhb53420c2016-03-09 14:32:57 +05309735 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309736}
9737
9738/**
9739 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9740 * @wmi_handle: wmi handle
9741 * @msg: ADDTS params
9742 *
9743 * Return: CDF status
9744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309745static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309746 struct add_ts_param *msg)
9747{
9748 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9749 wmi_buf_t buf;
9750 int32_t len = sizeof(*cmd);
9751
Govind Singhb53420c2016-03-09 14:32:57 +05309752 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309753
9754 buf = wmi_buf_alloc(wmi_handle, len);
9755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309756 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9757 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309758 }
9759 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9760 WMITLV_SET_HDR(&cmd->tlv_header,
9761 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9762 WMITLV_GET_STRUCT_TLVLEN
9763 (wmi_vdev_wmm_addts_cmd_fixed_param));
9764 cmd->vdev_id = msg->sme_session_id;
9765 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9766 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9767 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309768 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309769 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9770 cmd->downgrade_type, __func__, __LINE__);
9771 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9772 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309773 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9774 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309775 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309776 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309777 }
9778
Govind Singhb53420c2016-03-09 14:32:57 +05309779 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309780}
9781
9782/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309783 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9784 * @wmi_handle: wmi handle
9785 * @pAddPeriodicTxPtrnParams: tx ptrn params
9786 *
9787 * Retrun: CDF status
9788 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309789static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309790 struct periodic_tx_pattern *
9791 pAddPeriodicTxPtrnParams,
9792 uint8_t vdev_id)
9793{
9794 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9795 wmi_buf_t wmi_buf;
9796 uint32_t len;
9797 uint8_t *buf_ptr;
9798 uint32_t ptrn_len, ptrn_len_aligned;
9799 int j;
9800
9801 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9802 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9803 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9804 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9805
9806 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9807 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309808 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9809 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309810 }
9811
9812 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9813
9814 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9815 WMITLV_SET_HDR(&cmd->tlv_header,
9816 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9817 WMITLV_GET_STRUCT_TLVLEN
9818 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9819
9820 /* Pass the pattern id to delete for the corresponding vdev id */
9821 cmd->vdev_id = vdev_id;
9822 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9823 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9824 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9825
9826 /* Pattern info */
9827 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9829 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309830 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309831 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309832 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309833
Govind Singhb53420c2016-03-09 14:32:57 +05309834 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309835 __func__, cmd->pattern_id, cmd->vdev_id);
9836
9837 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9838 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309839 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309840 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309841 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309842 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309843 }
Govind Singhb53420c2016-03-09 14:32:57 +05309844 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309845}
9846
9847/**
9848 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9849 * @wmi_handle: wmi handle
9850 * @vdev_id: vdev id
9851 * @pattern_id: pattern id
9852 *
9853 * Retrun: CDF status
9854 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309855static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309856 uint8_t vdev_id,
9857 uint8_t pattern_id)
9858{
9859 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9860 wmi_buf_t wmi_buf;
9861 uint32_t len =
9862 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9863
9864 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9865 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309866 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9867 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309868 }
9869
9870 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9871 wmi_buf_data(wmi_buf);
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN
9875 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9876
9877 /* Pass the pattern id to delete for the corresponding vdev id */
9878 cmd->vdev_id = vdev_id;
9879 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309880 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309881 __func__, cmd->pattern_id, cmd->vdev_id);
9882
9883 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9884 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309885 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309886 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309887 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309888 }
Govind Singhb53420c2016-03-09 14:32:57 +05309889 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309890}
9891
9892/**
9893 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9894 * @wmi_handle: wmi handle
9895 * @preq: stats ext params
9896 *
9897 * Return: CDF status
9898 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309899static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309900 struct stats_ext_params *preq)
9901{
Govind Singh67922e82016-04-01 16:48:57 +05309902 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309903 wmi_req_stats_ext_cmd_fixed_param *cmd;
9904 wmi_buf_t buf;
9905 uint16_t len;
9906 uint8_t *buf_ptr;
9907
9908 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9909
9910 buf = wmi_buf_alloc(wmi_handle, len);
9911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309912 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309913 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309914 }
9915
9916 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9917 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9918
9919 WMITLV_SET_HDR(&cmd->tlv_header,
9920 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9921 WMITLV_GET_STRUCT_TLVLEN
9922 (wmi_req_stats_ext_cmd_fixed_param));
9923 cmd->vdev_id = preq->vdev_id;
9924 cmd->data_len = preq->request_data_len;
9925
Govind Singhb53420c2016-03-09 14:32:57 +05309926 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309927 __func__, preq->request_data_len, preq->vdev_id);
9928
9929 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9930 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9931
9932 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309933 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309934
9935 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9936 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309937 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309938 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309939 ret);
9940 wmi_buf_free(buf);
9941 }
9942
9943 return ret;
9944}
9945
9946/**
9947 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9948 * @wmi_handle: wmi handle
9949 * @params: ext wow params
9950 *
9951 * Return:0 for success or error code
9952 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309953static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309954 struct ext_wow_params *params)
9955{
9956 wmi_extwow_enable_cmd_fixed_param *cmd;
9957 wmi_buf_t buf;
9958 int32_t len;
9959 int ret;
9960
9961 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9962 buf = wmi_buf_alloc(wmi_handle, len);
9963 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309964 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9965 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309966 }
9967
9968 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9969
9970 WMITLV_SET_HDR(&cmd->tlv_header,
9971 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9972 WMITLV_GET_STRUCT_TLVLEN
9973 (wmi_extwow_enable_cmd_fixed_param));
9974
9975 cmd->vdev_id = params->vdev_id;
9976 cmd->type = params->type;
9977 cmd->wakeup_pin_num = params->wakeup_pin_num;
9978
Govind Singhb53420c2016-03-09 14:32:57 +05309979 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309980 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9981
9982 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9983 WMI_EXTWOW_ENABLE_CMDID);
9984 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309985 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309986 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309987 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309988 }
9989
Govind Singhb53420c2016-03-09 14:32:57 +05309990 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309991
9992}
9993
9994/**
9995 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9996 * @wmi_handle: wmi handle
9997 * @app_type1_params: app type1 params
9998 *
9999 * Return: CDF status
10000 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010001static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010002 struct app_type1_params *app_type1_params)
10003{
10004 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10005 wmi_buf_t buf;
10006 int32_t len;
10007 int ret;
10008
10009 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10010 buf = wmi_buf_alloc(wmi_handle, len);
10011 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010012 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10013 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010014 }
10015
10016 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10017 wmi_buf_data(buf);
10018
10019 WMITLV_SET_HDR(&cmd->tlv_header,
10020 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10021 WMITLV_GET_STRUCT_TLVLEN
10022 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10023
10024 cmd->vdev_id = app_type1_params->vdev_id;
10025 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10026 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010027 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010028 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010029 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010030 cmd->passwd_len = app_type1_params->pass_length;
10031
Govind Singhb53420c2016-03-09 14:32:57 +053010032 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010033 "identification_id %.8s id_length %u "
10034 "password %.16s pass_length %u",
10035 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10036 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10037
10038 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10039 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10040 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010041 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010042 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010043 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010044 }
10045
Govind Singhb53420c2016-03-09 14:32:57 +053010046 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010047}
10048
10049/**
10050 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10051 * @wmi_handle: wmi handle
10052 * @appType2Params: app type2 params
10053 *
10054 * Return: CDF status
10055 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010056static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010057 struct app_type2_params *appType2Params)
10058{
10059 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10060 wmi_buf_t buf;
10061 int32_t len;
10062 int ret;
10063
10064 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10065 buf = wmi_buf_alloc(wmi_handle, len);
10066 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010067 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10068 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010069 }
10070
10071 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10072 wmi_buf_data(buf);
10073
10074 WMITLV_SET_HDR(&cmd->tlv_header,
10075 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10076 WMITLV_GET_STRUCT_TLVLEN
10077 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10078
10079 cmd->vdev_id = appType2Params->vdev_id;
10080
Govind Singhb53420c2016-03-09 14:32:57 +053010081 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010082 cmd->rc4_key_len = appType2Params->rc4_key_len;
10083
10084 cmd->ip_id = appType2Params->ip_id;
10085 cmd->ip_device_ip = appType2Params->ip_device_ip;
10086 cmd->ip_server_ip = appType2Params->ip_server_ip;
10087
10088 cmd->tcp_src_port = appType2Params->tcp_src_port;
10089 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10090 cmd->tcp_seq = appType2Params->tcp_seq;
10091 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10092
10093 cmd->keepalive_init = appType2Params->keepalive_init;
10094 cmd->keepalive_min = appType2Params->keepalive_min;
10095 cmd->keepalive_max = appType2Params->keepalive_max;
10096 cmd->keepalive_inc = appType2Params->keepalive_inc;
10097
10098 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10099 &cmd->gateway_mac);
10100 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10101 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10102
Govind Singhb53420c2016-03-09 14:32:57 +053010103 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 "rc4_key %.16s rc4_key_len %u "
10105 "ip_id %x ip_device_ip %x ip_server_ip %x "
10106 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10107 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10108 "keepalive_max %u keepalive_inc %u "
10109 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10110 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10111 cmd->rc4_key, cmd->rc4_key_len,
10112 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10113 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10114 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10115 cmd->keepalive_max, cmd->keepalive_inc,
10116 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10117
10118 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10119 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10120 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010121 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010122 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010123 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010124 }
10125
Govind Singhb53420c2016-03-09 14:32:57 +053010126 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010127
10128}
10129
10130/**
10131 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10132 * @wmi_handle: wmi handle
10133 * @timer_val: auto shutdown timer value
10134 *
10135 * Return: CDF status
10136 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010137static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010138 uint32_t timer_val)
10139{
Govind Singh67922e82016-04-01 16:48:57 +053010140 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010141 wmi_buf_t buf = NULL;
10142 uint8_t *buf_ptr;
10143 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10144 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10145
Govind Singhb53420c2016-03-09 14:32:57 +053010146 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010147 __func__, timer_val);
10148
10149 buf = wmi_buf_alloc(wmi_handle, len);
10150 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010151 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10152 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010153 }
10154
10155 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10156 wmi_auto_sh_cmd =
10157 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10158 wmi_auto_sh_cmd->timer_value = timer_val;
10159
10160 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10161 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10162 WMITLV_GET_STRUCT_TLVLEN
10163 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10164
10165 status = wmi_unified_cmd_send(wmi_handle, buf,
10166 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010167 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010168 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010169 __func__, status);
10170 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010171 }
10172
Govind Singh67922e82016-04-01 16:48:57 +053010173 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010174}
10175
10176/**
10177 * send_nan_req_cmd_tlv() - to send nan request to target
10178 * @wmi_handle: wmi handle
10179 * @nan_req: request data which will be non-null
10180 *
10181 * Return: CDF status
10182 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010183static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010184 struct nan_req_params *nan_req)
10185{
Govind Singh67922e82016-04-01 16:48:57 +053010186 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010187 wmi_nan_cmd_param *cmd;
10188 wmi_buf_t buf;
10189 uint16_t len = sizeof(*cmd);
10190 uint16_t nan_data_len, nan_data_len_aligned;
10191 uint8_t *buf_ptr;
10192
10193 /*
10194 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10195 * +------------+----------+-----------------------+--------------+
10196 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10197 * +------------+----------+-----------------------+--------------+
10198 */
10199 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010200 WMI_LOGE("%s:nan req is not valid", __func__);
10201 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010202 }
10203 nan_data_len = nan_req->request_data_len;
10204 nan_data_len_aligned = roundup(nan_req->request_data_len,
10205 sizeof(uint32_t));
10206 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10207 buf = wmi_buf_alloc(wmi_handle, len);
10208 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010209 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10210 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010211 }
10212 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10213 cmd = (wmi_nan_cmd_param *) buf_ptr;
10214 WMITLV_SET_HDR(&cmd->tlv_header,
10215 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10216 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10217 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010218 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010219 __func__, nan_req->request_data_len);
10220 buf_ptr += sizeof(wmi_nan_cmd_param);
10221 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10222 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010223 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010224
10225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10226 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010227 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010228 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010229 __func__, ret);
10230 wmi_buf_free(buf);
10231 }
10232
10233 return ret;
10234}
10235
10236/**
10237 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10238 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010239 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010240 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010241 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010242 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010243static QDF_STATUS
10244send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10245 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010246{
10247 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10248 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010249 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010250
10251 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10252 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010253 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010254 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010255 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010256 }
10257
10258 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010259
10260 WMITLV_SET_HDR(&cmd->tlv_header,
10261 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10262 WMITLV_GET_STRUCT_TLVLEN
10263 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010264 cmd->vdev_id = params->vdev_id;
10265 cmd->enable = params->dhcp_offload_enabled;
10266 cmd->num_client = params->dhcp_client_num;
10267 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010268 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010269 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010270 sizeof(*cmd),
10271 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010272 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010273 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010274 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010275 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010276 }
Govind Singhb53420c2016-03-09 14:32:57 +053010277 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010278 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010279
10280 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010281}
10282
10283/**
10284 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10285 * @wmi_handle: wmi handle
10286 * @flashing: flashing request
10287 *
10288 * Return: CDF status
10289 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010290static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010291 struct flashing_req_params *flashing)
10292{
10293 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010294 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010295 wmi_buf_t buf;
10296 uint8_t *buf_ptr;
10297 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10298
10299 buf = wmi_buf_alloc(wmi_handle, len);
10300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010301 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010302 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010303 }
10304 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10305 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10306 WMITLV_SET_HDR(&cmd->tlv_header,
10307 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10308 WMITLV_GET_STRUCT_TLVLEN
10309 (wmi_set_led_flashing_cmd_fixed_param));
10310 cmd->pattern_id = flashing->pattern_id;
10311 cmd->led_x0 = flashing->led_x0;
10312 cmd->led_x1 = flashing->led_x1;
10313
10314 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10315 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010316 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010317 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010318 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010319 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010320 }
Govind Singh67922e82016-04-01 16:48:57 +053010321
10322 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010323}
10324
10325/**
10326 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10327 * @wmi_handle: wmi handle
10328 * @ch_avoid_update_req: channel avoid update params
10329 *
10330 * Return: CDF status
10331 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010332static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010333{
Govind Singh67922e82016-04-01 16:48:57 +053010334 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010335 wmi_buf_t buf = NULL;
10336 uint8_t *buf_ptr;
10337 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10338 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10339
10340
10341 buf = wmi_buf_alloc(wmi_handle, len);
10342 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010343 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10344 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010345 }
10346
10347 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10348 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10349 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10350 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10351 WMITLV_GET_STRUCT_TLVLEN
10352 (wmi_chan_avoid_update_cmd_param));
10353
10354 status = wmi_unified_cmd_send(wmi_handle, buf,
10355 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010356 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010357 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010358 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10359 " returned Error %d", status);
10360 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010361 }
10362
Govind Singh67922e82016-04-01 16:48:57 +053010363 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010364}
10365
10366/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010367 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10368 * @wmi_handle: wmi handle
10369 * @param: pointer to pdev regdomain params
10370 *
10371 * Return: 0 for success or error code
10372 */
10373static QDF_STATUS
10374send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10375 struct pdev_set_regdomain_params *param)
10376{
10377 wmi_buf_t buf;
10378 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10379 int32_t len = sizeof(*cmd);
10380
10381
10382 buf = wmi_buf_alloc(wmi_handle, len);
10383 if (!buf) {
10384 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10385 return QDF_STATUS_E_NOMEM;
10386 }
10387 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10388 WMITLV_SET_HDR(&cmd->tlv_header,
10389 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10390 WMITLV_GET_STRUCT_TLVLEN
10391 (wmi_pdev_set_regdomain_cmd_fixed_param));
10392
10393 cmd->reg_domain = param->currentRDinuse;
10394 cmd->reg_domain_2G = param->currentRD2G;
10395 cmd->reg_domain_5G = param->currentRD5G;
10396 cmd->conformance_test_limit_2G = param->ctl_2G;
10397 cmd->conformance_test_limit_5G = param->ctl_5G;
10398 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010399 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10400 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010401
10402 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10403 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10404 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10405 __func__);
10406 wmi_buf_free(buf);
10407 return QDF_STATUS_E_FAILURE;
10408 }
10409
10410 return QDF_STATUS_SUCCESS;
10411}
10412
10413/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010414 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10415 * @wmi_handle: wmi handle
10416 * @reg_dmn: reg domain
10417 * @regdmn2G: 2G reg domain
10418 * @regdmn5G: 5G reg domain
10419 * @ctl2G: 2G test limit
10420 * @ctl5G: 5G test limit
10421 *
10422 * Return: none
10423 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010424static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010425 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010426 uint16_t regdmn5G, uint8_t ctl2G,
10427 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010428{
10429 wmi_buf_t buf;
10430 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10431 int32_t len = sizeof(*cmd);
10432
10433
10434 buf = wmi_buf_alloc(wmi_handle, len);
10435 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010436 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10437 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010438 }
10439 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10440 WMITLV_SET_HDR(&cmd->tlv_header,
10441 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10442 WMITLV_GET_STRUCT_TLVLEN
10443 (wmi_pdev_set_regdomain_cmd_fixed_param));
10444 cmd->reg_domain = reg_dmn;
10445 cmd->reg_domain_2G = regdmn2G;
10446 cmd->reg_domain_5G = regdmn5G;
10447 cmd->conformance_test_limit_2G = ctl2G;
10448 cmd->conformance_test_limit_5G = ctl5G;
10449
10450 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10451 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010452 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010453 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010454 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010455 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010456 }
10457
Govind Singhb53420c2016-03-09 14:32:57 +053010458 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010459}
10460
10461
10462/**
10463 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10464 * @wmi_handle: wmi handle
10465 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10466 *
10467 * This function sets tdls off channel mode
10468 *
10469 * Return: 0 on success; Negative errno otherwise
10470 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010471static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010472 struct tdls_channel_switch_params *chan_switch_params)
10473{
10474 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10475 wmi_buf_t wmi_buf;
10476 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10477
10478 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10479 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010480 WMI_LOGE(FL("wmi_buf_alloc failed"));
10481 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010482 }
10483 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10484 wmi_buf_data(wmi_buf);
10485 WMITLV_SET_HDR(&cmd->tlv_header,
10486 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10487 WMITLV_GET_STRUCT_TLVLEN(
10488 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10489
10490 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10491 &cmd->peer_macaddr);
10492 cmd->vdev_id = chan_switch_params->vdev_id;
10493 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10494 cmd->is_peer_responder = chan_switch_params->is_responder;
10495 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10496 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10497 cmd->offchan_oper_class = chan_switch_params->oper_class;
10498
Govind Singhb53420c2016-03-09 14:32:57 +053010499 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010500 cmd->peer_macaddr.mac_addr31to0,
10501 cmd->peer_macaddr.mac_addr47to32);
10502
Govind Singhb53420c2016-03-09 14:32:57 +053010503 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010504 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10505 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10506 ),
10507 cmd->vdev_id,
10508 cmd->offchan_mode,
10509 cmd->offchan_num,
10510 cmd->offchan_bw_bitmap,
10511 cmd->is_peer_responder,
10512 cmd->offchan_oper_class);
10513
10514 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10515 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010516 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010517 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010518 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010519 }
10520
10521
Govind Singhb53420c2016-03-09 14:32:57 +053010522 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010523}
10524
10525/**
10526 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10527 * @wmi_handle: wmi handle
10528 * @pwmaTdlsparams: TDLS params
10529 *
10530 * Return: 0 for sucess or error code
10531 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010532static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010533 void *tdls_param, uint8_t tdls_state)
10534{
10535 wmi_tdls_set_state_cmd_fixed_param *cmd;
10536 wmi_buf_t wmi_buf;
10537
10538 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10539 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10540
10541 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10542 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010543 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10544 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010545 }
10546 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10547 WMITLV_SET_HDR(&cmd->tlv_header,
10548 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10549 WMITLV_GET_STRUCT_TLVLEN
10550 (wmi_tdls_set_state_cmd_fixed_param));
10551 cmd->vdev_id = wmi_tdls->vdev_id;
10552 cmd->state = tdls_state;
10553 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10554 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10555 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10556 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10557 cmd->rssi_delta = wmi_tdls->rssi_delta;
10558 cmd->tdls_options = wmi_tdls->tdls_options;
10559 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10560 cmd->tdls_peer_traffic_response_timeout_ms =
10561 wmi_tdls->peer_traffic_response_timeout;
10562 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10563 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10564 cmd->tdls_puapsd_rx_frame_threshold =
10565 wmi_tdls->puapsd_rx_frame_threshold;
10566 cmd->teardown_notification_ms =
10567 wmi_tdls->teardown_notification_ms;
10568 cmd->tdls_peer_kickout_threshold =
10569 wmi_tdls->tdls_peer_kickout_threshold;
10570
Govind Singhb53420c2016-03-09 14:32:57 +053010571 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010572 "notification_interval_ms: %d, "
10573 "tx_discovery_threshold: %d, "
10574 "tx_teardown_threshold: %d, "
10575 "rssi_teardown_threshold: %d, "
10576 "rssi_delta: %d, "
10577 "tdls_options: 0x%x, "
10578 "tdls_peer_traffic_ind_window: %d, "
10579 "tdls_peer_traffic_response_timeout: %d, "
10580 "tdls_puapsd_mask: 0x%x, "
10581 "tdls_puapsd_inactivity_time: %d, "
10582 "tdls_puapsd_rx_frame_threshold: %d, "
10583 "teardown_notification_ms: %d, "
10584 "tdls_peer_kickout_threshold: %d",
10585 __func__, tdls_state, cmd->state,
10586 cmd->notification_interval_ms,
10587 cmd->tx_discovery_threshold,
10588 cmd->tx_teardown_threshold,
10589 cmd->rssi_teardown_threshold,
10590 cmd->rssi_delta,
10591 cmd->tdls_options,
10592 cmd->tdls_peer_traffic_ind_window,
10593 cmd->tdls_peer_traffic_response_timeout_ms,
10594 cmd->tdls_puapsd_mask,
10595 cmd->tdls_puapsd_inactivity_time_ms,
10596 cmd->tdls_puapsd_rx_frame_threshold,
10597 cmd->teardown_notification_ms,
10598 cmd->tdls_peer_kickout_threshold);
10599
10600 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10601 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010602 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010603 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010604 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010605 }
Govind Singhb53420c2016-03-09 14:32:57 +053010606 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010607
Govind Singhb53420c2016-03-09 14:32:57 +053010608 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010609}
10610
10611/**
10612 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10613 * @wmi_handle: wmi handle
10614 * @peerStateParams: TDLS peer state params
10615 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010616 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010617 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010618static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010619 struct tdls_peer_state_params *peerStateParams,
10620 uint32_t *ch_mhz)
10621{
10622 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10623 wmi_tdls_peer_capabilities *peer_cap;
10624 wmi_channel *chan_info;
10625 wmi_buf_t wmi_buf;
10626 uint8_t *buf_ptr;
10627 uint32_t i;
10628 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10629 sizeof(wmi_tdls_peer_capabilities);
10630
10631
10632 len += WMI_TLV_HDR_SIZE +
10633 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10634
10635 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10636 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010637 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10638 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010639 }
10640
10641 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10642 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10643 WMITLV_SET_HDR(&cmd->tlv_header,
10644 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10645 WMITLV_GET_STRUCT_TLVLEN
10646 (wmi_tdls_peer_update_cmd_fixed_param));
10647
10648 cmd->vdev_id = peerStateParams->vdevId;
10649 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10650 &cmd->peer_macaddr);
10651
10652
10653 cmd->peer_state = peerStateParams->peerState;
10654
Govind Singhb53420c2016-03-09 14:32:57 +053010655 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010656 "peer_macaddr.mac_addr31to0: 0x%x, "
10657 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10658 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10659 cmd->peer_macaddr.mac_addr31to0,
10660 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10661
10662 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10663 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10664 WMITLV_SET_HDR(&peer_cap->tlv_header,
10665 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10666 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10667
10668 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10669 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10670 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10671 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10672 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10673 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10674 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10675 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10676
10677 /* Ack and More Data Ack are sent as 0, so no need to set
10678 * but fill SP
10679 */
10680 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10681 peerStateParams->peerCap.peerMaxSp);
10682
10683 peer_cap->buff_sta_support =
10684 peerStateParams->peerCap.peerBuffStaSupport;
10685 peer_cap->off_chan_support =
10686 peerStateParams->peerCap.peerOffChanSupport;
10687 peer_cap->peer_curr_operclass =
10688 peerStateParams->peerCap.peerCurrOperClass;
10689 /* self curr operclass is not being used and so pass op class for
10690 * preferred off chan in it.
10691 */
10692 peer_cap->self_curr_operclass =
10693 peerStateParams->peerCap.opClassForPrefOffChan;
10694 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10695 peer_cap->peer_operclass_len =
10696 peerStateParams->peerCap.peerOperClassLen;
10697
Govind Singhb53420c2016-03-09 14:32:57 +053010698 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010699 __func__, peer_cap->peer_operclass_len);
10700 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10701 peer_cap->peer_operclass[i] =
10702 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010703 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010704 __func__, i, peer_cap->peer_operclass[i]);
10705 }
10706
10707 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10708 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10709 peer_cap->pref_offchan_bw =
10710 peerStateParams->peerCap.prefOffChanBandwidth;
10711
Govind Singhb53420c2016-03-09 14:32:57 +053010712 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010713 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10714 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10715 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10716 " %d, pref_offchan_bw: %d",
10717 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10718 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10719 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10720 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10721 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10722
10723 /* next fill variable size array of peer chan info */
10724 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10725 WMITLV_SET_HDR(buf_ptr,
10726 WMITLV_TAG_ARRAY_STRUC,
10727 sizeof(wmi_channel) *
10728 peerStateParams->peerCap.peerChanLen);
10729 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10730
10731 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10732 WMITLV_SET_HDR(&chan_info->tlv_header,
10733 WMITLV_TAG_STRUC_wmi_channel,
10734 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10735 chan_info->mhz = ch_mhz[i];
10736 chan_info->band_center_freq1 = chan_info->mhz;
10737 chan_info->band_center_freq2 = 0;
10738
Govind Singhb53420c2016-03-09 14:32:57 +053010739 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010740
10741 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10742 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010743 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010744 peerStateParams->peerCap.peerChan[i].chanId,
10745 peerStateParams->peerCap.peerChan[i].dfsSet);
10746 }
10747
10748 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10749 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10750 else
10751 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10752
10753 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10754 peerStateParams->peerCap.
10755 peerChan[i].pwr);
10756
10757 WMI_SET_CHANNEL_REG_POWER(chan_info,
10758 peerStateParams->peerCap.peerChan[i].
10759 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010760 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010761 peerStateParams->peerCap.peerChan[i].pwr);
10762
10763 chan_info++;
10764 }
10765
10766 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10767 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010768 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010769 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010770 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010771 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010772 }
10773
10774
Govind Singhb53420c2016-03-09 14:32:57 +053010775 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010776}
10777
10778/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010779 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10780 * @wmi_handle: Pointer to WMi handle
10781 * @ie_data: Pointer for ie data
10782 *
10783 * This function sends IE information to firmware
10784 *
Govind Singhb53420c2016-03-09 14:32:57 +053010785 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010786 *
10787 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010788static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010789 struct vdev_ie_info_param *ie_info)
10790{
10791 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10792 wmi_buf_t buf;
10793 uint8_t *buf_ptr;
10794 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010795 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010796
10797
10798 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10799 /* Allocate memory for the WMI command */
10800 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10801
10802 buf = wmi_buf_alloc(wmi_handle, len);
10803 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010804 WMI_LOGE(FL("wmi_buf_alloc failed"));
10805 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010806 }
10807
10808 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010809 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010810
10811 /* Populate the WMI command */
10812 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10813
10814 WMITLV_SET_HDR(&cmd->tlv_header,
10815 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10816 WMITLV_GET_STRUCT_TLVLEN(
10817 wmi_vdev_set_ie_cmd_fixed_param));
10818 cmd->vdev_id = ie_info->vdev_id;
10819 cmd->ie_id = ie_info->ie_id;
10820 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010821 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010822
Govind Singhb53420c2016-03-09 14:32:57 +053010823 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010824 ie_info->length, ie_info->vdev_id);
10825
10826 buf_ptr += sizeof(*cmd);
10827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10828 buf_ptr += WMI_TLV_HDR_SIZE;
10829
Govind Singhb53420c2016-03-09 14:32:57 +053010830 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010831
10832 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10833 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010834 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010835 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010836 wmi_buf_free(buf);
10837 }
10838
10839 return ret;
10840}
10841
Sathish Kumar497bef42017-03-01 14:02:36 +053010842/**
10843 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10844 *
10845 * @param wmi_handle : handle to WMI.
10846 * @param param : pointer to antenna param
10847 *
10848 * This function sends smart antenna enable command to FW
10849 *
10850 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10851 */
10852static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10853 struct smart_ant_enable_params *param)
10854{
10855 /* Send WMI COMMAND to Enable */
10856 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10857 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10858 wmi_buf_t buf;
10859 uint8_t *buf_ptr;
10860 int len = 0;
10861 QDF_STATUS ret;
10862 int loop = 0;
10863
10864 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10865 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10866 buf = wmi_buf_alloc(wmi_handle, len);
10867
10868 if (!buf) {
10869 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10870 return QDF_STATUS_E_NOMEM;
10871 }
10872
10873 buf_ptr = wmi_buf_data(buf);
10874 qdf_mem_zero(buf_ptr, len);
10875 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10876
10877 WMITLV_SET_HDR(&cmd->tlv_header,
10878 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10879 WMITLV_GET_STRUCT_TLVLEN(
10880 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10881
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010882 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10883 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010884 cmd->enable = param->enable;
10885 cmd->mode = param->mode;
10886 cmd->rx_antenna = param->rx_antenna;
10887 cmd->tx_default_antenna = param->rx_antenna;
10888
10889 /* TLV indicating array of structures to follow */
10890 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10892 WMI_HAL_MAX_SANTENNA *
10893 sizeof(wmi_pdev_smart_ant_gpio_handle));
10894
10895 buf_ptr += WMI_TLV_HDR_SIZE;
10896 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10897
10898 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10899 WMITLV_SET_HDR(&gpio_param->tlv_header,
10900 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10901 WMITLV_GET_STRUCT_TLVLEN(
10902 wmi_pdev_smart_ant_gpio_handle));
10903 if (param->mode == SMART_ANT_MODE_SERIAL) {
10904 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10905 gpio_param->gpio_pin = param->gpio_pin[loop];
10906 gpio_param->gpio_func = param->gpio_func[loop];
10907 } else {
10908 gpio_param->gpio_pin = 0;
10909 gpio_param->gpio_func = 0;
10910 }
10911 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10912 gpio_param->gpio_pin = param->gpio_pin[loop];
10913 gpio_param->gpio_func = param->gpio_func[loop];
10914 }
10915 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010916 gpio_param->pdev_id =
10917 wmi_handle->ops->convert_pdev_id_host_to_target(
10918 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010919 gpio_param++;
10920 }
10921
10922 ret = wmi_unified_cmd_send(wmi_handle,
10923 buf,
10924 len,
10925 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10926
10927 if (ret != 0) {
10928 WMI_LOGE(" %s :WMI Failed\n", __func__);
10929 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10930 cmd->enable,
10931 cmd->mode,
10932 cmd->rx_antenna,
10933 param->gpio_pin[0], param->gpio_pin[1],
10934 param->gpio_pin[2], param->gpio_pin[3],
10935 param->gpio_func[0], param->gpio_func[1],
10936 param->gpio_func[2], param->gpio_func[3],
10937 ret);
10938 wmi_buf_free(buf);
10939 }
10940
10941 return ret;
10942}
10943
10944/**
10945 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10946 *
10947 * @param wmi_handle : handle to WMI.
10948 * @param param : pointer to rx antenna param
10949 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10950 */
10951static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10952 struct smart_ant_rx_ant_params *param)
10953{
10954 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10955 wmi_buf_t buf;
10956 uint8_t *buf_ptr;
10957 uint32_t len;
10958 QDF_STATUS ret;
10959
10960 len = sizeof(*cmd);
10961 buf = wmi_buf_alloc(wmi_handle, len);
10962 WMI_LOGD("%s:\n", __func__);
10963 if (!buf) {
10964 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10965 return QDF_STATUS_E_NOMEM;
10966 }
10967
10968 buf_ptr = wmi_buf_data(buf);
10969 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10970 WMITLV_SET_HDR(&cmd->tlv_header,
10971 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10972 WMITLV_GET_STRUCT_TLVLEN(
10973 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10974 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010975 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10976 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010977
10978 ret = wmi_unified_cmd_send(wmi_handle,
10979 buf,
10980 len,
10981 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10982
10983 if (ret != 0) {
10984 WMI_LOGE(" %s :WMI Failed\n", __func__);
10985 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10986 __func__,
10987 cmd->rx_antenna,
10988 ret);
10989 wmi_buf_free(buf);
10990 }
10991
10992 return ret;
10993}
10994
10995/**
10996 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10997 * @wmi_handle: wmi handle
10998 * @param: pointer to hold ctl table param
10999 *
11000 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11001 */
11002static QDF_STATUS
11003send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11004 struct ctl_table_params *param)
11005{
11006 uint16_t len, ctl_tlv_len;
11007 uint8_t *buf_ptr;
11008 wmi_buf_t buf;
11009 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11010 uint32_t *ctl_array;
11011
11012 if (!param->ctl_array)
11013 return QDF_STATUS_E_FAILURE;
11014
11015 if (param->ctl_cmd_len !=
11016 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
11017 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
11018 qdf_print("CTL array len not correct\n");
11019 return QDF_STATUS_E_FAILURE;
11020 }
11021
11022 ctl_tlv_len = WMI_TLV_HDR_SIZE +
11023 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
11024 len = sizeof(*cmd) + ctl_tlv_len;
11025
11026 buf = wmi_buf_alloc(wmi_handle, len);
11027 if (!buf) {
11028 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11029 return QDF_STATUS_E_FAILURE;
11030 }
11031
11032 buf_ptr = wmi_buf_data(buf);
11033 qdf_mem_zero(buf_ptr, len);
11034
11035 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11036
11037 WMITLV_SET_HDR(&cmd->tlv_header,
11038 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11039 WMITLV_GET_STRUCT_TLVLEN(
11040 wmi_pdev_set_ctl_table_cmd_fixed_param));
11041 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011042 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11043 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011044
11045 buf_ptr += sizeof(*cmd);
11046 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11047 (cmd->ctl_len));
11048 buf_ptr += WMI_TLV_HDR_SIZE;
11049 ctl_array = (uint32_t *)buf_ptr;
11050
11051 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11052 sizeof(param->ctl_band));
11053 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11054 param->ctl_cmd_len -
11055 sizeof(param->ctl_band));
11056
11057 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11058 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11059 WMI_LOGE("%s:Failed to send command\n", __func__);
11060 wmi_buf_free(buf);
11061 return QDF_STATUS_E_FAILURE;
11062 }
11063
11064 return QDF_STATUS_SUCCESS;
11065}
11066
11067/**
11068 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11069 * @wmi_handle: wmi handle
11070 * @param: pointer to hold mimogain table param
11071 *
11072 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11073 */
11074static QDF_STATUS
11075send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11076 struct mimogain_table_params *param)
11077{
11078 uint16_t len, table_tlv_len;
11079 wmi_buf_t buf;
11080 uint8_t *buf_ptr;
11081 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11082 uint32_t *gain_table;
11083
11084 if (!param->array_gain)
11085 return QDF_STATUS_E_FAILURE;
11086
11087 /* len must be multiple of a single array gain table */
11088 if (param->tbl_len %
11089 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11090 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11091 WMI_LOGE("Array gain table len not correct\n");
11092 return QDF_STATUS_E_FAILURE;
11093 }
11094
11095 table_tlv_len = WMI_TLV_HDR_SIZE +
11096 roundup(param->tbl_len, sizeof(uint32_t));
11097 len = sizeof(*cmd) + table_tlv_len;
11098
11099 buf = wmi_buf_alloc(wmi_handle, len);
11100 if (!buf) {
11101 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11102 return QDF_STATUS_E_FAILURE;
11103 }
11104
11105 buf_ptr = wmi_buf_data(buf);
11106 qdf_mem_zero(buf_ptr, len);
11107
11108 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11109
11110 WMITLV_SET_HDR(&cmd->tlv_header,
11111 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11112 WMITLV_GET_STRUCT_TLVLEN(
11113 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11114
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011115 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11116 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011117 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11118 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11119 param->multichain_gain_bypass);
11120
11121 buf_ptr += sizeof(*cmd);
11122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11123 (param->tbl_len));
11124 buf_ptr += WMI_TLV_HDR_SIZE;
11125 gain_table = (uint32_t *)buf_ptr;
11126
11127 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11128 param->array_gain,
11129 param->tbl_len);
11130
11131 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11132 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11133 return QDF_STATUS_E_FAILURE;
11134 }
11135
11136 return QDF_STATUS_SUCCESS;
11137}
11138
11139/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011140 * enum packet_power_tlv_flags: target defined
11141 * packet power rate flags for TLV
11142 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11143 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11144 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11145 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11146 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11147 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11148 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11149 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11150 * @WMI_TLV_FLAG_STBC: STBC is set
11151 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11152 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11153 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11154 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11155 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11156 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11157 * @WMI_TLV_FLAG_LDPC: LDPC is set
11158 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11159 * @WMI_TLV_FLAG_SU: SU Data
11160 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11161 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11162 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11163 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11164 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11165 *
11166 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11167 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11168 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11169 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11170 */
11171enum packet_power_tlv_flags {
11172 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11173 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11174 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11175 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11176 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11177 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11178 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11179 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11180 WMI_TLV_FLAG_STBC = 0x00000100,
11181 WMI_TLV_FLAG_40MHZ = 0x00000200,
11182 WMI_TLV_FLAG_80MHZ = 0x00000300,
11183 WMI_TLV_FLAG_160MHZ = 0x00000400,
11184 WMI_TLV_FLAG_TXBF = 0x00000800,
11185 WMI_TLV_FLAG_RTSENA = 0x00001000,
11186 WMI_TLV_FLAG_CTSENA = 0x00002000,
11187 WMI_TLV_FLAG_LDPC = 0x00004000,
11188 WMI_TLV_FLAG_SGI = 0x00008000,
11189 WMI_TLV_FLAG_SU = 0x00100000,
11190 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11191 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11192 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11193 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11194 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11195
11196 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11197 WMI_TLV_FLAG_BW_MASK = 0x3,
11198 WMI_TLV_FLAG_BW_SHIFT = 9,
11199 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11200 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11201};
11202
11203/**
11204 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11205 * to FW understandable format
11206 * @param: pointer to hold packet power info param
11207 *
11208 * @return FW understandable 32 bit rate flags
11209 */
11210static uint32_t
11211convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11212{
11213 uint32_t rateflags = 0;
11214
11215 if (param->chainmask)
11216 rateflags |=
11217 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11218 if (param->chan_width)
11219 rateflags |=
11220 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11221 << WMI_TLV_FLAG_BW_SHIFT);
11222 if (param->su_mu_ofdma)
11223 rateflags |=
11224 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11225 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11226 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11227 rateflags |= WMI_TLV_FLAG_STBC;
11228 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11229 rateflags |= WMI_TLV_FLAG_LDPC;
11230 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11231 rateflags |= WMI_TLV_FLAG_TXBF;
11232 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11233 rateflags |= WMI_TLV_FLAG_RTSENA;
11234 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11235 rateflags |= WMI_TLV_FLAG_CTSENA;
11236 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11237 rateflags |= WMI_TLV_FLAG_SGI;
11238
11239 return rateflags;
11240}
11241
11242/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011243 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11244 * info to fw
11245 * @wmi_handle: wmi handle
11246 * @param: pointer to hold packet power info param
11247 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011248 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011249 */
11250static QDF_STATUS
11251send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11252 struct packet_power_info_params *param)
11253{
11254 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11255 wmi_buf_t wmibuf;
11256 uint8_t *buf_ptr;
11257 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11258
11259 wmibuf = wmi_buf_alloc(wmi_handle, len);
11260 if (wmibuf == NULL)
11261 return QDF_STATUS_E_NOMEM;
11262
11263 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11264
11265 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11266 WMITLV_SET_HDR(&cmd->tlv_header,
11267 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11268 WMITLV_GET_STRUCT_TLVLEN(
11269 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011270 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11271 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011272 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011273 cmd->nss = param->nss;
11274 cmd->preamble = param->preamble;
11275 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011276
11277 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11278 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11279 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11280 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11281
Sathish Kumar497bef42017-03-01 14:02:36 +053011282 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11283 WMI_PDEV_GET_TPC_CMDID)) {
11284 WMI_LOGE(FL("Failed to get tpc command\n"));
11285 wmi_buf_free(wmibuf);
11286 return QDF_STATUS_E_FAILURE;
11287 }
11288
11289 return QDF_STATUS_SUCCESS;
11290}
11291
11292/**
11293 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11294 * @wmi_handle: wmi handle
11295 * @param: pointer to hold config ratemask params
11296 *
11297 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11298 */
11299static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11300 struct config_ratemask_params *param)
11301{
11302 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11303 wmi_buf_t buf;
11304 int32_t len = sizeof(*cmd);
11305
11306 buf = wmi_buf_alloc(wmi_handle, len);
11307 if (!buf) {
11308 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11309 return QDF_STATUS_E_FAILURE;
11310 }
11311 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11312 WMITLV_SET_HDR(&cmd->tlv_header,
11313 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11314 WMITLV_GET_STRUCT_TLVLEN(
11315 wmi_vdev_config_ratemask_cmd_fixed_param));
11316 cmd->vdev_id = param->vdev_id;
11317 cmd->type = param->type;
11318 cmd->mask_lower32 = param->lower32;
11319 cmd->mask_higher32 = param->higher32;
11320 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11321 param->vdev_id, param->type, param->lower32, param->higher32);
11322
11323 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11324 WMI_VDEV_RATEMASK_CMDID)) {
11325 WMI_LOGE("Seting vdev ratemask failed\n");
11326 wmi_buf_free(buf);
11327 return QDF_STATUS_E_FAILURE;
11328 }
11329
11330 return QDF_STATUS_SUCCESS;
11331}
11332
11333/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011334 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11335 * @param: param sent from the host side
11336 * @cmd: param to be sent to the fw side
11337 */
11338static inline void copy_custom_aggr_bitmap(
11339 struct set_custom_aggr_size_params *param,
11340 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11341{
11342 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11343 param->ac);
11344 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11345 param->aggr_type);
11346 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11347 param->tx_aggr_size_disable);
11348 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11349 param->rx_aggr_size_disable);
11350 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11351 param->tx_ac_enable);
11352}
11353
11354/**
11355 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11356 * @wmi_handle: wmi handle
11357 * @param: pointer to hold custom aggr size params
11358 *
11359 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11360 */
11361static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11362 wmi_unified_t wmi_handle,
11363 struct set_custom_aggr_size_params *param)
11364{
11365 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11366 wmi_buf_t buf;
11367 int32_t len = sizeof(*cmd);
11368
11369 buf = wmi_buf_alloc(wmi_handle, len);
11370 if (!buf) {
11371 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11372 return QDF_STATUS_E_FAILURE;
11373 }
11374 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11375 wmi_buf_data(buf);
11376 WMITLV_SET_HDR(&cmd->tlv_header,
11377 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11378 WMITLV_GET_STRUCT_TLVLEN(
11379 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11380 cmd->vdev_id = param->vdev_id;
11381 cmd->tx_aggr_size = param->tx_aggr_size;
11382 cmd->rx_aggr_size = param->rx_aggr_size;
11383 copy_custom_aggr_bitmap(param, cmd);
11384
11385 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11386 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11387 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11388 "tx_ac_enable=0x%X\n",
11389 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11390 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11391 param->rx_aggr_size_disable, param->tx_ac_enable);
11392
11393 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11394 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11395 WMI_LOGE("Seting custom aggregation size failed\n");
11396 wmi_buf_free(buf);
11397 return QDF_STATUS_E_FAILURE;
11398 }
11399
11400 return QDF_STATUS_SUCCESS;
11401}
11402
11403/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011404 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11405 * @param wmi_handle : handle to WMI.
11406 * @param param : pointer to tx antenna param
11407 *
11408 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11409 */
11410
11411static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11412 struct set_qdepth_thresh_params *param)
11413{
11414 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11415 wmi_msduq_qdepth_thresh_update *cmd_update;
11416 wmi_buf_t buf;
11417 int32_t len = 0;
11418 int i;
11419 uint8_t *buf_ptr;
11420 QDF_STATUS ret;
11421
11422 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11423 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11424 return QDF_STATUS_E_INVAL;
11425 }
11426
11427 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11428 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11429 param->num_of_msduq_updates);
11430 buf = wmi_buf_alloc(wmi_handle, len);
11431
11432 if (!buf) {
11433 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11434 return QDF_STATUS_E_NOMEM;
11435 }
11436
11437 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11438 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11439 buf_ptr;
11440
11441 WMITLV_SET_HDR(&cmd->tlv_header,
11442 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11443 , WMITLV_GET_STRUCT_TLVLEN(
11444 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11445
11446 cmd->pdev_id =
11447 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11448 cmd->vdev_id = param->vdev_id;
11449 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11450 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11451
11452 buf_ptr += sizeof(
11453 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11454 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11455 param->num_of_msduq_updates *
11456 sizeof(wmi_msduq_qdepth_thresh_update));
11457 buf_ptr += WMI_TLV_HDR_SIZE;
11458 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11459
11460 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11461 WMITLV_SET_HDR(&cmd_update->tlv_header,
11462 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11463 WMITLV_GET_STRUCT_TLVLEN(
11464 wmi_msduq_qdepth_thresh_update));
11465 cmd_update->tid_num = param->update_params[i].tid_num;
11466 cmd_update->msduq_update_mask =
11467 param->update_params[i].msduq_update_mask;
11468 cmd_update->qdepth_thresh_value =
11469 param->update_params[i].qdepth_thresh_value;
11470 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11471 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11472 " update mask=0x%X thresh val=0x%X\n",
11473 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11474 cmd->peer_mac_address.mac_addr31to0,
11475 cmd->peer_mac_address.mac_addr47to32,
11476 cmd_update->msduq_update_mask,
11477 cmd_update->qdepth_thresh_value);
11478 cmd_update++;
11479 }
11480
11481 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11482 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11483
11484 if (ret != 0) {
11485 WMI_LOGE(" %s :WMI Failed\n", __func__);
11486 wmi_buf_free(buf);
11487 }
11488
11489 return ret;
11490}
11491
11492/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011493 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11494 * @wmi_handle: wmi handle
11495 * @param: pointer to hold vap dscp tid map param
11496 *
11497 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11498 */
11499static QDF_STATUS
11500send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11501 struct vap_dscp_tid_map_params *param)
11502{
11503 wmi_buf_t buf;
11504 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11505 int32_t len = sizeof(*cmd);
11506
11507 buf = wmi_buf_alloc(wmi_handle, len);
11508 if (!buf) {
11509 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11510 return QDF_STATUS_E_FAILURE;
11511 }
11512
11513 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11514 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
11515 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
11516
11517 cmd->vdev_id = param->vdev_id;
11518 cmd->enable_override = 0;
11519
11520 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11521 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11522 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11523 WMI_LOGE("Failed to set dscp cmd\n");
11524 wmi_buf_free(buf);
11525 return QDF_STATUS_E_FAILURE;
11526 }
11527
11528 return QDF_STATUS_SUCCESS;
11529}
11530
11531/**
11532 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11533 * @wmi_handle: wmi handle
11534 * @macaddr: vdev mac address
11535 * @param: pointer to hold neigbour rx param
11536 *
11537 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11538 */
11539static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11540 uint8_t macaddr[IEEE80211_ADDR_LEN],
11541 struct set_neighbour_rx_params *param)
11542{
11543 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11544 wmi_buf_t buf;
11545 int32_t len = sizeof(*cmd);
11546
11547 buf = wmi_buf_alloc(wmi_handle, len);
11548 if (!buf) {
11549 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11550 return QDF_STATUS_E_FAILURE;
11551 }
11552 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11553 WMITLV_SET_HDR(&cmd->tlv_header,
11554 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11555 WMITLV_GET_STRUCT_TLVLEN(
11556 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11557 cmd->vdev_id = param->vdev_id;
11558 cmd->bssid_idx = param->idx;
11559 cmd->action = param->action;
11560 cmd->type = param->type;
11561 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11562 cmd->flag = 0;
11563
11564 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11565 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11566 WMI_LOGE("Failed to set neighbour rx param\n");
11567 wmi_buf_free(buf);
11568 return QDF_STATUS_E_FAILURE;
11569 }
11570
11571 return QDF_STATUS_SUCCESS;
11572}
11573
11574/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011575 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011576 * @param wmi_handle : handle to WMI.
11577 * @param macaddr : vdev mac address
11578 * @param param : pointer to tx antenna param
11579 *
11580 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11581 */
11582static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11583 uint8_t macaddr[IEEE80211_ADDR_LEN],
11584 struct smart_ant_tx_ant_params *param)
11585{
11586 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11587 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11588 wmi_buf_t buf;
11589 int32_t len = 0;
11590 int i;
11591 uint8_t *buf_ptr;
11592 QDF_STATUS ret;
11593
11594 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11595 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11596 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11597 buf = wmi_buf_alloc(wmi_handle, len);
11598
11599 if (!buf) {
11600 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11601 return QDF_STATUS_E_NOMEM;
11602 }
11603
11604 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11605 qdf_mem_zero(buf_ptr, len);
11606 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11607
11608 WMITLV_SET_HDR(&cmd->tlv_header,
11609 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11610 WMITLV_GET_STRUCT_TLVLEN(
11611 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11612
11613 cmd->vdev_id = param->vdev_id;
11614 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11615
11616 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11618 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11619 buf_ptr += WMI_TLV_HDR_SIZE;
11620 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11621
11622 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11623 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11624 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11625 WMITLV_GET_STRUCT_TLVLEN(
11626 wmi_peer_smart_ant_set_tx_antenna_series));
11627 ant_tx_series->antenna_series = param->antenna_array[i];
11628 ant_tx_series++;
11629 }
11630
11631 ret = wmi_unified_cmd_send(wmi_handle,
11632 buf,
11633 len,
11634 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11635
11636 if (ret != 0) {
11637 WMI_LOGE(" %s :WMI Failed\n", __func__);
11638 wmi_buf_free(buf);
11639 }
11640
11641 return ret;
11642}
11643
Sathish Kumar02c3b542017-02-22 17:24:45 +053011644/**
11645 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11646 * @wmi_handle: wmi handle
11647 * @param: pointer to hold ant switch tbl param
11648 *
11649 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11650 */
11651static QDF_STATUS
11652send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11653 struct ant_switch_tbl_params *param)
11654{
11655 uint8_t len;
11656 wmi_buf_t buf;
11657 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11658 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11659 uint8_t *buf_ptr;
11660
11661 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11662 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11663 buf = wmi_buf_alloc(wmi_handle, len);
11664
11665 if (!buf) {
11666 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11667 return QDF_STATUS_E_NOMEM;
11668 }
11669
11670 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11671 qdf_mem_zero(buf_ptr, len);
11672 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11673
11674 WMITLV_SET_HDR(&cmd->tlv_header,
11675 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11676 WMITLV_GET_STRUCT_TLVLEN(
11677 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11678
11679 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11680 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011681 cmd->mac_id =
11682 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011683
11684 /* TLV indicating array of structures to follow */
11685 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11686 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11687 sizeof(wmi_pdev_set_ant_ctrl_chain));
11688 buf_ptr += WMI_TLV_HDR_SIZE;
11689 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11690
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011691 ctrl_chain->pdev_id =
11692 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011693 ctrl_chain->antCtrlChain = param->antCtrlChain;
11694
11695 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11696 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11697 wmi_buf_free(buf);
11698 return QDF_STATUS_E_FAILURE;
11699 }
11700
11701 return QDF_STATUS_SUCCESS;
11702}
11703
11704/**
11705 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11706 * training information function
11707 * @param wmi_handle : handle to WMI.
11708 * @macaddr : vdev mac address
11709 * @param param : pointer to tx antenna param
11710 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11711 */
11712static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11713 wmi_unified_t wmi_handle,
11714 uint8_t macaddr[IEEE80211_ADDR_LEN],
11715 struct smart_ant_training_info_params *param)
11716{
11717 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11718 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11719 wmi_buf_t buf;
11720 uint8_t *buf_ptr;
11721 int32_t len = 0;
11722 QDF_STATUS ret;
11723 int loop;
11724
11725 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11726 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11727 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11728 buf = wmi_buf_alloc(wmi_handle, len);
11729
11730 if (!buf) {
11731 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11732 return QDF_STATUS_E_NOMEM;
11733 }
11734
11735 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11736 qdf_mem_zero(buf_ptr, len);
11737 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11738
11739 WMITLV_SET_HDR(&cmd->tlv_header,
11740 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11741 WMITLV_GET_STRUCT_TLVLEN(
11742 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11743
11744 cmd->vdev_id = param->vdev_id;
11745 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11746 cmd->num_pkts = param->numpkts;
11747
11748 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11750 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11751 WMI_SMART_ANT_MAX_RATE_SERIES);
11752
11753 buf_ptr += WMI_TLV_HDR_SIZE;
11754 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11755
11756 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11757 WMITLV_SET_HDR(&train_param->tlv_header,
11758 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11759 WMITLV_GET_STRUCT_TLVLEN(
11760 wmi_peer_smart_ant_set_train_antenna_param));
11761 train_param->train_rate_series = param->rate_array[loop];
11762 train_param->train_antenna_series = param->antenna_array[loop];
11763 train_param->rc_flags = 0;
11764 WMI_LOGI(FL("Series number:%d\n"), loop);
11765 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11766 train_param->train_rate_series,
11767 train_param->train_antenna_series);
11768 train_param++;
11769 }
11770
11771 ret = wmi_unified_cmd_send(wmi_handle,
11772 buf,
11773 len,
11774 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11775
11776 if (ret != 0) {
11777 WMI_LOGE(" %s :WMI Failed\n", __func__);
11778 wmi_buf_free(buf);
11779 return QDF_STATUS_E_FAILURE;
11780 }
11781
11782 return ret;
11783}
11784
11785/**
11786 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11787 * configuration function
11788 * @param wmi_handle : handle to WMI.
11789 * @macaddr : vdev mad address
11790 * @param param : pointer to tx antenna param
11791 *
11792 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11793 */
11794static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11795 wmi_unified_t wmi_handle,
11796 uint8_t macaddr[IEEE80211_ADDR_LEN],
11797 struct smart_ant_node_config_params *param)
11798{
11799 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11800 wmi_buf_t buf;
11801 uint8_t *buf_ptr;
11802 int32_t len = 0, args_tlv_len;
11803 int ret;
11804 int i = 0;
11805 A_UINT32 *node_config_args;
11806
11807 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
11808 len = sizeof(*cmd) + args_tlv_len;
11809
11810 if ((param->args_count == 0)) {
11811 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11812 __func__, param->args_count);
11813 return QDF_STATUS_E_FAILURE;
11814 }
11815
11816 buf = wmi_buf_alloc(wmi_handle, len);
11817 if (!buf) {
11818 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11819 return QDF_STATUS_E_NOMEM;
11820 }
11821
11822 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11823 wmi_buf_data(buf);
11824 buf_ptr = (uint8_t *)cmd;
11825 WMITLV_SET_HDR(&cmd->tlv_header,
11826 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11827 WMITLV_GET_STRUCT_TLVLEN(
11828 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11829 cmd->vdev_id = param->vdev_id;
11830 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11831 cmd->cmd_id = param->cmd_id;
11832 cmd->args_count = param->args_count;
11833 buf_ptr += sizeof(
11834 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11835 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11836 (cmd->args_count * sizeof(A_UINT32)));
11837 buf_ptr += WMI_TLV_HDR_SIZE;
11838 node_config_args = (A_UINT32 *)buf_ptr;
11839
11840 for (i = 0; i < param->args_count; i++) {
11841 node_config_args[i] = param->args_arr[i];
11842 WMI_LOGI("%d", param->args_arr[i]);
11843 }
11844
11845 ret = wmi_unified_cmd_send(wmi_handle,
11846 buf,
11847 len,
11848 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11849
11850 if (ret != 0) {
11851 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11852 __func__, param->cmd_id, macaddr[0],
11853 macaddr[1], macaddr[2], macaddr[3],
11854 macaddr[4], macaddr[5], ret);
11855 wmi_buf_free(buf);
11856 }
11857
11858 return ret;
11859}
11860
11861/**
11862 * send_set_atf_cmd_tlv() - send set atf command to fw
11863 * @wmi_handle: wmi handle
11864 * @param: pointer to set atf param
11865 *
11866 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11867 */
11868static QDF_STATUS
11869send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11870 struct set_atf_params *param)
11871{
11872 wmi_atf_peer_info *peer_info;
11873 wmi_peer_atf_request_fixed_param *cmd;
11874 wmi_buf_t buf;
11875 uint8_t *buf_ptr;
11876 int i;
11877 int32_t len = 0;
11878 QDF_STATUS retval;
11879
11880 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11881 len += param->num_peers * sizeof(wmi_atf_peer_info);
11882 buf = wmi_buf_alloc(wmi_handle, len);
11883 if (!buf) {
11884 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11885 return QDF_STATUS_E_FAILURE;
11886 }
11887 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11888 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11889 WMITLV_SET_HDR(&cmd->tlv_header,
11890 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11891 WMITLV_GET_STRUCT_TLVLEN(
11892 wmi_peer_atf_request_fixed_param));
11893 cmd->num_peers = param->num_peers;
11894
11895 buf_ptr += sizeof(*cmd);
11896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11897 sizeof(wmi_atf_peer_info) *
11898 cmd->num_peers);
11899 buf_ptr += WMI_TLV_HDR_SIZE;
11900 peer_info = (wmi_atf_peer_info *)buf_ptr;
11901
11902 for (i = 0; i < cmd->num_peers; i++) {
11903 WMITLV_SET_HDR(&peer_info->tlv_header,
11904 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11905 WMITLV_GET_STRUCT_TLVLEN(
11906 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011907 qdf_mem_copy(&(peer_info->peer_macaddr),
11908 &(param->peer_info[i].peer_macaddr),
11909 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011910 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011911 peer_info->vdev_id = param->peer_info[i].vdev_id;
11912 peer_info->pdev_id =
11913 wmi_handle->ops->convert_pdev_id_host_to_target(
11914 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011915 /*
11916 * TLV definition for peer atf request fixed param combines
11917 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11918 * stats and atf extension stats as two different
11919 * implementations.
11920 * Need to discuss with FW on this.
11921 *
11922 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11923 * peer_info->atf_units_reserved =
11924 * param->peer_ext_info[i].atf_index_reserved;
11925 */
11926 peer_info++;
11927 }
11928
11929 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11930 WMI_PEER_ATF_REQUEST_CMDID);
11931
11932 if (retval != QDF_STATUS_SUCCESS) {
11933 WMI_LOGE("%s : WMI Failed\n", __func__);
11934 wmi_buf_free(buf);
11935 }
11936
11937 return retval;
11938}
11939
11940/**
11941 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11942 * @wmi_handle: wmi handle
11943 * @param: pointer to hold fwtest param
11944 *
11945 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11946 */
11947static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11948 struct set_fwtest_params *param)
11949{
11950 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11951 wmi_buf_t buf;
11952 int32_t len = sizeof(*cmd);
11953
11954 buf = wmi_buf_alloc(wmi_handle, len);
11955
11956 if (!buf) {
11957 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11958 return QDF_STATUS_E_FAILURE;
11959 }
11960
11961 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11962 WMITLV_SET_HDR(&cmd->tlv_header,
11963 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11964 WMITLV_GET_STRUCT_TLVLEN(
11965 wmi_fwtest_set_param_cmd_fixed_param));
11966 cmd->param_id = param->arg;
11967 cmd->param_value = param->value;
11968
11969 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11970 WMI_LOGE("Setting FW test param failed\n");
11971 wmi_buf_free(buf);
11972 return QDF_STATUS_E_FAILURE;
11973 }
11974
11975 return QDF_STATUS_SUCCESS;
11976}
11977
11978/**
11979 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11980 * @wmi_handle: wmi handle
11981 * @param: pointer to qboost params
11982 * @macaddr: vdev mac address
11983 *
11984 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11985 */
11986static QDF_STATUS
11987send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11988 uint8_t macaddr[IEEE80211_ADDR_LEN],
11989 struct set_qboost_params *param)
11990{
11991 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11992 wmi_buf_t buf;
11993 int32_t len;
11994 QDF_STATUS ret;
11995
11996 len = sizeof(*cmd);
11997
11998 buf = wmi_buf_alloc(wmi_handle, len);
11999 if (!buf) {
12000 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12001 return QDF_STATUS_E_FAILURE;
12002 }
12003
12004 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12005 WMITLV_SET_HDR(&cmd->tlv_header,
12006 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12007 WMITLV_GET_STRUCT_TLVLEN(
12008 WMI_QBOOST_CFG_CMD_fixed_param));
12009 cmd->vdev_id = param->vdev_id;
12010 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12011 cmd->qb_enable = param->value;
12012
12013 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12014 WMI_QBOOST_CFG_CMDID);
12015
12016 if (ret != 0) {
12017 WMI_LOGE("Setting qboost cmd failed\n");
12018 wmi_buf_free(buf);
12019 }
12020
12021 return ret;
12022}
12023
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012024/**
12025 * send_gpio_config_cmd_tlv() - send gpio config to fw
12026 * @wmi_handle: wmi handle
12027 * @param: pointer to hold gpio config param
12028 *
12029 * Return: 0 for success or error code
12030 */
12031static QDF_STATUS
12032send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12033 struct gpio_config_params *param)
12034{
12035 wmi_gpio_config_cmd_fixed_param *cmd;
12036 wmi_buf_t buf;
12037 int32_t len;
12038 QDF_STATUS ret;
12039
12040 len = sizeof(*cmd);
12041
12042 /* Sanity Checks */
12043 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12044 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12045 return QDF_STATUS_E_FAILURE;
12046 }
12047
12048 buf = wmi_buf_alloc(wmi_handle, len);
12049 if (!buf) {
12050 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12051 return QDF_STATUS_E_FAILURE;
12052 }
12053
12054 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12055 WMITLV_SET_HDR(&cmd->tlv_header,
12056 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12057 WMITLV_GET_STRUCT_TLVLEN(
12058 wmi_gpio_config_cmd_fixed_param));
12059 cmd->gpio_num = param->gpio_num;
12060 cmd->input = param->input;
12061 cmd->pull_type = param->pull_type;
12062 cmd->intr_mode = param->intr_mode;
12063
12064 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12065 WMI_GPIO_CONFIG_CMDID);
12066
12067 if (ret != 0) {
12068 WMI_LOGE("Sending GPIO config cmd failed\n");
12069 wmi_buf_free(buf);
12070 }
12071
12072 return ret;
12073}
12074
12075/**
12076 * send_gpio_output_cmd_tlv() - send gpio output to fw
12077 * @wmi_handle: wmi handle
12078 * @param: pointer to hold gpio output param
12079 *
12080 * Return: 0 for success or error code
12081 */
12082static QDF_STATUS
12083send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12084 struct gpio_output_params *param)
12085{
12086 wmi_gpio_output_cmd_fixed_param *cmd;
12087 wmi_buf_t buf;
12088 int32_t len;
12089 QDF_STATUS ret;
12090
12091 len = sizeof(*cmd);
12092
12093 buf = wmi_buf_alloc(wmi_handle, len);
12094 if (!buf) {
12095 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12096 return QDF_STATUS_E_FAILURE;
12097 }
12098
12099 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12100 WMITLV_SET_HDR(&cmd->tlv_header,
12101 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12102 WMITLV_GET_STRUCT_TLVLEN(
12103 wmi_gpio_output_cmd_fixed_param));
12104 cmd->gpio_num = param->gpio_num;
12105 cmd->set = param->set;
12106
12107 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12108 WMI_GPIO_OUTPUT_CMDID);
12109
12110 if (ret != 0) {
12111 WMI_LOGE("Sending GPIO output cmd failed\n");
12112 wmi_buf_free(buf);
12113 }
12114
12115 return ret;
12116
12117}
12118
12119/**
12120 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12121 *
12122 * @param wmi_handle : handle to WMI.
12123 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12124 */
12125static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12126{
12127 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12128 wmi_buf_t buf;
12129 QDF_STATUS ret;
12130 int32_t len;
12131
12132 len = sizeof(*cmd);
12133
12134 buf = wmi_buf_alloc(wmi_handle, len);
12135 if (!buf) {
12136 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12137 return QDF_STATUS_E_FAILURE;
12138 }
12139
12140 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12141 WMITLV_SET_HDR(&cmd->tlv_header,
12142 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12143 WMITLV_GET_STRUCT_TLVLEN(
12144 wmi_pdev_dfs_disable_cmd_fixed_param));
12145 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012146 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12147 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012148
12149 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12150 WMI_PDEV_DFS_DISABLE_CMDID);
12151
12152 if (ret != 0) {
12153 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12154 wmi_buf_free(buf);
12155 }
12156
12157 return ret;
12158}
12159
12160/**
12161 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12162 *
12163 * @param wmi_handle : handle to WMI.
12164 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12165 */
12166static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12167{
12168 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12169 wmi_buf_t buf;
12170 QDF_STATUS ret;
12171 int32_t len;
12172
12173 len = sizeof(*cmd);
12174
12175 buf = wmi_buf_alloc(wmi_handle, len);
12176 if (!buf) {
12177 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12178 return QDF_STATUS_E_FAILURE;
12179 }
12180
12181 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12182 WMITLV_SET_HDR(&cmd->tlv_header,
12183 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12184 WMITLV_GET_STRUCT_TLVLEN(
12185 wmi_pdev_dfs_enable_cmd_fixed_param));
12186 /* Reserved for future use */
12187 cmd->reserved0 = 0;
12188
12189 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12190 WMI_PDEV_DFS_ENABLE_CMDID);
12191
12192 if (ret != 0) {
12193 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12194 wmi_buf_free(buf);
12195 }
12196
12197 return ret;
12198}
12199
12200/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012201 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12202 * to fw
12203 * @wmi_handle: wmi handle
12204 * @param: pointer to hold periodic chan stats param
12205 *
12206 * Return: 0 for success or error code
12207 */
12208static QDF_STATUS
12209send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12210 struct periodic_chan_stats_params *param)
12211{
12212 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12213 wmi_buf_t buf;
12214 QDF_STATUS ret;
12215 int32_t len;
12216
12217 len = sizeof(*cmd);
12218
12219 buf = wmi_buf_alloc(wmi_handle, len);
12220 if (!buf) {
12221 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12222 return QDF_STATUS_E_FAILURE;
12223 }
12224
12225 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12226 wmi_buf_data(buf);
12227 WMITLV_SET_HDR(&cmd->tlv_header,
12228 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12229 WMITLV_GET_STRUCT_TLVLEN(
12230 wmi_set_periodic_channel_stats_config_fixed_param));
12231 cmd->enable = param->enable;
12232 cmd->stats_period = param->stats_period;
12233 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12234 param->pdev_id);
12235
12236 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12237 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12238
12239 if (ret != 0) {
12240 WMI_LOGE("Sending periodic chan stats config failed");
12241 wmi_buf_free(buf);
12242 }
12243
12244 return ret;
12245}
12246
12247/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012248 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12249 * @wmi_handle: wmi handle
12250 *
12251 * Return: 0 for success or error code
12252 */
12253static QDF_STATUS
12254send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
12255{
12256 wmi_buf_t buf;
12257 QDF_STATUS ret;
12258
12259 buf = wmi_buf_alloc(wmi_handle, 0);
12260 if (buf == NULL)
12261 return QDF_STATUS_E_NOMEM;
12262
12263 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
12264 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12265 if (ret != 0) {
12266 WMI_LOGE("Sending get nfcal power cmd failed\n");
12267 wmi_buf_free(buf);
12268 }
12269
12270 return ret;
12271}
12272
12273/**
12274 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12275 * @wmi_handle: wmi handle
12276 * @param: pointer to ht ie param
12277 *
12278 * Return: 0 for success or error code
12279 */
12280static QDF_STATUS
12281send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12282 struct ht_ie_params *param)
12283{
12284 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12285 wmi_buf_t buf;
12286 QDF_STATUS ret;
12287 int32_t len;
12288 uint8_t *buf_ptr;
12289
12290 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12291 roundup(param->ie_len, sizeof(uint32_t));
12292
12293 buf = wmi_buf_alloc(wmi_handle, len);
12294 if (!buf) {
12295 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12296 return QDF_STATUS_E_FAILURE;
12297 }
12298
12299 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12300 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12301 WMITLV_SET_HDR(&cmd->tlv_header,
12302 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12303 WMITLV_GET_STRUCT_TLVLEN(
12304 wmi_pdev_set_ht_ie_cmd_fixed_param));
12305 cmd->reserved0 = 0;
12306 cmd->ie_len = param->ie_len;
12307 cmd->tx_streams = param->tx_streams;
12308 cmd->rx_streams = param->rx_streams;
12309
12310 buf_ptr += sizeof(*cmd);
12311 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12312 buf_ptr += WMI_TLV_HDR_SIZE;
12313 if (param->ie_len)
12314 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12315 cmd->ie_len);
12316
12317 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12318 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12319
12320 if (ret != 0) {
12321 WMI_LOGE("Sending set ht ie cmd failed\n");
12322 wmi_buf_free(buf);
12323 }
12324
12325 return ret;
12326}
12327
12328/**
12329 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12330 * @wmi_handle: wmi handle
12331 * @param: pointer to vht ie param
12332 *
12333 * Return: 0 for success or error code
12334 */
12335static QDF_STATUS
12336send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12337 struct vht_ie_params *param)
12338{
12339 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12340 wmi_buf_t buf;
12341 QDF_STATUS ret;
12342 int32_t len;
12343 uint8_t *buf_ptr;
12344
12345 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12346 roundup(param->ie_len, sizeof(uint32_t));
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 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12355 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12356 WMITLV_SET_HDR(&cmd->tlv_header,
12357 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12358 WMITLV_GET_STRUCT_TLVLEN(
12359 wmi_pdev_set_vht_ie_cmd_fixed_param));
12360 cmd->reserved0 = 0;
12361 cmd->ie_len = param->ie_len;
12362 cmd->tx_streams = param->tx_streams;
12363 cmd->rx_streams = param->rx_streams;
12364
12365 buf_ptr += sizeof(*cmd);
12366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12367 buf_ptr += WMI_TLV_HDR_SIZE;
12368 if (param->ie_len)
12369 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12370 cmd->ie_len);
12371
12372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12373 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12374
12375 if (ret != 0) {
12376 WMI_LOGE("Sending set vht ie cmd failed\n");
12377 wmi_buf_free(buf);
12378 }
12379
12380 return ret;
12381}
12382
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012383/**
12384 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12385 * @wmi_handle: wmi handle
12386 * @param: pointer to quiet mode params
12387 *
12388 * Return: 0 for success or error code
12389 */
12390static QDF_STATUS
12391send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12392 struct set_quiet_mode_params *param)
12393{
12394 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12395 wmi_buf_t buf;
12396 QDF_STATUS ret;
12397 int32_t len;
12398
12399 len = sizeof(*quiet_cmd);
12400 buf = wmi_buf_alloc(wmi_handle, len);
12401 if (!buf) {
12402 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12403 return QDF_STATUS_E_FAILURE;
12404 }
12405
12406 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12407 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12408 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12409 WMITLV_GET_STRUCT_TLVLEN(
12410 wmi_pdev_set_quiet_cmd_fixed_param));
12411 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12412 quiet_cmd->enabled = param->enabled;
12413 quiet_cmd->period = (param->period)*(param->intval);
12414 quiet_cmd->duration = param->duration;
12415 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012416 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12417 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012418
12419 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12420 WMI_PDEV_SET_QUIET_MODE_CMDID);
12421
12422 if (ret != 0) {
12423 WMI_LOGE("Sending set quiet cmd failed\n");
12424 wmi_buf_free(buf);
12425 }
12426
12427 return ret;
12428}
12429
12430/**
12431 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12432 * @wmi_handle: wmi handle
12433 * @param: pointer to set bwf param
12434 *
12435 * Return: 0 for success or error code
12436 */
12437static QDF_STATUS
12438send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12439 struct set_bwf_params *param)
12440{
12441 wmi_bwf_peer_info *peer_info;
12442 wmi_peer_bwf_request_fixed_param *cmd;
12443 wmi_buf_t buf;
12444 QDF_STATUS retval;
12445 int32_t len;
12446 uint8_t *buf_ptr;
12447 int i;
12448
12449 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12450 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12451 buf = wmi_buf_alloc(wmi_handle, len);
12452 if (!buf) {
12453 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12454 return QDF_STATUS_E_FAILURE;
12455 }
12456 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12457 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12458 WMITLV_SET_HDR(&cmd->tlv_header,
12459 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12460 WMITLV_GET_STRUCT_TLVLEN(
12461 wmi_peer_bwf_request_fixed_param));
12462 cmd->num_peers = param->num_peers;
12463
12464 buf_ptr += sizeof(*cmd);
12465 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12466 sizeof(wmi_bwf_peer_info) *
12467 cmd->num_peers);
12468 buf_ptr += WMI_TLV_HDR_SIZE;
12469 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12470
12471 for (i = 0; i < cmd->num_peers; i++) {
12472 WMITLV_SET_HDR(&peer_info->tlv_header,
12473 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12474 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12475 peer_info->bwf_guaranteed_bandwidth =
12476 param->peer_info[i].throughput;
12477 peer_info->bwf_max_airtime =
12478 param->peer_info[i].max_airtime;
12479 peer_info->bwf_peer_priority =
12480 param->peer_info[i].priority;
12481 qdf_mem_copy(&peer_info->peer_macaddr,
12482 &param->peer_info[i].peer_macaddr,
12483 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012484 peer_info->vdev_id =
12485 param->peer_info[i].vdev_id;
12486 peer_info->pdev_id =
12487 wmi_handle->ops->convert_pdev_id_host_to_target(
12488 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012489 peer_info++;
12490 }
12491
12492 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12493 WMI_PEER_BWF_REQUEST_CMDID);
12494
12495 if (retval != QDF_STATUS_SUCCESS) {
12496 WMI_LOGE("%s : WMI Failed\n", __func__);
12497 wmi_buf_free(buf);
12498 }
12499
12500 return retval;
12501}
12502
12503/**
12504 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12505 * @wmi_handle: wmi handle
12506 * @param: pointer to hold mcast update param
12507 *
12508 * Return: 0 for success or error code
12509 */
12510static QDF_STATUS
12511send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12512 struct mcast_group_update_params *param)
12513{
12514 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12515 wmi_buf_t buf;
12516 QDF_STATUS ret;
12517 int32_t len;
12518 int offset = 0;
12519 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12520
12521 len = sizeof(*cmd);
12522 buf = wmi_buf_alloc(wmi_handle, len);
12523 if (!buf) {
12524 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12525 return QDF_STATUS_E_FAILURE;
12526 }
12527 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12528 WMITLV_SET_HDR(&cmd->tlv_header,
12529 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12530 WMITLV_GET_STRUCT_TLVLEN(
12531 wmi_peer_mcast_group_cmd_fixed_param));
12532 /* confirm the buffer is 4-byte aligned */
12533 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12534 qdf_mem_zero(cmd, sizeof(*cmd));
12535
12536 cmd->vdev_id = param->vap_id;
12537 /* construct the message assuming our endianness matches the target */
12538 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12539 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12540 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12541 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12542 if (param->is_action_delete)
12543 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12544
12545 if (param->is_mcast_addr_len)
12546 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12547
12548 if (param->is_filter_mode_snoop)
12549 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12550
12551 /* unicast address spec only applies for non-wildcard cases */
12552 if (!param->wildcard && param->ucast_mac_addr) {
12553 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12554 &cmd->ucast_mac_addr);
12555 }
Amar Singhal5593c902017-10-03 13:00:29 -070012556
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012557 if (param->mcast_ip_addr) {
12558 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12559 sizeof(cmd->mcast_ip_addr));
12560 offset = sizeof(cmd->mcast_ip_addr) -
12561 param->mcast_ip_addr_bytes;
12562 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12563 param->mcast_ip_addr,
12564 param->mcast_ip_addr_bytes);
12565 }
12566 if (!param->mask)
12567 param->mask = &dummymask[0];
12568
12569 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12570 param->mask,
12571 param->mcast_ip_addr_bytes);
12572
12573 if (param->srcs && param->nsrcs) {
12574 cmd->num_filter_addr = param->nsrcs;
12575 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12576 sizeof(cmd->filter_addr));
12577
12578 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12579 param->nsrcs * param->mcast_ip_addr_bytes);
12580 }
12581
12582 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12583 WMI_PEER_MCAST_GROUP_CMDID);
12584
12585 if (ret != QDF_STATUS_SUCCESS) {
12586 WMI_LOGE("%s : WMI Failed\n", __func__);
12587 wmi_buf_free(buf);
12588 }
12589
12590 return ret;
12591}
12592
12593/**
12594 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12595 * command to fw
12596 * @wmi_handle: wmi handle
12597 * @param: pointer to hold spectral config parameter
12598 *
12599 * Return: 0 for success or error code
12600 */
12601static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12602 struct vdev_spectral_configure_params *param)
12603{
12604 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12605 wmi_buf_t buf;
12606 QDF_STATUS ret;
12607 int32_t len;
12608
12609 len = sizeof(*cmd);
12610 buf = wmi_buf_alloc(wmi_handle, len);
12611 if (!buf) {
12612 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12613 return QDF_STATUS_E_FAILURE;
12614 }
12615
12616 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12617 WMITLV_SET_HDR(&cmd->tlv_header,
12618 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12619 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012620 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012621
12622 cmd->vdev_id = param->vdev_id;
12623 cmd->spectral_scan_count = param->count;
12624 cmd->spectral_scan_period = param->period;
12625 cmd->spectral_scan_priority = param->spectral_pri;
12626 cmd->spectral_scan_fft_size = param->fft_size;
12627 cmd->spectral_scan_gc_ena = param->gc_enable;
12628 cmd->spectral_scan_restart_ena = param->restart_enable;
12629 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12630 cmd->spectral_scan_init_delay = param->init_delay;
12631 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12632 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12633 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12634 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12635 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12636 cmd->spectral_scan_pwr_format = param->pwr_format;
12637 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12638 cmd->spectral_scan_bin_scale = param->bin_scale;
12639 cmd->spectral_scan_dBm_adj = param->dBm_adj;
12640 cmd->spectral_scan_chn_mask = param->chn_mask;
12641
12642 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12643 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12644
12645 if (ret != 0) {
12646 WMI_LOGE("Sending set quiet cmd failed\n");
12647 wmi_buf_free(buf);
12648 }
12649
12650 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12651 __func__);
12652
12653 WMI_LOGI("vdev_id = %u\n"
12654 "spectral_scan_count = %u\n"
12655 "spectral_scan_period = %u\n"
12656 "spectral_scan_priority = %u\n"
12657 "spectral_scan_fft_size = %u\n"
12658 "spectral_scan_gc_ena = %u\n"
12659 "spectral_scan_restart_ena = %u\n"
12660 "spectral_scan_noise_floor_ref = %u\n"
12661 "spectral_scan_init_delay = %u\n"
12662 "spectral_scan_nb_tone_thr = %u\n"
12663 "spectral_scan_str_bin_thr = %u\n"
12664 "spectral_scan_wb_rpt_mode = %u\n"
12665 "spectral_scan_rssi_rpt_mode = %u\n"
12666 "spectral_scan_rssi_thr = %u\n"
12667 "spectral_scan_pwr_format = %u\n"
12668 "spectral_scan_rpt_mode = %u\n"
12669 "spectral_scan_bin_scale = %u\n"
12670 "spectral_scan_dBm_adj = %u\n"
12671 "spectral_scan_chn_mask = %u\n",
12672 param->vdev_id,
12673 param->count,
12674 param->period,
12675 param->spectral_pri,
12676 param->fft_size,
12677 param->gc_enable,
12678 param->restart_enable,
12679 param->noise_floor_ref,
12680 param->init_delay,
12681 param->nb_tone_thr,
12682 param->str_bin_thr,
12683 param->wb_rpt_mode,
12684 param->rssi_rpt_mode,
12685 param->rssi_thr,
12686 param->pwr_format,
12687 param->rpt_mode,
12688 param->bin_scale,
12689 param->dBm_adj,
12690 param->chn_mask);
12691 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12692
12693 return ret;
12694}
12695
12696/**
12697 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12698 * command to fw
12699 * @wmi_handle: wmi handle
12700 * @param: pointer to hold spectral enable parameter
12701 *
12702 * Return: 0 for success or error code
12703 */
12704static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12705 struct vdev_spectral_enable_params *param)
12706{
12707 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12708 wmi_buf_t buf;
12709 QDF_STATUS ret;
12710 int32_t len;
12711
12712 len = sizeof(*cmd);
12713 buf = wmi_buf_alloc(wmi_handle, len);
12714 if (!buf) {
12715 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12716 return QDF_STATUS_E_FAILURE;
12717 }
12718
12719 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12720 WMITLV_SET_HDR(&cmd->tlv_header,
12721 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12722 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012723 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012724
12725 cmd->vdev_id = param->vdev_id;
12726
12727 if (param->active_valid) {
12728 cmd->trigger_cmd = param->active ? 1 : 2;
12729 /* 1: Trigger, 2: Clear Trigger */
12730 } else {
12731 cmd->trigger_cmd = 0; /* 0: Ignore */
12732 }
12733
12734 if (param->enabled_valid) {
12735 cmd->enable_cmd = param->enabled ? 1 : 2;
12736 /* 1: Enable 2: Disable */
12737 } else {
12738 cmd->enable_cmd = 0; /* 0: Ignore */
12739 }
12740
12741 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12742 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12743
12744 if (ret != 0) {
12745 WMI_LOGE("Sending scan enable CMD failed\n");
12746 wmi_buf_free(buf);
12747 }
12748
12749 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12750
12751 WMI_LOGI("vdev_id = %u\n"
12752 "trigger_cmd = %u\n"
12753 "enable_cmd = %u\n",
12754 cmd->vdev_id,
12755 cmd->trigger_cmd,
12756 cmd->enable_cmd);
12757
12758 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12759
12760 return ret;
12761}
12762
12763/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012764 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12765 * @param wmi_handle : handle to WMI.
12766 * @param param : pointer to hold thermal mitigation param
12767 *
12768 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12769 */
12770static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12771 wmi_unified_t wmi_handle,
12772 struct thermal_mitigation_params *param)
12773{
12774 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12775 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12776 wmi_buf_t buf = NULL;
12777 uint8_t *buf_ptr = NULL;
12778 int error;
12779 int32_t len;
12780 int i;
12781
12782 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12783 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12784
12785 buf = wmi_buf_alloc(wmi_handle, len);
12786 if (!buf) {
12787 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12788 return QDF_STATUS_E_NOMEM;
12789 }
12790 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12791
12792 /* init fixed params */
12793 WMITLV_SET_HDR(tt_conf,
12794 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12795 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12796
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012797 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12798 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012799 tt_conf->enable = param->enable;
12800 tt_conf->dc = param->dc;
12801 tt_conf->dc_per_event = param->dc_per_event;
12802 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12803
12804 buf_ptr = (uint8_t *) ++tt_conf;
12805 /* init TLV params */
12806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12807 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12808
12809 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12810 for (i = 0; i < THERMAL_LEVELS; i++) {
12811 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12812 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12813 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12814 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12815 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12816 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12817 lvl_conf->prio = param->levelconf[i].priority;
12818 lvl_conf++;
12819 }
12820
12821 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12822 WMI_THERM_THROT_SET_CONF_CMDID);
12823 if (QDF_IS_STATUS_ERROR(error)) {
12824 wmi_buf_free(buf);
12825 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12826 }
12827
12828 return error;
12829}
12830
12831/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012832 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12833 * @wmi_handle: wmi handle
12834 * @param: pointer to pdev_qvit_params
12835 *
12836 * Return: 0 for success or error code
12837 */
12838static QDF_STATUS
12839send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12840 struct pdev_qvit_params *param)
12841{
12842 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012843 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012844 uint8_t *cmd;
12845 static uint8_t msgref = 1;
12846 uint8_t segnumber = 0, seginfo, numsegments;
12847 uint16_t chunk_len, total_bytes;
12848 uint8_t *bufpos;
12849 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12850
12851 bufpos = param->utf_payload;
12852 total_bytes = param->len;
12853 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12854 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12855 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12856
12857 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12858 numsegments++;
12859
12860 while (param->len) {
12861 if (param->len > MAX_WMI_QVIT_LEN)
12862 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
12863 else
12864 chunk_len = param->len;
12865
12866 buf = wmi_buf_alloc(wmi_handle,
12867 (chunk_len + sizeof(seghdrinfo) +
12868 WMI_TLV_HDR_SIZE));
12869 if (!buf) {
12870 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12871 return QDF_STATUS_E_NOMEM;
12872 }
12873
12874 cmd = (uint8_t *) wmi_buf_data(buf);
12875
12876 seghdrinfo.len = total_bytes;
12877 seghdrinfo.msgref = msgref;
12878 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12879 seghdrinfo.segmentInfo = seginfo;
12880
12881 segnumber++;
12882
12883 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12884 (chunk_len + sizeof(seghdrinfo)));
12885 cmd += WMI_TLV_HDR_SIZE;
12886 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12887 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12888
12889 ret = wmi_unified_cmd_send(wmi_handle, buf,
12890 (chunk_len + sizeof(seghdrinfo) +
12891 WMI_TLV_HDR_SIZE),
12892 WMI_PDEV_QVIT_CMDID);
12893
12894 if (ret != 0) {
12895 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12896 wmi_buf_free(buf);
12897 break;
12898 }
12899
12900 param->len -= chunk_len;
12901 bufpos += chunk_len;
12902 }
12903 msgref++;
12904
12905 return ret;
12906}
12907
12908/**
12909 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12910 * @wmi_handle: wmi handle
12911 * @param: pointer to wmm update param
12912 *
12913 * Return: 0 for success or error code
12914 */
12915static QDF_STATUS
12916send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12917 struct wmm_update_params *param)
12918{
12919 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12920 wmi_wmm_params *wmm_param;
12921 wmi_buf_t buf;
12922 QDF_STATUS ret;
12923 int32_t len;
12924 int ac = 0;
12925 struct wmi_host_wmeParams *wmep;
12926 uint8_t *buf_ptr;
12927
12928 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12929 buf = wmi_buf_alloc(wmi_handle, len);
12930 if (!buf) {
12931 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12932 return QDF_STATUS_E_FAILURE;
12933 }
12934
12935 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12936 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12937 WMITLV_SET_HDR(&cmd->tlv_header,
12938 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12939 WMITLV_GET_STRUCT_TLVLEN
12940 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12941
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012942 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012943
12944 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12945
12946 for (ac = 0; ac < WME_NUM_AC; ac++) {
12947 wmep = &param->wmep_array[ac];
12948 wmm_param = (wmi_wmm_params *)buf_ptr;
12949 WMITLV_SET_HDR(&wmm_param->tlv_header,
12950 WMITLV_TAG_STRUC_wmi_wmm_params,
12951 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12952 wmm_param->aifs = wmep->wmep_aifsn;
12953 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12954 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12955 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12956 wmm_param->acm = wmep->wmep_acm;
12957 wmm_param->no_ack = wmep->wmep_noackPolicy;
12958 buf_ptr += sizeof(wmi_wmm_params);
12959 }
12960 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12961 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12962
12963 if (ret != 0) {
12964 WMI_LOGE("Sending WMM update CMD failed\n");
12965 wmi_buf_free(buf);
12966 }
12967
12968 return ret;
12969}
12970
Sathish Kumar80f4f382017-04-24 11:36:00 +053012971/**
12972 * send_coex_config_cmd_tlv() - send coex config command to fw
12973 * @wmi_handle: wmi handle
12974 * @param: pointer to coex config param
12975 *
12976 * Return: 0 for success or error code
12977 */
12978static QDF_STATUS
12979send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12980 struct coex_config_params *param)
12981{
12982 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12983 wmi_buf_t buf;
12984 QDF_STATUS ret;
12985 int32_t len;
12986
12987 len = sizeof(*cmd);
12988 buf = wmi_buf_alloc(wmi_handle, len);
12989 if (!buf) {
12990 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12991 return QDF_STATUS_E_FAILURE;
12992 }
12993
12994 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12995 WMITLV_SET_HDR(&cmd->tlv_header,
12996 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12997 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012998 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012999
13000 cmd->vdev_id = param->vdev_id;
13001 cmd->config_type = param->config_type;
13002 cmd->config_arg1 = param->config_arg1;
13003 cmd->config_arg2 = param->config_arg2;
13004 cmd->config_arg3 = param->config_arg3;
13005 cmd->config_arg4 = param->config_arg4;
13006 cmd->config_arg5 = param->config_arg5;
13007 cmd->config_arg6 = param->config_arg6;
13008
13009 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13010 WMI_COEX_CONFIG_CMDID);
13011
13012 if (ret != 0) {
13013 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13014 wmi_buf_free(buf);
13015 }
13016
13017 return ret;
13018}
13019
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013020static
Govind Singh9ddd5162016-03-07 16:30:32 +053013021void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013022 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013023{
Govind Singhe7f2f342016-05-23 12:12:52 +053013024 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013025 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13026 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13027 resource_cfg->num_offload_reorder_buffs =
13028 tgt_res_cfg->num_offload_reorder_buffs;
13029 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13030 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13031 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13032 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13033 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13034 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13035 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13036 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13037 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13038 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13039 resource_cfg->scan_max_pending_req =
13040 tgt_res_cfg->scan_max_pending_req;
13041 resource_cfg->bmiss_offload_max_vdev =
13042 tgt_res_cfg->bmiss_offload_max_vdev;
13043 resource_cfg->roam_offload_max_vdev =
13044 tgt_res_cfg->roam_offload_max_vdev;
13045 resource_cfg->roam_offload_max_ap_profiles =
13046 tgt_res_cfg->roam_offload_max_ap_profiles;
13047 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13048 resource_cfg->num_mcast_table_elems =
13049 tgt_res_cfg->num_mcast_table_elems;
13050 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13051 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13052 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13053 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13054 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13055 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13056 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13057 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13058 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13059 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13060 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13061 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13062 resource_cfg->num_tdls_conn_table_entries =
13063 tgt_res_cfg->num_tdls_conn_table_entries;
13064 resource_cfg->beacon_tx_offload_max_vdev =
13065 tgt_res_cfg->beacon_tx_offload_max_vdev;
13066 resource_cfg->num_multicast_filter_entries =
13067 tgt_res_cfg->num_multicast_filter_entries;
13068 resource_cfg->num_wow_filters =
13069 tgt_res_cfg->num_wow_filters;
13070 resource_cfg->num_keep_alive_pattern =
13071 tgt_res_cfg->num_keep_alive_pattern;
13072 resource_cfg->keep_alive_pattern_size =
13073 tgt_res_cfg->keep_alive_pattern_size;
13074 resource_cfg->max_tdls_concurrent_sleep_sta =
13075 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13076 resource_cfg->max_tdls_concurrent_buffer_sta =
13077 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13078 resource_cfg->wmi_send_separate =
13079 tgt_res_cfg->wmi_send_separate;
13080 resource_cfg->num_ocb_vdevs =
13081 tgt_res_cfg->num_ocb_vdevs;
13082 resource_cfg->num_ocb_channels =
13083 tgt_res_cfg->num_ocb_channels;
13084 resource_cfg->num_ocb_schedules =
13085 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013086 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13087 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13088 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013089 resource_cfg->max_num_dbs_scan_duty_cycle =
13090 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013091 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013092
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013093 if (tgt_res_cfg->atf_config)
13094 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13095 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13096 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13097 resource_cfg->flag1, 1);
13098 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13099 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13100 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013101 if (tgt_res_cfg->cce_disable)
13102 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053013103}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013104
13105/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13106 * @wmi_handle: pointer to wmi handle
13107 * @buf_ptr: pointer to current position in init command buffer
13108 * @len: pointer to length. This will be updated with current lenght of cmd
13109 * @param: point host parameters for init command
13110 *
13111 * Return: Updated pointer of buf_ptr.
13112 */
13113static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13114 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13115{
13116 uint16_t idx;
13117
13118 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13119 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13120 wmi_pdev_band_to_mac *band_to_mac;
13121
13122 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13123 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13124 sizeof(wmi_resource_config) +
13125 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13126 sizeof(wlan_host_memory_chunk)));
13127
13128 WMITLV_SET_HDR(&hw_mode->tlv_header,
13129 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13130 (WMITLV_GET_STRUCT_TLVLEN
13131 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13132
13133 hw_mode->hw_mode_index = param->hw_mode_id;
13134 hw_mode->num_band_to_mac = param->num_band_to_mac;
13135
13136 buf_ptr = (uint8_t *) (hw_mode + 1);
13137 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13138 WMI_TLV_HDR_SIZE);
13139 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13140 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13141 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13142 WMITLV_GET_STRUCT_TLVLEN
13143 (wmi_pdev_band_to_mac));
13144 band_to_mac[idx].pdev_id =
13145 wmi_handle->ops->convert_pdev_id_host_to_target(
13146 param->band_to_mac[idx].pdev_id);
13147 band_to_mac[idx].start_freq =
13148 param->band_to_mac[idx].start_freq;
13149 band_to_mac[idx].end_freq =
13150 param->band_to_mac[idx].end_freq;
13151 }
13152 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13153 (param->num_band_to_mac *
13154 sizeof(wmi_pdev_band_to_mac)) +
13155 WMI_TLV_HDR_SIZE;
13156
13157 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13158 (param->num_band_to_mac *
13159 sizeof(wmi_pdev_band_to_mac)));
13160 }
13161
13162 return buf_ptr;
13163}
13164
13165static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13166 wmi_init_cmd_fixed_param *cmd)
13167{
13168 int num_whitelist;
13169 wmi_abi_version my_vers;
13170
13171 num_whitelist = sizeof(version_whitelist) /
13172 sizeof(wmi_whitelist_version_info);
13173 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13174 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13175 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13176 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13177 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13178 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13179
13180 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13181 &my_vers,
13182 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13183 &cmd->host_abi_vers);
13184
13185 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13186 __func__,
13187 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13188 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13189 cmd->host_abi_vers.abi_version_ns_0,
13190 cmd->host_abi_vers.abi_version_ns_1,
13191 cmd->host_abi_vers.abi_version_ns_2,
13192 cmd->host_abi_vers.abi_version_ns_3);
13193
13194 /* Save version sent from host -
13195 * Will be used to check ready event
13196 */
13197 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13198 sizeof(wmi_abi_version));
13199}
13200
Sathish Kumarfd347372017-02-13 12:29:09 +053013201static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013202{
13203 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13204 wmi_service_ready_event_fixed_param *ev;
13205
13206
13207 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13208
13209 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13210 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013211 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013212
13213 /*Save fw version from service ready message */
13214 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013215 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013216 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013217
Govind Singhb53420c2016-03-09 14:32:57 +053013218 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013219}
13220
13221/**
13222 * wmi_unified_save_fw_version_cmd() - save fw version
13223 * @wmi_handle: pointer to wmi handle
13224 * @res_cfg: resource config
13225 * @num_mem_chunks: no of mem chunck
13226 * @mem_chunk: pointer to mem chunck structure
13227 *
13228 * This function sends IE information to firmware
13229 *
Govind Singhb53420c2016-03-09 14:32:57 +053013230 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013231 *
13232 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013233static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013234 void *evt_buf)
13235{
13236 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13237 wmi_ready_event_fixed_param *ev = NULL;
13238
13239 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13240 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013241 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13242 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013243 &ev->fw_abi_vers)) {
13244 /*
13245 * Error: Our host version and the given firmware version
13246 * are incompatible.
13247 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013248 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013249 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13250 __func__,
13251 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13252 abi_version_0),
13253 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13254 abi_version_0),
13255 wmi_handle->final_abi_vers.abi_version_ns_0,
13256 wmi_handle->final_abi_vers.abi_version_ns_1,
13257 wmi_handle->final_abi_vers.abi_version_ns_2,
13258 wmi_handle->final_abi_vers.abi_version_ns_3,
13259 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13260 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13261 ev->fw_abi_vers.abi_version_ns_0,
13262 ev->fw_abi_vers.abi_version_ns_1,
13263 ev->fw_abi_vers.abi_version_ns_2,
13264 ev->fw_abi_vers.abi_version_ns_3);
13265
Govind Singhb53420c2016-03-09 14:32:57 +053013266 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013267 }
Govind Singhb53420c2016-03-09 14:32:57 +053013268 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013269 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013270 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013271 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013272
Govind Singhb53420c2016-03-09 14:32:57 +053013273 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013274}
Govind Singha4836fd2016-03-07 16:45:38 +053013275
13276/**
13277 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13278 * @wmi_handle: wmi handle
13279 * @custom_addr: base mac address
13280 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013281 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013282 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013283static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013284 uint8_t *custom_addr)
13285{
13286 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13287 wmi_buf_t buf;
13288 int err;
13289
13290 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13291 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013292 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013293 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013294 }
13295
13296 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013297 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013298
13299 WMITLV_SET_HDR(&cmd->tlv_header,
13300 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13301 WMITLV_GET_STRUCT_TLVLEN
13302 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13303 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013304 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13305 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013306 err = wmi_unified_cmd_send(wmi_handle, buf,
13307 sizeof(*cmd),
13308 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13309 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013310 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013311 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013312 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013313 }
13314
13315 return 0;
13316}
13317
13318/**
13319 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13320 * @handle: wmi handle
13321 * @event: Event received from FW
13322 * @len: Length of the event
13323 *
13324 * Enables the low frequency events and disables the high frequency
13325 * events. Bit 17 indicates if the event if low/high frequency.
13326 * 1 - high frequency, 0 - low frequency
13327 *
13328 * Return: 0 on successfully enabling/disabling the events
13329 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013330static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013331 uint8_t *event,
13332 uint32_t len)
13333{
13334 uint32_t num_of_diag_events_logs;
13335 wmi_diag_event_log_config_fixed_param *cmd;
13336 wmi_buf_t buf;
13337 uint8_t *buf_ptr;
13338 uint32_t *cmd_args, *evt_args;
13339 uint32_t buf_len, i;
13340
13341 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13342 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13343
Govind Singhb53420c2016-03-09 14:32:57 +053013344 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013345
13346 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13347 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013348 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013349 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013350 }
13351 wmi_event = param_buf->fixed_param;
13352 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013353
13354 if (num_of_diag_events_logs >
13355 param_buf->num_diag_events_logs_list) {
13356 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13357 num_of_diag_events_logs,
13358 param_buf->num_diag_events_logs_list);
13359 return QDF_STATUS_E_INVAL;
13360 }
13361
Govind Singha4836fd2016-03-07 16:45:38 +053013362 evt_args = param_buf->diag_events_logs_list;
13363 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013364 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013365 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013366 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013367 }
13368
Govind Singhb53420c2016-03-09 14:32:57 +053013369 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013370 __func__, num_of_diag_events_logs);
13371
13372 /* Free any previous allocation */
13373 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013374 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013375
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013376 if (num_of_diag_events_logs >
13377 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13378 WMI_LOGE("%s: excess num of logs:%d", __func__,
13379 num_of_diag_events_logs);
13380 QDF_ASSERT(0);
13381 return QDF_STATUS_E_INVAL;
13382 }
Govind Singha4836fd2016-03-07 16:45:38 +053013383 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013384 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013385 sizeof(uint32_t));
13386 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013387 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013388 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013389 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013390 }
13391 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13392
13393 /* Prepare the send buffer */
13394 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13395 (num_of_diag_events_logs * sizeof(uint32_t));
13396
13397 buf = wmi_buf_alloc(wmi_handle, buf_len);
13398 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013399 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13400 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013401 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013402 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013403 }
13404
13405 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13406 buf_ptr = (uint8_t *) cmd;
13407
13408 WMITLV_SET_HDR(&cmd->tlv_header,
13409 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13410 WMITLV_GET_STRUCT_TLVLEN(
13411 wmi_diag_event_log_config_fixed_param));
13412
13413 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13414
13415 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13416
13417 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13418 (num_of_diag_events_logs * sizeof(uint32_t)));
13419
13420 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13421
13422 /* Populate the events */
13423 for (i = 0; i < num_of_diag_events_logs; i++) {
13424 /* Low freq (0) - Enable (1) the event
13425 * High freq (1) - Disable (0) the event
13426 */
13427 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13428 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13429 /* Set the event ID */
13430 WMI_DIAG_ID_SET(cmd_args[i],
13431 WMI_DIAG_ID_GET(evt_args[i]));
13432 /* Set the type */
13433 WMI_DIAG_TYPE_SET(cmd_args[i],
13434 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013435 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013436 wmi_handle->events_logs_list[i] = evt_args[i];
13437 }
13438
13439 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13440 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013441 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013442 __func__);
13443 wmi_buf_free(buf);
13444 /* Not clearing events_logs_list, though wmi cmd failed.
13445 * Host can still have this list
13446 */
Govind Singh67922e82016-04-01 16:48:57 +053013447 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013448 }
13449
13450 return 0;
13451}
13452
13453/**
13454 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13455 * @wmi_handle: wmi handle
13456 * @start_log: Start logging related parameters
13457 *
13458 * Send the command to the FW based on which specific logging of diag
13459 * event/log id can be started/stopped
13460 *
13461 * Return: None
13462 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013463static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013464 struct wmi_wifi_start_log *start_log)
13465{
13466 wmi_diag_event_log_config_fixed_param *cmd;
13467 wmi_buf_t buf;
13468 uint8_t *buf_ptr;
13469 uint32_t len, count, log_level, i;
13470 uint32_t *cmd_args;
13471 uint32_t total_len;
13472 count = 0;
13473
13474 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013475 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013476 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013477 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013478 }
13479 /* total_len stores the number of events where BITS 17 and 18 are set.
13480 * i.e., events of high frequency (17) and for extended debugging (18)
13481 */
13482 total_len = 0;
13483 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13484 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13485 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13486 total_len++;
13487 }
13488
13489 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13490 (total_len * sizeof(uint32_t));
13491
13492 buf = wmi_buf_alloc(wmi_handle, len);
13493 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013494 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013495 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013496 }
13497 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13498 buf_ptr = (uint8_t *) cmd;
13499
13500 WMITLV_SET_HDR(&cmd->tlv_header,
13501 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13502 WMITLV_GET_STRUCT_TLVLEN(
13503 wmi_diag_event_log_config_fixed_param));
13504
13505 cmd->num_of_diag_events_logs = total_len;
13506
13507 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13508
13509 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13510 (total_len * sizeof(uint32_t)));
13511
13512 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13513
Govind Singh224a7312016-06-21 14:33:26 +053013514 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013515 log_level = 1;
13516 else
13517 log_level = 0;
13518
Govind Singhb53420c2016-03-09 14:32:57 +053013519 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013520 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13521 uint32_t val = wmi_handle->events_logs_list[i];
13522 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13523 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13524
13525 WMI_DIAG_ID_SET(cmd_args[count],
13526 WMI_DIAG_ID_GET(val));
13527 WMI_DIAG_TYPE_SET(cmd_args[count],
13528 WMI_DIAG_TYPE_GET(val));
13529 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13530 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013531 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013532 count++;
13533 }
13534 }
13535
13536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13537 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013538 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013539 __func__);
13540 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013541 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013542 }
13543
Govind Singhb53420c2016-03-09 14:32:57 +053013544 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013545}
13546
13547/**
13548 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13549 * @wmi_handle: WMI handle
13550 *
13551 * This function is used to send the flush command to the FW,
13552 * that will flush the fw logs that are residue in the FW
13553 *
13554 * Return: None
13555 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013556static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013557{
13558 wmi_debug_mesg_flush_fixed_param *cmd;
13559 wmi_buf_t buf;
13560 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013561 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013562
13563 buf = wmi_buf_alloc(wmi_handle, len);
13564 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013565 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013566 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013567 }
13568
13569 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13570 WMITLV_SET_HDR(&cmd->tlv_header,
13571 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13572 WMITLV_GET_STRUCT_TLVLEN(
13573 wmi_debug_mesg_flush_fixed_param));
13574 cmd->reserved0 = 0;
13575
13576 ret = wmi_unified_cmd_send(wmi_handle,
13577 buf,
13578 len,
13579 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013580 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013581 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013582 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013583 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013584 }
Govind Singhb53420c2016-03-09 14:32:57 +053013585 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013586
Govind Singh67922e82016-04-01 16:48:57 +053013587 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013588}
13589
13590/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013591 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013592 * @wmi_handle: wmi handle
13593 * @msg: PCL structure containing the PCL and the number of channels
13594 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013595 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013596 * firmware. The DBS Manager is the consumer of this information in the WLAN
13597 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13598 * to migrate to a new channel without host driver involvement. An example of
13599 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13600 * manage the channel selection without firmware involvement.
13601 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013602 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13603 * channel list. The weights corresponds to the channels sent in
13604 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13605 * weightage compared to the non PCL channels.
13606 *
Govind Singha4836fd2016-03-07 16:45:38 +053013607 * Return: Success if the cmd is sent successfully to the firmware
13608 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013609static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013610 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013611{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013612 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013613 wmi_buf_t buf;
13614 uint8_t *buf_ptr;
13615 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013616 uint32_t chan_len;
13617
13618 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013619
13620 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013621 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013622
13623 buf = wmi_buf_alloc(wmi_handle, len);
13624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013625 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13626 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013627 }
13628
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013629 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013630 buf_ptr = (uint8_t *) cmd;
13631 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013632 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13633 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013634
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013635 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13636 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013637 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013638 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013639
13640 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013642 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013643 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013644 for (i = 0; i < chan_len ; i++) {
13645 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013646 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013647 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013648 }
13649 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013650 WMI_PDEV_SET_PCL_CMDID)) {
13651 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013652 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013653 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013654 }
Govind Singhb53420c2016-03-09 14:32:57 +053013655 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013656}
13657
13658/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013659 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013660 * @wmi_handle: wmi handle
13661 * @msg: Structure containing the following parameters
13662 *
13663 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13664 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13665 *
13666 * Provides notification to the WLAN firmware that host driver is requesting a
13667 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13668 * configurations that include the Dual Band Simultaneous (DBS) feature.
13669 *
13670 * Return: Success if the cmd is sent successfully to the firmware
13671 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013672static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013673 uint32_t hw_mode_index)
13674{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013675 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013676 wmi_buf_t buf;
13677 uint32_t len;
13678
13679 len = sizeof(*cmd);
13680
13681 buf = wmi_buf_alloc(wmi_handle, len);
13682 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013683 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13684 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013685 }
13686
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013687 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013688 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013689 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13690 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13691
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013692 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13693 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013694 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013695 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013696
13697 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013698 WMI_PDEV_SET_HW_MODE_CMDID)) {
13699 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013700 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013701 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013702 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013703 }
13704
Govind Singhb53420c2016-03-09 14:32:57 +053013705 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013706}
13707
13708/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013709 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013710 * @wmi_handle: wmi handle
13711 * @msg: Dual MAC config parameters
13712 *
13713 * Configures WLAN firmware with the dual MAC features
13714 *
Govind Singhb53420c2016-03-09 14:32:57 +053013715 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013716 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013717static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013718QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013719 struct wmi_dual_mac_config *msg)
13720{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013721 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013722 wmi_buf_t buf;
13723 uint32_t len;
13724
13725 len = sizeof(*cmd);
13726
13727 buf = wmi_buf_alloc(wmi_handle, len);
13728 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013729 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13730 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013731 }
13732
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013733 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013734 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013735 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013736 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013737 wmi_pdev_set_mac_config_cmd_fixed_param));
13738
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013739 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13740 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013741 cmd->concurrent_scan_config_bits = msg->scan_config;
13742 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013743 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013744 __func__, msg->scan_config, msg->fw_mode_config);
13745
13746 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013747 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13748 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013749 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013750 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013751 }
Govind Singhb53420c2016-03-09 14:32:57 +053013752 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013753}
13754
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013755#ifdef BIG_ENDIAN_HOST
13756/**
13757* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13758* @param data_len - data length
13759* @param data - pointer to data
13760*
13761* Return: QDF_STATUS - success or error status
13762*/
13763static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13764 struct fips_params *param)
13765{
13766 unsigned char *key_unaligned, *data_unaligned;
13767 int c;
13768 u_int8_t *key_aligned = NULL;
13769 u_int8_t *data_aligned = NULL;
13770
13771 /* Assigning unaligned space to copy the key */
13772 key_unaligned = qdf_mem_malloc(
13773 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13774 data_unaligned = qdf_mem_malloc(
13775 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13776
13777 /* Checking if kmalloc is succesful to allocate space */
13778 if (key_unaligned == NULL)
13779 return QDF_STATUS_SUCCESS;
13780 /* Checking if space is aligned */
13781 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13782 /* align to 4 */
13783 key_aligned =
13784 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13785 FIPS_ALIGN);
13786 } else {
13787 key_aligned = (u_int8_t *)key_unaligned;
13788 }
13789
13790 /* memset and copy content from key to key aligned */
13791 OS_MEMSET(key_aligned, 0, param->key_len);
13792 OS_MEMCPY(key_aligned, param->key, param->key_len);
13793
13794 /* print a hexdump for host debug */
13795 print_hex_dump(KERN_DEBUG,
13796 "\t Aligned and Copied Key:@@@@ ",
13797 DUMP_PREFIX_NONE,
13798 16, 1, key_aligned, param->key_len, true);
13799
13800 /* Checking if kmalloc is succesful to allocate space */
13801 if (data_unaligned == NULL)
13802 return QDF_STATUS_SUCCESS;
13803 /* Checking of space is aligned */
13804 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13805 /* align to 4 */
13806 data_aligned =
13807 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13808 FIPS_ALIGN);
13809 } else {
13810 data_aligned = (u_int8_t *)data_unaligned;
13811 }
13812
13813 /* memset and copy content from data to data aligned */
13814 OS_MEMSET(data_aligned, 0, param->data_len);
13815 OS_MEMCPY(data_aligned, param->data, param->data_len);
13816
13817 /* print a hexdump for host debug */
13818 print_hex_dump(KERN_DEBUG,
13819 "\t Properly Aligned and Copied Data:@@@@ ",
13820 DUMP_PREFIX_NONE,
13821 16, 1, data_aligned, param->data_len, true);
13822
13823 /* converting to little Endian both key_aligned and
13824 * data_aligned*/
13825 for (c = 0; c < param->key_len/4; c++) {
13826 *((u_int32_t *)key_aligned+c) =
13827 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13828 }
13829 for (c = 0; c < param->data_len/4; c++) {
13830 *((u_int32_t *)data_aligned+c) =
13831 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13832 }
13833
13834 /* update endian data to key and data vectors */
13835 OS_MEMCPY(param->key, key_aligned, param->key_len);
13836 OS_MEMCPY(param->data, data_aligned, param->data_len);
13837
13838 /* clean up allocated spaces */
13839 qdf_mem_free(key_unaligned);
13840 key_unaligned = NULL;
13841 key_aligned = NULL;
13842
13843 qdf_mem_free(data_unaligned);
13844 data_unaligned = NULL;
13845 data_aligned = NULL;
13846
13847 return QDF_STATUS_SUCCESS;
13848}
13849#else
13850/**
13851* fips_align_data_be() - DUMMY for LE platform
13852*
13853* Return: QDF_STATUS - success
13854*/
13855static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13856 struct fips_params *param)
13857{
13858 return QDF_STATUS_SUCCESS;
13859}
13860#endif
13861
13862
13863/**
13864 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13865 * @wmi_handle: wmi handle
13866 * @param: pointer to hold pdev fips param
13867 *
13868 * Return: 0 for success or error code
13869 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013870static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013871send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13872 struct fips_params *param)
13873{
13874 wmi_pdev_fips_cmd_fixed_param *cmd;
13875 wmi_buf_t buf;
13876 uint8_t *buf_ptr;
13877 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13878 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13879
13880 /* Length TLV placeholder for array of bytes */
13881 len += WMI_TLV_HDR_SIZE;
13882 if (param->data_len)
13883 len += (param->data_len*sizeof(uint8_t));
13884
13885 /*
13886 * Data length must be multiples of 16 bytes - checked against 0xF -
13887 * and must be less than WMI_SVC_MSG_SIZE - static size of
13888 * wmi_pdev_fips_cmd structure
13889 */
13890
13891 /* do sanity on the input */
13892 if (!(((param->data_len & 0xF) == 0) &&
13893 ((param->data_len > 0) &&
13894 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13895 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13896 return QDF_STATUS_E_INVAL;
13897 }
13898
13899 buf = wmi_buf_alloc(wmi_handle, len);
13900 if (!buf) {
13901 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13902 return QDF_STATUS_E_FAILURE;
13903 }
13904
13905 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13906 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13907 WMITLV_SET_HDR(&cmd->tlv_header,
13908 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13909 WMITLV_GET_STRUCT_TLVLEN
13910 (wmi_pdev_fips_cmd_fixed_param));
13911
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013912 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13913 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013914 if (param->key != NULL && param->data != NULL) {
13915 cmd->key_len = param->key_len;
13916 cmd->data_len = param->data_len;
13917 cmd->fips_cmd = !!(param->op);
13918
13919 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13920 return QDF_STATUS_E_FAILURE;
13921
13922 qdf_mem_copy(cmd->key, param->key, param->key_len);
13923
13924 if (param->mode == FIPS_ENGINE_AES_CTR ||
13925 param->mode == FIPS_ENGINE_AES_MIC) {
13926 cmd->mode = param->mode;
13927 } else {
13928 cmd->mode = FIPS_ENGINE_AES_CTR;
13929 }
13930 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13931 cmd->key_len, cmd->data_len);
13932
13933 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13934 cmd->key, cmd->key_len, true);
13935 buf_ptr += sizeof(*cmd);
13936
13937 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13938
13939 buf_ptr += WMI_TLV_HDR_SIZE;
13940 if (param->data_len)
13941 qdf_mem_copy(buf_ptr,
13942 (uint8_t *) param->data, param->data_len);
13943
13944 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13945 16, 1, buf_ptr, cmd->data_len, true);
13946
13947 buf_ptr += param->data_len;
13948
13949 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13950 WMI_PDEV_FIPS_CMDID);
13951 qdf_print("%s return value %d\n", __func__, retval);
13952 } else {
13953 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13954 wmi_buf_free(buf);
13955 retval = -QDF_STATUS_E_BADMSG;
13956 }
13957
13958 return retval;
13959}
13960
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013961#ifdef WLAN_PMO_ENABLE
13962/**
13963 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13964 * @wmi_handle: wmi handle
13965 * @vdev_id: vdev id
13966 * @bitmap: Event bitmap
13967 * @enable: enable/disable
13968 *
13969 * Return: CDF status
13970 */
13971static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13972 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013973 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013974 bool enable)
13975{
13976 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13977 uint16_t len;
13978 wmi_buf_t buf;
13979 int ret;
13980
13981 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13982 buf = wmi_buf_alloc(wmi_handle, len);
13983 if (!buf) {
13984 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13985 return QDF_STATUS_E_NOMEM;
13986 }
13987 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13988 WMITLV_SET_HDR(&cmd->tlv_header,
13989 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13990 WMITLV_GET_STRUCT_TLVLEN
13991 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13992 cmd->vdev_id = vdev_id;
13993 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013994 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13995 WMI_WOW_MAX_EVENT_BM_LEN);
13996
13997 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13998 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13999 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014000
14001 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14002 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14003 if (ret) {
14004 WMI_LOGE("Failed to config wow wakeup event");
14005 wmi_buf_free(buf);
14006 return QDF_STATUS_E_FAILURE;
14007 }
14008
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014009 return QDF_STATUS_SUCCESS;
14010}
14011
14012/**
14013 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14014 * @wmi_handle: wmi handle
14015 * @vdev_id: vdev id
14016 * @ptrn_id: pattern id
14017 * @ptrn: pattern
14018 * @ptrn_len: pattern length
14019 * @ptrn_offset: pattern offset
14020 * @mask: mask
14021 * @mask_len: mask length
14022 * @user: true for user configured pattern and false for default pattern
14023 * @default_patterns: default patterns
14024 *
14025 * Return: CDF status
14026 */
14027static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14028 uint8_t vdev_id, uint8_t ptrn_id,
14029 const uint8_t *ptrn, uint8_t ptrn_len,
14030 uint8_t ptrn_offset, const uint8_t *mask,
14031 uint8_t mask_len, bool user,
14032 uint8_t default_patterns)
14033{
14034 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14035 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14036 wmi_buf_t buf;
14037 uint8_t *buf_ptr;
14038 int32_t len;
14039 int ret;
14040
14041 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14042 WMI_TLV_HDR_SIZE +
14043 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14044 WMI_TLV_HDR_SIZE +
14045 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14046 WMI_TLV_HDR_SIZE +
14047 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14048 WMI_TLV_HDR_SIZE +
14049 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14050 WMI_TLV_HDR_SIZE +
14051 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14052
14053 buf = wmi_buf_alloc(wmi_handle, len);
14054 if (!buf) {
14055 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14056 return QDF_STATUS_E_NOMEM;
14057 }
14058
14059 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14060 buf_ptr = (uint8_t *) cmd;
14061
14062 WMITLV_SET_HDR(&cmd->tlv_header,
14063 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14064 WMITLV_GET_STRUCT_TLVLEN
14065 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14066 cmd->vdev_id = vdev_id;
14067 cmd->pattern_id = ptrn_id;
14068
14069 cmd->pattern_type = WOW_BITMAP_PATTERN;
14070 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14071
14072 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14073 sizeof(WOW_BITMAP_PATTERN_T));
14074 buf_ptr += WMI_TLV_HDR_SIZE;
14075 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14076
14077 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14078 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14079 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14080
14081 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14082 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14083
14084 bitmap_pattern->pattern_offset = ptrn_offset;
14085 bitmap_pattern->pattern_len = ptrn_len;
14086
14087 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14088 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14089
14090 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14091 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14092
14093 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14094 bitmap_pattern->pattern_id = ptrn_id;
14095
14096 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14097 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14098 bitmap_pattern->pattern_offset, user);
14099 WMI_LOGI("Pattern : ");
14100 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14101 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14102
14103 WMI_LOGI("Mask : ");
14104 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14105 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14106
14107 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14108
14109 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14111 buf_ptr += WMI_TLV_HDR_SIZE;
14112
14113 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14114 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14115 buf_ptr += WMI_TLV_HDR_SIZE;
14116
14117 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14119 buf_ptr += WMI_TLV_HDR_SIZE;
14120
14121 /* Fill TLV for pattern_info_timeout but no data. */
14122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14123 buf_ptr += WMI_TLV_HDR_SIZE;
14124
14125 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
14126 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
14127 buf_ptr += WMI_TLV_HDR_SIZE;
14128 *(A_UINT32 *) buf_ptr = 0;
14129
14130 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14131 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14132 if (ret) {
14133 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14134 wmi_buf_free(buf);
14135 return QDF_STATUS_E_FAILURE;
14136 }
14137
14138 return QDF_STATUS_SUCCESS;
14139}
14140
Govind Singha4836fd2016-03-07 16:45:38 +053014141/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014142 * fill_arp_offload_params_tlv() - Fill ARP offload data
14143 * @wmi_handle: wmi handle
14144 * @offload_req: offload request
14145 * @buf_ptr: buffer pointer
14146 *
14147 * To fill ARP offload data to firmware
14148 * when target goes to wow mode.
14149 *
14150 * Return: None
14151 */
14152static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014153 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014154{
14155
14156 int i;
14157 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014158 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014159
14160 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14161 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14162 *buf_ptr += WMI_TLV_HDR_SIZE;
14163 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14164 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14165 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14166 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14167 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14168
14169 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014170 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014171 /* Copy the target ip addr and flags */
14172 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14173 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014174 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014175 WMI_IPV4_ADDR_LEN);
14176 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014177 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014178 }
14179 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14180 }
14181}
14182
14183#ifdef WLAN_NS_OFFLOAD
14184/**
14185 * fill_ns_offload_params_tlv() - Fill NS offload data
14186 * @wmi|_handle: wmi handle
14187 * @offload_req: offload request
14188 * @buf_ptr: buffer pointer
14189 *
14190 * To fill NS offload data to firmware
14191 * when target goes to wow mode.
14192 *
14193 * Return: None
14194 */
14195static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014196 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014197{
14198
14199 int i;
14200 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014201
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014202 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14203 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14204 *buf_ptr += WMI_TLV_HDR_SIZE;
14205 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14206 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14207 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14208 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14209 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14210
14211 /*
14212 * Fill data only for NS offload in the first ARP tuple for LA
14213 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014214 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014215 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14216 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014217 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014218 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014219 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014220 sizeof(WMI_IPV6_ADDR));
14221 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014222 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014223 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014224 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014225 ns_tuple->flags |=
14226 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14227 }
14228 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014229 i, &ns_req->self_ipv6_addr[i],
14230 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014231
14232 /* target MAC is optional, check if it is valid,
14233 * if this is not valid, the target will use the known
14234 * local MAC address rather than the tuple
14235 */
14236 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014237 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014238 &ns_tuple->target_mac);
14239 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14240 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14241 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14242 }
14243 }
14244 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14245 }
14246}
14247
14248
14249/**
14250 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14251 * @wmi: wmi handle
14252 * @offload_req: offload request
14253 * @buf_ptr: buffer pointer
14254 *
14255 * To fill extended NS offload extended data to firmware
14256 * when target goes to wow mode.
14257 *
14258 * Return: None
14259 */
14260static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014261 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014262{
14263 int i;
14264 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14265 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014266
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014267 count = ns_req->num_ns_offload_count;
14268 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014269 WMI_MAX_NS_OFFLOADS;
14270
14271 /* Populate extended NS offload tuples */
14272 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14273 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14274 *buf_ptr += WMI_TLV_HDR_SIZE;
14275 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14276 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14277 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14278 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14279 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14280
14281 /*
14282 * Fill data only for NS offload in the first ARP tuple for LA
14283 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014284 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014285 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14286 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014287 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014288 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014289 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014290 sizeof(WMI_IPV6_ADDR));
14291 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014292 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014293 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014294 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014295 ns_tuple->flags |=
14296 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14297 }
14298 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014299 i, &ns_req->self_ipv6_addr[i],
14300 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014301
14302 /* target MAC is optional, check if it is valid,
14303 * if this is not valid, the target will use the
14304 * known local MAC address rather than the tuple
14305 */
14306 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014307 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014308 &ns_tuple->target_mac);
14309 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14310 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14311 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14312 }
14313 }
14314 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14315 }
14316}
14317#else
14318static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014319 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014320{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014321}
14322
14323static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014324 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014325{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014326}
14327#endif
14328
14329/**
Govind Singha4836fd2016-03-07 16:45:38 +053014330 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14331 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014332 * @arp_offload_req: arp offload request
14333 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014334 * @arp_only: flag
14335 *
14336 * To configure ARP NS off load data to firmware
14337 * when target goes to wow mode.
14338 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014339 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014340 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014341static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014342 struct pmo_arp_offload_params *arp_offload_req,
14343 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014344 uint8_t vdev_id)
14345{
Govind Singha4836fd2016-03-07 16:45:38 +053014346 int32_t res;
14347 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053014348 A_UINT8 *buf_ptr;
14349 wmi_buf_t buf;
14350 int32_t len;
14351 uint32_t count = 0, num_ns_ext_tuples = 0;
14352
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014353 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014354
Govind Singha4836fd2016-03-07 16:45:38 +053014355 /*
14356 * TLV place holder size for array of NS tuples
14357 * TLV place holder size for array of ARP tuples
14358 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014359 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14360 WMI_TLV_HDR_SIZE +
14361 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14362 WMI_TLV_HDR_SIZE +
14363 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014364
14365 /*
14366 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14367 * extra length for extended NS offload tuples which follows ARP offload
14368 * tuples. Host needs to fill this structure in following format:
14369 * 2 NS ofload tuples
14370 * 2 ARP offload tuples
14371 * N numbers of extended NS offload tuples if HDD has given more than
14372 * 2 NS offload addresses
14373 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014374 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014375 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014376 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14377 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014378 }
14379
14380 buf = wmi_buf_alloc(wmi_handle, len);
14381 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014382 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014383 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014384 }
14385
14386 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14387 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14388 WMITLV_SET_HDR(&cmd->tlv_header,
14389 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14390 WMITLV_GET_STRUCT_TLVLEN
14391 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14392 cmd->flags = 0;
14393 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014394 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014395
Govind Singhb53420c2016-03-09 14:32:57 +053014396 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014397
Govind Singha4836fd2016-03-07 16:45:38 +053014398 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014399 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14400 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14401 if (num_ns_ext_tuples)
14402 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014403
14404 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14405 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14406 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014407 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014408 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014409 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014410 }
14411
Govind Singhb53420c2016-03-09 14:32:57 +053014412 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014413}
14414
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014415/**
14416 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14417 * @wmi_handle: wmi handle
14418 * @vdev_id: vdev id
14419 * @action: true for enable else false
14420 *
14421 * To enable enhance multicast offload to firmware
14422 * when target goes to wow mode.
14423 *
14424 * Return: QDF Status
14425 */
14426
14427static
14428QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14429 wmi_unified_t wmi_handle,
14430 uint8_t vdev_id, bool action)
14431{
14432 QDF_STATUS status;
14433 wmi_buf_t buf;
14434 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14435
14436 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14437 if (!buf) {
14438 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14439 return QDF_STATUS_E_NOMEM;
14440 }
14441
14442 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14443 wmi_buf_data(buf);
14444
14445 WMITLV_SET_HDR(&cmd->tlv_header,
14446 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14447 WMITLV_GET_STRUCT_TLVLEN(
14448 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14449
14450 cmd->vdev_id = vdev_id;
14451 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14452 ENHANCED_MCAST_FILTER_ENABLED);
14453 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14454 __func__, action, vdev_id);
14455 status = wmi_unified_cmd_send(wmi_handle, buf,
14456 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14457 if (status != QDF_STATUS_SUCCESS) {
14458 qdf_nbuf_free(buf);
14459 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14460 __func__);
14461 }
14462
14463 return status;
14464}
14465
14466/**
14467 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14468 * @wmi_handle: wmi handle
14469 * @param evt_buf: pointer to event buffer
14470 * @param hdr: Pointer to hold header
14471 * @param bufp: Pointer to hold pointer to rx param buffer
14472 *
14473 * Return: QDF_STATUS_SUCCESS for success or error code
14474 */
14475static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14476 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14477{
14478 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14479 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14480
14481 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14482 if (!param_buf) {
14483 WMI_LOGE("gtk param_buf is NULL");
14484 return QDF_STATUS_E_INVAL;
14485 }
14486
14487 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14488 WMI_LOGE("Invalid length for GTK status");
14489 return QDF_STATUS_E_INVAL;
14490 }
14491
14492 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14493 param_buf->fixed_param;
14494 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14495 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14496 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14497 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14498 &fixed_param->replay_counter,
14499 GTK_REPLAY_COUNTER_BYTES);
14500
14501 return QDF_STATUS_SUCCESS;
14502
14503}
14504
14505#ifdef FEATURE_WLAN_RA_FILTERING
14506/**
14507 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14508 * @wmi_handle: wmi handle
14509 * @vdev_id: vdev id
14510 *
14511 * Return: CDF status
14512 */
14513static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14514 uint8_t vdev_id, uint8_t default_pattern,
14515 uint16_t rate_limit_interval)
14516{
14517
14518 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14519 wmi_buf_t buf;
14520 uint8_t *buf_ptr;
14521 int32_t len;
14522 int ret;
14523
14524 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14525 WMI_TLV_HDR_SIZE +
14526 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14527 WMI_TLV_HDR_SIZE +
14528 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14529 WMI_TLV_HDR_SIZE +
14530 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14531 WMI_TLV_HDR_SIZE +
14532 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14533 WMI_TLV_HDR_SIZE +
14534 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14535
14536 buf = wmi_buf_alloc(wmi_handle, len);
14537 if (!buf) {
14538 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14539 return QDF_STATUS_E_NOMEM;
14540 }
14541
14542 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14543 buf_ptr = (uint8_t *) cmd;
14544
14545 WMITLV_SET_HDR(&cmd->tlv_header,
14546 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14547 WMITLV_GET_STRUCT_TLVLEN
14548 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14549 cmd->vdev_id = vdev_id;
14550 cmd->pattern_id = default_pattern,
14551 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14552 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14553
14554 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14556 buf_ptr += WMI_TLV_HDR_SIZE;
14557
14558 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14559 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14560 buf_ptr += WMI_TLV_HDR_SIZE;
14561
14562 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14563 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14564 buf_ptr += WMI_TLV_HDR_SIZE;
14565
14566 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14567 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14568 buf_ptr += WMI_TLV_HDR_SIZE;
14569
14570 /* Fill TLV for pattern_info_timeout but no data. */
14571 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14572 buf_ptr += WMI_TLV_HDR_SIZE;
14573
14574 /* Fill TLV for ra_ratelimit_interval. */
14575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
14576 buf_ptr += WMI_TLV_HDR_SIZE;
14577
14578 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
14579
14580 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14581 rate_limit_interval, vdev_id);
14582
14583 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14584 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14585 if (ret) {
14586 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14587 wmi_buf_free(buf);
14588 return QDF_STATUS_E_FAILURE;
14589 }
14590
14591 return QDF_STATUS_SUCCESS;
14592
14593}
14594#endif /* FEATURE_WLAN_RA_FILTERING */
14595
14596/**
14597 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14598 * @wmi_handle: wmi handle
14599 * @vdev_id: vdev id
14600 * @multicastAddr: mcast address
14601 * @clearList: clear list flag
14602 *
14603 * Return: QDF_STATUS_SUCCESS for success or error code
14604 */
14605static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14606 uint8_t vdev_id,
14607 struct qdf_mac_addr multicast_addr,
14608 bool clearList)
14609{
14610 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14611 wmi_buf_t buf;
14612 int err;
14613
14614 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14615 if (!buf) {
14616 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14617 return QDF_STATUS_E_NOMEM;
14618 }
14619
14620 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14621 qdf_mem_zero(cmd, sizeof(*cmd));
14622
14623 WMITLV_SET_HDR(&cmd->tlv_header,
14624 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14625 WMITLV_GET_STRUCT_TLVLEN
14626 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14627 cmd->action =
14628 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14629 cmd->vdev_id = vdev_id;
14630 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14631
14632 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14633 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14634
14635 err = wmi_unified_cmd_send(wmi_handle, buf,
14636 sizeof(*cmd),
14637 WMI_SET_MCASTBCAST_FILTER_CMDID);
14638 if (err) {
14639 WMI_LOGE("Failed to send set_param cmd");
14640 wmi_buf_free(buf);
14641 return QDF_STATUS_E_FAILURE;
14642 }
14643
14644 return QDF_STATUS_SUCCESS;
14645}
14646
14647/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014648 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14649 * command to fw
14650 * @wmi_handle: wmi handle
14651 * @vdev_id: vdev id
14652 * @mcast_filter_params: mcast filter params
14653 *
14654 * Return: QDF_STATUS_SUCCESS for success or error code
14655 */
14656static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14657 wmi_unified_t wmi_handle,
14658 uint8_t vdev_id,
14659 struct pmo_mcast_filter_params *filter_param)
14660
14661{
14662 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14663 uint8_t *buf_ptr;
14664 wmi_buf_t buf;
14665 int err;
14666 int i;
14667 uint8_t *mac_addr_src_ptr = NULL;
14668 wmi_mac_addr *mac_addr_dst_ptr;
14669 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14670 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14671
14672 buf = wmi_buf_alloc(wmi_handle, len);
14673 if (!buf) {
14674 WMI_LOGE("Failed to allocate memory");
14675 return QDF_STATUS_E_NOMEM;
14676 }
14677
14678 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14679 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14680 wmi_buf_data(buf);
14681 qdf_mem_zero(cmd, sizeof(*cmd));
14682
14683 WMITLV_SET_HDR(&cmd->tlv_header,
14684 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14685 WMITLV_GET_STRUCT_TLVLEN
14686 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14687 cmd->operation =
14688 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14689 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14690 cmd->vdev_id = vdev_id;
14691 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14692
14693 buf_ptr += sizeof(*cmd);
14694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14695 sizeof(wmi_mac_addr) *
14696 filter_param->multicast_addr_cnt);
14697
14698 if (filter_param->multicast_addr_cnt == 0)
14699 goto send_cmd;
14700
14701 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14702 mac_addr_dst_ptr = (wmi_mac_addr *)
14703 (buf_ptr + WMI_TLV_HDR_SIZE);
14704
14705 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14706 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14707 mac_addr_src_ptr += ATH_MAC_LEN;
14708 mac_addr_dst_ptr++;
14709 }
14710
14711send_cmd:
14712 err = wmi_unified_cmd_send(wmi_handle, buf,
14713 len,
14714 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14715 if (err) {
14716 WMI_LOGE("Failed to send set_param cmd");
14717 wmi_buf_free(buf);
14718 return QDF_STATUS_E_FAILURE;
14719 }
14720
14721 return QDF_STATUS_SUCCESS;
14722}
14723
14724
14725/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014726 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14727 * @wmi_handle: wmi handle
14728 * @vdev_id: vdev id
14729 * @params: GTK offload parameters
14730 *
14731 * Return: CDF status
14732 */
14733static
14734QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14735 struct pmo_gtk_req *params,
14736 bool enable_offload,
14737 uint32_t gtk_offload_opcode)
14738{
14739 int len;
14740 wmi_buf_t buf;
14741 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014742 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014743 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014744 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014745
14746 WMI_LOGD("%s Enter", __func__);
14747
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014748 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014749
14750 /* alloc wmi buffer */
14751 buf = wmi_buf_alloc(wmi_handle, len);
14752 if (!buf) {
14753 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14754 status = QDF_STATUS_E_NOMEM;
14755 goto out;
14756 }
14757
14758 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014759 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014760 WMITLV_SET_HDR(&cmd->tlv_header,
14761 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14762 WMITLV_GET_STRUCT_TLVLEN
14763 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14764
14765 cmd->vdev_id = vdev_id;
14766
14767 /* Request target to enable GTK offload */
14768 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14769 cmd->flags = gtk_offload_opcode;
14770
14771 /* Copy the keys and replay counter */
14772 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014773 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014774 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14775 GTK_REPLAY_COUNTER_BYTES);
14776 } else {
14777 cmd->flags = gtk_offload_opcode;
14778 }
14779
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014780 buf_ptr += sizeof(*cmd);
14781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
14782 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014783
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014784 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14785 WMITLV_SET_HDR(&ext_param->tlv_header,
14786 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14787 WMITLV_GET_STRUCT_TLVLEN(
14788 wmi_gtk_offload_fils_tlv_param));
14789 ext_param->vdev_id = vdev_id;
14790 ext_param->flags = cmd->flags;
14791 ext_param->kek_len = params->kek_len;
14792 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14793 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
14794 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14795 GTK_REPLAY_COUNTER_BYTES);
14796
14797 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 +053014798 /* send the wmi command */
14799 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14800 WMI_GTK_OFFLOAD_CMDID)) {
14801 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14802 wmi_buf_free(buf);
14803 status = QDF_STATUS_E_FAILURE;
14804 }
14805
14806out:
14807 WMI_LOGD("%s Exit", __func__);
14808 return status;
14809}
14810
14811/**
14812 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14813 * @wmi_handle: wmi handle
14814 * @params: GTK offload params
14815 *
14816 * Return: CDF status
14817 */
14818static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14819 wmi_unified_t wmi_handle,
14820 uint8_t vdev_id,
14821 uint64_t offload_req_opcode)
14822{
14823 int len;
14824 wmi_buf_t buf;
14825 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14826 QDF_STATUS status = QDF_STATUS_SUCCESS;
14827
14828 len = sizeof(*cmd);
14829
14830 /* alloc wmi buffer */
14831 buf = wmi_buf_alloc(wmi_handle, len);
14832 if (!buf) {
14833 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14834 status = QDF_STATUS_E_NOMEM;
14835 goto out;
14836 }
14837
14838 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14839 WMITLV_SET_HDR(&cmd->tlv_header,
14840 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14841 WMITLV_GET_STRUCT_TLVLEN
14842 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14843
14844 /* Request for GTK offload status */
14845 cmd->flags = offload_req_opcode;
14846 cmd->vdev_id = vdev_id;
14847
14848 /* send the wmi command */
14849 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14850 WMI_GTK_OFFLOAD_CMDID)) {
14851 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14852 wmi_buf_free(buf);
14853 status = QDF_STATUS_E_FAILURE;
14854 }
14855
14856out:
14857 return status;
14858}
14859
14860/**
14861 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14862 * @wmi_handle: wmi handler
14863 * @action_params: pointer to action_params
14864 *
14865 * Return: 0 for success, otherwise appropriate error code
14866 */
14867static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14868 struct pmo_action_wakeup_set_params *action_params)
14869{
14870 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14871 wmi_buf_t buf;
14872 int i;
14873 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014874 uint32_t len = 0, *cmd_args;
14875 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014876
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014877 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
14878 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14879 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014880 if (!buf) {
14881 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14882 return QDF_STATUS_E_NOMEM;
14883 }
14884 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014885 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014886 WMITLV_SET_HDR(&cmd->tlv_header,
14887 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14888 WMITLV_GET_STRUCT_TLVLEN(
14889 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14890
14891 cmd->vdev_id = action_params->vdev_id;
14892 cmd->operation = action_params->operation;
14893
14894 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14895 cmd->action_category_map[i] =
14896 action_params->action_category_map[i];
14897
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014898 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14900 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
14901 buf_ptr += WMI_TLV_HDR_SIZE;
14902 cmd_args = (uint32_t *) buf_ptr;
14903 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14904 cmd_args[i] = action_params->action_per_category[i];
14905
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014906 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014907 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014908 if (err) {
14909 WMI_LOGE("Failed to send ap_ps_egap cmd");
14910 wmi_buf_free(buf);
14911 return QDF_STATUS_E_FAILURE;
14912 }
14913
14914 return QDF_STATUS_SUCCESS;
14915}
14916
14917#ifdef FEATURE_WLAN_LPHB
14918
14919/**
14920 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14921 * @wmi_handle: wmi handle
14922 * @lphb_conf_req: configuration info
14923 *
14924 * Return: CDF status
14925 */
14926static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14927 wmi_hb_set_enable_cmd_fixed_param *params)
14928{
14929 QDF_STATUS status;
14930 wmi_buf_t buf = NULL;
14931 uint8_t *buf_ptr;
14932 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14933 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14934
14935
14936 buf = wmi_buf_alloc(wmi_handle, len);
14937 if (!buf) {
14938 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14939 return QDF_STATUS_E_NOMEM;
14940 }
14941
14942 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14943 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14944 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14945 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14946 WMITLV_GET_STRUCT_TLVLEN
14947 (wmi_hb_set_enable_cmd_fixed_param));
14948
14949 /* fill in values */
14950 hb_enable_fp->vdev_id = params->session;
14951 hb_enable_fp->enable = params->enable;
14952 hb_enable_fp->item = params->item;
14953 hb_enable_fp->session = params->session;
14954
14955 status = wmi_unified_cmd_send(wmi_handle, buf,
14956 len, WMI_HB_SET_ENABLE_CMDID);
14957 if (QDF_IS_STATUS_ERROR(status)) {
14958 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14959 status);
14960 wmi_buf_free(buf);
14961 }
14962
14963 return status;
14964}
14965
14966/**
14967 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14968 * @wmi_handle: wmi handle
14969 * @lphb_conf_req: lphb config request
14970 *
14971 * Return: CDF status
14972 */
14973static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14974 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14975{
14976 QDF_STATUS status;
14977 wmi_buf_t buf = NULL;
14978 uint8_t *buf_ptr;
14979 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14980 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14981
14982 buf = wmi_buf_alloc(wmi_handle, len);
14983 if (!buf) {
14984 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14985 return QDF_STATUS_E_NOMEM;
14986 }
14987
14988 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14989 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14990 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14991 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14992 WMITLV_GET_STRUCT_TLVLEN
14993 (wmi_hb_set_tcp_params_cmd_fixed_param));
14994
14995 /* fill in values */
14996 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14997 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14998 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14999 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15000 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15001 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15002 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15003 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15004 hb_tcp_params_fp->session = lphb_conf_req->session;
15005 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15006 &lphb_conf_req->gateway_mac,
15007 sizeof(hb_tcp_params_fp->gateway_mac));
15008
15009 status = wmi_unified_cmd_send(wmi_handle, buf,
15010 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15011 if (QDF_IS_STATUS_ERROR(status)) {
15012 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15013 status);
15014 wmi_buf_free(buf);
15015 }
15016
15017 return status;
15018}
15019
15020/**
15021 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15022 * @wmi_handle: wmi handle
15023 * @lphb_conf_req: lphb config request
15024 *
15025 * Return: CDF status
15026 */
15027static
15028QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15029 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15030{
15031 QDF_STATUS status;
15032 wmi_buf_t buf = NULL;
15033 uint8_t *buf_ptr;
15034 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15035 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15036
15037 buf = wmi_buf_alloc(wmi_handle, len);
15038 if (!buf) {
15039 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15040 return QDF_STATUS_E_NOMEM;
15041 }
15042
15043 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15044 hb_tcp_filter_fp =
15045 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15046 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15047 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15048 WMITLV_GET_STRUCT_TLVLEN
15049 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15050
15051 /* fill in values */
15052 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15053 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15054 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15055 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15056 memcpy((void *)&hb_tcp_filter_fp->filter,
15057 (void *)&g_hb_tcp_filter_fp->filter,
15058 WMI_WLAN_HB_MAX_FILTER_SIZE);
15059
15060 status = wmi_unified_cmd_send(wmi_handle, buf,
15061 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15062 if (QDF_IS_STATUS_ERROR(status)) {
15063 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15064 status);
15065 wmi_buf_free(buf);
15066 }
15067
15068 return status;
15069}
15070
15071/**
15072 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15073 * @wmi_handle: wmi handle
15074 * @lphb_conf_req: lphb config request
15075 *
15076 * Return: CDF status
15077 */
15078static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15079 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15080{
15081 QDF_STATUS status;
15082 wmi_buf_t buf = NULL;
15083 uint8_t *buf_ptr;
15084 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15085 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15086
15087 buf = wmi_buf_alloc(wmi_handle, len);
15088 if (!buf) {
15089 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15090 return QDF_STATUS_E_NOMEM;
15091 }
15092
15093 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15094 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15095 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15096 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15097 WMITLV_GET_STRUCT_TLVLEN
15098 (wmi_hb_set_udp_params_cmd_fixed_param));
15099
15100 /* fill in values */
15101 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15102 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15103 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15104 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15105 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15106 hb_udp_params_fp->interval = lphb_conf_req->interval;
15107 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15108 hb_udp_params_fp->session = lphb_conf_req->session;
15109 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15110 &lphb_conf_req->gateway_mac,
15111 sizeof(lphb_conf_req->gateway_mac));
15112
15113 status = wmi_unified_cmd_send(wmi_handle, buf,
15114 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15115 if (QDF_IS_STATUS_ERROR(status)) {
15116 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15117 status);
15118 wmi_buf_free(buf);
15119 }
15120
15121 return status;
15122}
15123
15124/**
15125 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15126 * @wmi_handle: wmi handle
15127 * @lphb_conf_req: lphb config request
15128 *
15129 * Return: CDF status
15130 */
15131static
15132QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15133 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15134{
15135 QDF_STATUS status;
15136 wmi_buf_t buf = NULL;
15137 uint8_t *buf_ptr;
15138 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15139 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15140
15141 buf = wmi_buf_alloc(wmi_handle, len);
15142 if (!buf) {
15143 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15144 return QDF_STATUS_E_NOMEM;
15145 }
15146
15147 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15148 hb_udp_filter_fp =
15149 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15150 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15151 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15152 WMITLV_GET_STRUCT_TLVLEN
15153 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15154
15155 /* fill in values */
15156 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15157 hb_udp_filter_fp->length = lphb_conf_req->length;
15158 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15159 hb_udp_filter_fp->session = lphb_conf_req->session;
15160 memcpy((void *)&hb_udp_filter_fp->filter,
15161 (void *)&lphb_conf_req->filter,
15162 WMI_WLAN_HB_MAX_FILTER_SIZE);
15163
15164 status = wmi_unified_cmd_send(wmi_handle, buf,
15165 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15166 if (QDF_IS_STATUS_ERROR(status)) {
15167 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15168 status);
15169 wmi_buf_free(buf);
15170 }
15171
15172 return status;
15173}
15174#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015175
Dustin Brownf31f88b2017-05-12 14:01:44 -070015176static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15177 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015178{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015179 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015180 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015181 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015182
Dustin Brownf31f88b2017-05-12 14:01:44 -070015183 if (!req) {
15184 WMI_LOGE("req is null");
15185 return QDF_STATUS_E_INVAL;
15186 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015187
Dustin Brownf31f88b2017-05-12 14:01:44 -070015188 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15189 if (!wmi_buf) {
15190 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015191 return QDF_STATUS_E_NOMEM;
15192 }
15193
Dustin Brownf31f88b2017-05-12 14:01:44 -070015194 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015195 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015196 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15197 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15198 cmd->vdev_id = req->vdev_id;
15199 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15200 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015201
Dustin Brownf31f88b2017-05-12 14:01:44 -070015202 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15203 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015204
Dustin Brownf31f88b2017-05-12 14:01:44 -070015205 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15206 WMI_HW_DATA_FILTER_CMDID);
15207 if (QDF_IS_STATUS_ERROR(status)) {
15208 WMI_LOGE("Failed to configure hw filter");
15209 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015210 }
15211
Dustin Brownf31f88b2017-05-12 14:01:44 -070015212 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015213}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015214
15215/**
15216 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15217 * @wmi_handle: wmi handle
15218 * @vdev_id: vdev id
15219 * @enable: Flag to enable/disable packet filter
15220 *
15221 * Return: QDF_STATUS_SUCCESS for success or error code
15222 */
15223static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15224 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15225{
15226 int32_t len;
15227 int ret = 0;
15228 wmi_buf_t buf;
15229 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15230
15231 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15232
15233 buf = wmi_buf_alloc(wmi_handle, len);
15234 if (!buf) {
15235 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15236 return QDF_STATUS_E_NOMEM;
15237 }
15238
15239 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15240 WMITLV_SET_HDR(&cmd->tlv_header,
15241 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15242 WMITLV_GET_STRUCT_TLVLEN(
15243 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15244
15245 cmd->vdev_id = vdev_id;
15246 if (enable)
15247 cmd->enable = PACKET_FILTER_SET_ENABLE;
15248 else
15249 cmd->enable = PACKET_FILTER_SET_DISABLE;
15250
15251 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15252 __func__, cmd->enable, vdev_id);
15253
15254 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15255 WMI_PACKET_FILTER_ENABLE_CMDID);
15256 if (ret) {
15257 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15258 wmi_buf_free(buf);
15259 }
15260
15261 return ret;
15262}
15263
15264/**
15265 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15266 * @wmi_handle: wmi handle
15267 * @vdev_id: vdev id
15268 * @rcv_filter_param: Packet filter parameters
15269 * @filter_id: Filter id
15270 * @enable: Flag to add/delete packet filter configuration
15271 *
15272 * Return: QDF_STATUS_SUCCESS for success or error code
15273 */
15274static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15275 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15276 uint8_t filter_id, bool enable)
15277{
15278 int len, i;
15279 int err = 0;
15280 wmi_buf_t buf;
15281 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15282
15283
15284 /* allocate the memory */
15285 len = sizeof(*cmd);
15286 buf = wmi_buf_alloc(wmi_handle, len);
15287 if (!buf) {
15288 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15289 return QDF_STATUS_E_NOMEM;
15290 }
15291
15292 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15293 WMITLV_SET_HDR(&cmd->tlv_header,
15294 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15295 WMITLV_GET_STRUCT_TLVLEN
15296 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15297
15298 cmd->vdev_id = vdev_id;
15299 cmd->filter_id = filter_id;
15300 if (enable)
15301 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15302 else
15303 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15304
15305 if (enable) {
15306 cmd->num_params = QDF_MIN(
15307 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15308 rcv_filter_param->num_params);
15309 cmd->filter_type = rcv_filter_param->filter_type;
15310 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15311
15312 for (i = 0; i < cmd->num_params; i++) {
15313 cmd->paramsData[i].proto_type =
15314 rcv_filter_param->params_data[i].protocol_layer;
15315 cmd->paramsData[i].cmp_type =
15316 rcv_filter_param->params_data[i].compare_flag;
15317 cmd->paramsData[i].data_length =
15318 rcv_filter_param->params_data[i].data_length;
15319 cmd->paramsData[i].data_offset =
15320 rcv_filter_param->params_data[i].data_offset;
15321 memcpy(&cmd->paramsData[i].compareData,
15322 rcv_filter_param->params_data[i].compare_data,
15323 sizeof(cmd->paramsData[i].compareData));
15324 memcpy(&cmd->paramsData[i].dataMask,
15325 rcv_filter_param->params_data[i].data_mask,
15326 sizeof(cmd->paramsData[i].dataMask));
15327 }
15328 }
15329
15330 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15331 cmd->filter_action, cmd->filter_id, cmd->num_params);
15332 /* send the command along with data */
15333 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15334 WMI_PACKET_FILTER_CONFIG_CMDID);
15335 if (err) {
15336 WMI_LOGE("Failed to send pkt_filter cmd");
15337 wmi_buf_free(buf);
15338 return QDF_STATUS_E_FAILURE;
15339 }
15340
15341 return QDF_STATUS_SUCCESS;
15342}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015343#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015344
Govind Singha4836fd2016-03-07 16:45:38 +053015345/**
15346 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15347 * @wmi_handle: wmi handle
15348 * @request: SSID hotlist set request
15349 *
Govind Singhb53420c2016-03-09 14:32:57 +053015350 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015351 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015352static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015353send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15354 struct ssid_hotlist_request_params *request)
15355{
15356 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15357 wmi_buf_t wmi_buf;
15358 uint32_t len;
15359 uint32_t array_size;
15360 uint8_t *buf_ptr;
15361
15362 /* length of fixed portion */
15363 len = sizeof(*cmd);
15364
15365 /* length of variable portion */
15366 array_size =
15367 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15368 len += WMI_TLV_HDR_SIZE + array_size;
15369
15370 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15371 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015372 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15373 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015374 }
15375
15376 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15377 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15378 buf_ptr;
15379 WMITLV_SET_HDR
15380 (&cmd->tlv_header,
15381 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15382 WMITLV_GET_STRUCT_TLVLEN
15383 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15384
15385 cmd->request_id = request->request_id;
15386 cmd->requestor_id = 0;
15387 cmd->vdev_id = request->session_id;
15388 cmd->table_id = 0;
15389 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15390 cmd->total_entries = request->ssid_count;
15391 cmd->num_entries_in_page = request->ssid_count;
15392 cmd->first_entry_index = 0;
15393
15394 buf_ptr += sizeof(*cmd);
15395 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15396
15397 if (request->ssid_count) {
15398 wmi_extscan_hotlist_ssid_entry *entry;
15399 int i;
15400
15401 buf_ptr += WMI_TLV_HDR_SIZE;
15402 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15403 for (i = 0; i < request->ssid_count; i++) {
15404 WMITLV_SET_HDR
15405 (entry,
15406 WMITLV_TAG_ARRAY_STRUC,
15407 WMITLV_GET_STRUCT_TLVLEN
15408 (wmi_extscan_hotlist_ssid_entry));
15409 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015410 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015411 request->ssids[i].ssid.mac_ssid,
15412 request->ssids[i].ssid.length);
15413 entry->band = request->ssids[i].band;
15414 entry->min_rssi = request->ssids[i].rssi_low;
15415 entry->max_rssi = request->ssids[i].rssi_high;
15416 entry++;
15417 }
15418 cmd->mode = WMI_EXTSCAN_MODE_START;
15419 } else {
15420 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15421 }
15422
15423 if (wmi_unified_cmd_send
15424 (wmi_handle, wmi_buf, len,
15425 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015426 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015427 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015428 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015429 }
15430
Govind Singhb53420c2016-03-09 14:32:57 +053015431 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015432}
15433
15434/**
15435 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15436 * @wmi_handle: wmi handle
15437 * @vdev_id: vdev id
15438 *
15439 * This function sends roam synch complete event to fw.
15440 *
15441 * Return: CDF STATUS
15442 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015443static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015444 uint8_t vdev_id)
15445{
15446 wmi_roam_synch_complete_fixed_param *cmd;
15447 wmi_buf_t wmi_buf;
15448 uint8_t *buf_ptr;
15449 uint16_t len;
15450 len = sizeof(wmi_roam_synch_complete_fixed_param);
15451
15452 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15453 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015454 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15455 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015456 }
15457 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15458 buf_ptr = (uint8_t *) cmd;
15459 WMITLV_SET_HDR(&cmd->tlv_header,
15460 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15461 WMITLV_GET_STRUCT_TLVLEN
15462 (wmi_roam_synch_complete_fixed_param));
15463 cmd->vdev_id = vdev_id;
15464 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15465 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015466 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015467 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015468 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015469 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015470 }
15471
Govind Singhb53420c2016-03-09 14:32:57 +053015472 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015473}
15474
15475/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015476 * send_fw_test_cmd_tlv() - send fw test command to fw.
15477 * @wmi_handle: wmi handle
15478 * @wmi_fwtest: fw test command
15479 *
15480 * This function sends fw test command to fw.
15481 *
15482 * Return: CDF STATUS
15483 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015484static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015485QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15486 struct set_fwtest_params *wmi_fwtest)
15487{
15488 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15489 wmi_buf_t wmi_buf;
15490 uint16_t len;
15491
15492 len = sizeof(*cmd);
15493
15494 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15495 if (!wmi_buf) {
15496 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15497 return QDF_STATUS_E_NOMEM;
15498 }
15499
15500 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15501 WMITLV_SET_HDR(&cmd->tlv_header,
15502 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15503 WMITLV_GET_STRUCT_TLVLEN(
15504 wmi_fwtest_set_param_cmd_fixed_param));
15505 cmd->param_id = wmi_fwtest->arg;
15506 cmd->param_value = wmi_fwtest->value;
15507
15508 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15509 WMI_FWTEST_CMDID)) {
15510 WMI_LOGP("%s: failed to send fw test command", __func__);
15511 qdf_nbuf_free(wmi_buf);
15512 return QDF_STATUS_E_FAILURE;
15513 }
15514
15515 return QDF_STATUS_SUCCESS;
15516}
15517
15518/**
Govind Singha4836fd2016-03-07 16:45:38 +053015519 * send_unit_test_cmd_tlv() - send unit test command to fw.
15520 * @wmi_handle: wmi handle
15521 * @wmi_utest: unit test command
15522 *
15523 * This function send unit test command to fw.
15524 *
15525 * Return: CDF STATUS
15526 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015527static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015528 struct wmi_unit_test_cmd *wmi_utest)
15529{
15530 wmi_unit_test_cmd_fixed_param *cmd;
15531 wmi_buf_t wmi_buf;
15532 uint8_t *buf_ptr;
15533 int i;
15534 uint16_t len, args_tlv_len;
15535 A_UINT32 *unit_test_cmd_args;
15536
15537 args_tlv_len =
15538 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
15539 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15540
15541 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15542 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015543 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15544 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015545 }
15546
15547 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15548 buf_ptr = (uint8_t *) cmd;
15549 WMITLV_SET_HDR(&cmd->tlv_header,
15550 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15551 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15552 cmd->vdev_id = wmi_utest->vdev_id;
15553 cmd->module_id = wmi_utest->module_id;
15554 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015555 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015556 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15558 (wmi_utest->num_args * sizeof(uint32_t)));
15559 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015560 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15561 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15562 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015563 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053015564 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15565 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015566 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015567 }
15568 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15569 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015570 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015571 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015572 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015573 }
15574
Govind Singhb53420c2016-03-09 14:32:57 +053015575 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015576}
15577
15578/**
15579 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15580 * @wmi_handle: wma handle
15581 * @roaminvoke: roam invoke command
15582 *
15583 * Send roam invoke command to fw for fastreassoc.
15584 *
15585 * Return: CDF STATUS
15586 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015587static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015588 struct wmi_roam_invoke_cmd *roaminvoke,
15589 uint32_t ch_hz)
15590{
15591 wmi_roam_invoke_cmd_fixed_param *cmd;
15592 wmi_buf_t wmi_buf;
15593 u_int8_t *buf_ptr;
15594 u_int16_t len, args_tlv_len;
15595 A_UINT32 *channel_list;
15596 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015597 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015598
15599 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080015600 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
15601 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15602 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015603 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15604 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15605 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015606 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15607 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015608 }
15609
15610 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15611 buf_ptr = (u_int8_t *) cmd;
15612 WMITLV_SET_HDR(&cmd->tlv_header,
15613 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15614 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15615 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015616 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015617 if (roaminvoke->is_same_bssid)
15618 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15619 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015620
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015621 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015622 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015623 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15624 cmd->num_buf = 1;
15625 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015626 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015627 cmd->num_buf = 0;
15628 }
Naveen Rawat77797922017-01-20 17:00:07 -080015629
Govind Singha4836fd2016-03-07 16:45:38 +053015630 cmd->roam_ap_sel_mode = 0;
15631 cmd->roam_delay = 0;
15632 cmd->num_chan = 1;
15633 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015634
Govind Singha4836fd2016-03-07 16:45:38 +053015635 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15637 (sizeof(u_int32_t)));
15638 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
15639 *channel_list = ch_hz;
15640 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
15641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15642 (sizeof(wmi_mac_addr)));
15643 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15644 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015645
15646 /* move to next tlv i.e. bcn_prb_buf_list */
15647 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15648
15649 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15650 sizeof(wmi_tlv_buf_len_param));
15651
15652 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15653 buf_len_tlv->buf_len = roaminvoke->frame_len;
15654
15655 /* move to next tlv i.e. bcn_prb_frm */
15656 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15658 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15659
15660 /* copy frame after the header */
15661 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15662 roaminvoke->frame_buf,
15663 roaminvoke->frame_len);
15664
15665 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15666 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15667 buf_ptr + WMI_TLV_HDR_SIZE,
15668 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015669 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15670 cmd->flags, cmd->roam_scan_mode,
15671 cmd->roam_ap_sel_mode, cmd->roam_delay,
15672 cmd->num_chan, cmd->num_bssid);
15673 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015674
Govind Singha4836fd2016-03-07 16:45:38 +053015675 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15676 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015677 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015678 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015679 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015680 }
15681
Govind Singhb53420c2016-03-09 14:32:57 +053015682 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015683}
15684
15685/**
15686 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15687 * @wmi_handle: wmi handle
15688 * @command: command
15689 * @vdev_id: vdev id
15690 *
15691 * This function set roam offload command to fw.
15692 *
15693 * Return: CDF status
15694 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015695static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015696 uint32_t command, uint32_t vdev_id)
15697{
Govind Singh67922e82016-04-01 16:48:57 +053015698 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015699 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15700 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015701 int len;
15702 uint8_t *buf_ptr;
15703
15704 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15705 buf = wmi_buf_alloc(wmi_handle, len);
15706 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015707 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15708 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015709 }
15710
15711 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15712
15713 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15714 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15715 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15716 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15717 cmd_fp->vdev_id = vdev_id;
15718 cmd_fp->command_arg = command;
15719
15720 status = wmi_unified_cmd_send(wmi_handle, buf,
15721 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015722 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015723 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015724 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015725 goto error;
15726 }
15727
Govind Singhb53420c2016-03-09 14:32:57 +053015728 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15729 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015730
15731error:
15732 wmi_buf_free(buf);
15733
Govind Singh67922e82016-04-01 16:48:57 +053015734 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015735}
15736
15737/**
15738 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15739 * @wmi_handle: wmi handle
15740 * @ap_profile_p: ap profile
15741 * @vdev_id: vdev id
15742 *
15743 * Send WMI_ROAM_AP_PROFILE to firmware
15744 *
15745 * Return: CDF status
15746 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015747static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015748 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015749{
Govind Singha4836fd2016-03-07 16:45:38 +053015750 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015751 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015752 int len;
15753 uint8_t *buf_ptr;
15754 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015755 wmi_roam_cnd_scoring_param *score_param;
15756 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015757
15758 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015759 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015760 buf = wmi_buf_alloc(wmi_handle, len);
15761 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015762 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15763 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015764 }
15765
15766 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15767 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15768 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15769 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15770 WMITLV_GET_STRUCT_TLVLEN
15771 (wmi_roam_ap_profile_fixed_param));
15772 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015773 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015774 roam_ap_profile_fp->id = 0;
15775 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15776
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015777 profile = (wmi_ap_profile *)buf_ptr;
15778 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015779 WMITLV_TAG_STRUC_wmi_ap_profile,
15780 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015781 profile->flags = ap_profile->profile.flags;
15782 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15783 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15784 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15785 profile->ssid.ssid_len);
15786 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15787 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15788 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15789 profile->rsn_mcastmgmtcipherset =
15790 ap_profile->profile.rsn_mcastmgmtcipherset;
15791 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15792
15793 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",
15794 profile->flags, profile->rssi_threshold,
15795 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15796 profile->rsn_authmode, profile->rsn_ucastcipherset,
15797 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15798 profile->rssi_abs_thresh);
15799
15800 buf_ptr += sizeof(wmi_ap_profile);
15801
15802 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15803 WMITLV_SET_HDR(&score_param->tlv_header,
15804 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15805 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15806 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15807 score_param->rssi_weightage_pcnt =
15808 ap_profile->param.rssi_weightage;
15809 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15810 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15811 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15812 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15813 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15814 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15815 score_param->esp_qbss_weightage_pcnt =
15816 ap_profile->param.esp_qbss_weightage;
15817 score_param->beamforming_weightage_pcnt =
15818 ap_profile->param.beamforming_weightage;
15819 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15820 score_param->oce_wan_weightage_pcnt =
15821 ap_profile->param.oce_wan_weightage;
15822
15823 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",
15824 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15825 score_param->ht_weightage_pcnt,
15826 score_param->vht_weightage_pcnt,
15827 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15828 score_param->band_weightage_pcnt,
15829 score_param->nss_weightage_pcnt,
15830 score_param->esp_qbss_weightage_pcnt,
15831 score_param->beamforming_weightage_pcnt,
15832 score_param->pcl_weightage_pcnt,
15833 score_param->oce_wan_weightage_pcnt);
15834
15835 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15836 score_param->band_scoring.score_pcnt =
15837 ap_profile->param.band_index_score;
15838 score_param->nss_scoring.score_pcnt =
15839 ap_profile->param.nss_index_score;
15840
15841 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15842 score_param->bw_scoring.score_pcnt,
15843 score_param->band_scoring.score_pcnt,
15844 score_param->nss_scoring.score_pcnt);
15845
15846 score_param->rssi_scoring.best_rssi_threshold =
15847 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15848 score_param->rssi_scoring.good_rssi_threshold =
15849 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15850 score_param->rssi_scoring.bad_rssi_threshold =
15851 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15852 score_param->rssi_scoring.good_rssi_pcnt =
15853 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15854 score_param->rssi_scoring.bad_rssi_pcnt =
15855 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15856 score_param->rssi_scoring.good_bucket_size =
15857 ap_profile->param.rssi_scoring.good_bucket_size;
15858 score_param->rssi_scoring.bad_bucket_size =
15859 ap_profile->param.rssi_scoring.bad_bucket_size;
15860 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15861 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15862
15863 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15864 score_param->rssi_scoring.best_rssi_threshold,
15865 score_param->rssi_scoring.good_rssi_threshold,
15866 score_param->rssi_scoring.bad_rssi_threshold,
15867 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15868 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15869 score_param->rssi_scoring.good_rssi_pcnt,
15870 score_param->rssi_scoring.bad_rssi_pcnt,
15871 score_param->rssi_scoring.good_bucket_size,
15872 score_param->rssi_scoring.bad_bucket_size);
15873
15874 score_param->esp_qbss_scoring.num_slot =
15875 ap_profile->param.esp_qbss_scoring.num_slot;
15876 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15877 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15878 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15879 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15880 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15881 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15882 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15883 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15884
15885 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15886 score_param->esp_qbss_scoring.num_slot,
15887 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15888 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15889 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15890 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15891
15892 score_param->oce_wan_scoring.num_slot =
15893 ap_profile->param.oce_wan_scoring.num_slot;
15894 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15895 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15896 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15897 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15898 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15899 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15900 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15901 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15902
15903 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15904 score_param->oce_wan_scoring.num_slot,
15905 score_param->oce_wan_scoring.score_pcnt3_to_0,
15906 score_param->oce_wan_scoring.score_pcnt7_to_4,
15907 score_param->oce_wan_scoring.score_pcnt11_to_8,
15908 score_param->oce_wan_scoring.score_pcnt15_to_12);
15909
Govind Singha4836fd2016-03-07 16:45:38 +053015910 status = wmi_unified_cmd_send(wmi_handle, buf,
15911 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015912 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015913 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015914 status);
Govind Singh67922e82016-04-01 16:48:57 +053015915 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015916 }
15917
Govind Singhb53420c2016-03-09 14:32:57 +053015918 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015919
Govind Singh67922e82016-04-01 16:48:57 +053015920 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015921}
15922
15923/**
15924 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15925 * @wmi_handle: wmi handle
15926 * @scan_period: scan period
15927 * @scan_age: scan age
15928 * @vdev_id: vdev id
15929 *
15930 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15931 *
15932 * Return: CDF status
15933 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015934static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015935 uint32_t scan_period,
15936 uint32_t scan_age,
15937 uint32_t vdev_id)
15938{
Govind Singh67922e82016-04-01 16:48:57 +053015939 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015940 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015941 int len;
15942 uint8_t *buf_ptr;
15943 wmi_roam_scan_period_fixed_param *scan_period_fp;
15944
15945 /* Send scan period values */
15946 len = sizeof(wmi_roam_scan_period_fixed_param);
15947 buf = wmi_buf_alloc(wmi_handle, len);
15948 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015949 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15950 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015951 }
15952
15953 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15954 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15955 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15956 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15957 WMITLV_GET_STRUCT_TLVLEN
15958 (wmi_roam_scan_period_fixed_param));
15959 /* fill in scan period values */
15960 scan_period_fp->vdev_id = vdev_id;
15961 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15962 scan_period_fp->roam_scan_age = scan_age;
15963
15964 status = wmi_unified_cmd_send(wmi_handle, buf,
15965 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015966 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015967 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015968 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015969 goto error;
15970 }
15971
Govind Singhb53420c2016-03-09 14:32:57 +053015972 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015973 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015974 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015975error:
15976 wmi_buf_free(buf);
15977
Govind Singh67922e82016-04-01 16:48:57 +053015978 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015979}
15980
15981/**
15982 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15983 * @wmi_handle: wmi handle
15984 * @chan_count: channel count
15985 * @chan_list: channel list
15986 * @list_type: list type
15987 * @vdev_id: vdev id
15988 *
15989 * Set roam offload channel list.
15990 *
15991 * Return: CDF status
15992 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015993static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015994 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015995 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015996 uint8_t list_type, uint32_t vdev_id)
15997{
Govind Singha4836fd2016-03-07 16:45:38 +053015998 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015999 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016000 int len, list_tlv_len;
16001 int i;
16002 uint8_t *buf_ptr;
16003 wmi_roam_chan_list_fixed_param *chan_list_fp;
16004 A_UINT32 *roam_chan_list_array;
16005
16006 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016007 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016008 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016009 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016010 }
16011 /* Channel list is a table of 2 TLV's */
16012 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
16013 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16014 buf = wmi_buf_alloc(wmi_handle, len);
16015 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016016 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16017 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016018 }
16019
16020 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16021 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16022 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16023 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16024 WMITLV_GET_STRUCT_TLVLEN
16025 (wmi_roam_chan_list_fixed_param));
16026 chan_list_fp->vdev_id = vdev_id;
16027 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016028 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016029 /* external app is controlling channel list */
16030 chan_list_fp->chan_list_type =
16031 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16032 } else {
16033 /* umac supplied occupied channel list in LFR */
16034 chan_list_fp->chan_list_type =
16035 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16036 }
16037
16038 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16039 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16040 (chan_list_fp->num_chan * sizeof(uint32_t)));
16041 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016042 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016043 for (i = 0; ((i < chan_list_fp->num_chan) &&
16044 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16045 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016046 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016047 }
16048
16049 status = wmi_unified_cmd_send(wmi_handle, buf,
16050 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016051 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016052 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016053 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016054 goto error;
16055 }
16056
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016057 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016058 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016059error:
16060 wmi_buf_free(buf);
16061
Govind Singh67922e82016-04-01 16:48:57 +053016062 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016063}
16064
16065/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016066 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16067 * @wmi_handle: wmi handle
16068 * @req_buf: per roam config buffer
16069 *
16070 * Return: QDF status
16071 */
16072static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16073 struct wmi_per_roam_config_req *req_buf)
16074{
16075 wmi_buf_t buf = NULL;
16076 QDF_STATUS status;
16077 int len;
16078 uint8_t *buf_ptr;
16079 wmi_roam_per_config_fixed_param *wmi_per_config;
16080
16081 len = sizeof(wmi_roam_per_config_fixed_param);
16082 buf = wmi_buf_alloc(wmi_handle, len);
16083 if (!buf) {
16084 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16085 return QDF_STATUS_E_NOMEM;
16086 }
16087
16088 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16089 wmi_per_config =
16090 (wmi_roam_per_config_fixed_param *) buf_ptr;
16091 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16092 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16093 WMITLV_GET_STRUCT_TLVLEN
16094 (wmi_roam_per_config_fixed_param));
16095
16096 /* fill in per roam config values */
16097 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016098
16099 wmi_per_config->enable = req_buf->per_config.enable;
16100 wmi_per_config->high_rate_thresh =
16101 (req_buf->per_config.tx_high_rate_thresh << 16) |
16102 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16103 wmi_per_config->low_rate_thresh =
16104 (req_buf->per_config.tx_low_rate_thresh << 16) |
16105 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16106 wmi_per_config->pkt_err_rate_thresh_pct =
16107 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16108 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16109 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016110 wmi_per_config->pkt_err_rate_mon_time =
16111 (req_buf->per_config.tx_per_mon_time << 16) |
16112 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016113 wmi_per_config->min_candidate_rssi =
16114 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016115
16116 /* Send per roam config parameters */
16117 status = wmi_unified_cmd_send(wmi_handle, buf,
16118 len, WMI_ROAM_PER_CONFIG_CMDID);
16119 if (QDF_IS_STATUS_ERROR(status)) {
16120 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16121 status);
16122 wmi_buf_free(buf);
16123 return status;
16124 }
16125
16126 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16127 req_buf->per_config.enable, req_buf->vdev_id);
16128 return QDF_STATUS_SUCCESS;
16129}
16130
16131/**
Govind Singha4836fd2016-03-07 16:45:38 +053016132 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16133 * @wmi_handle: wmi handle
16134 * @rssi_change_thresh: RSSI Change threshold
16135 * @bcn_rssi_weight: beacon RSSI weight
16136 * @vdev_id: vdev id
16137 *
16138 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16139 *
16140 * Return: CDF status
16141 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016142static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016143 uint32_t vdev_id,
16144 int32_t rssi_change_thresh,
16145 uint32_t bcn_rssi_weight,
16146 uint32_t hirssi_delay_btw_scans)
16147{
Govind Singha4836fd2016-03-07 16:45:38 +053016148 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016149 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016150 int len;
16151 uint8_t *buf_ptr;
16152 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16153
16154 /* Send rssi change parameters */
16155 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16156 buf = wmi_buf_alloc(wmi_handle, len);
16157 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016158 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16159 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016160 }
16161
16162 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16163 rssi_change_fp =
16164 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16165 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16166 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16167 WMITLV_GET_STRUCT_TLVLEN
16168 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16169 /* fill in rssi change threshold (hysteresis) values */
16170 rssi_change_fp->vdev_id = vdev_id;
16171 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16172 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16173 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16174
16175 status = wmi_unified_cmd_send(wmi_handle, buf,
16176 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016177 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016178 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016179 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016180 goto error;
16181 }
16182
Govind Singhb53420c2016-03-09 14:32:57 +053016183 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016184 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016185 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16186 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016187error:
16188 wmi_buf_free(buf);
16189
Govind Singh67922e82016-04-01 16:48:57 +053016190 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016191}
16192
16193/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16194 * @wmi_handle: wmi handle.
16195 * @cmd: size of command structure.
16196 * @per_entry_size: per entry size.
16197 *
16198 * This utility function calculates how many hotlist entries can
16199 * fit in one page.
16200 *
16201 * Return: number of entries
16202 */
16203static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16204 size_t cmd_size,
16205 size_t per_entry_size)
16206{
16207 uint32_t avail_space = 0;
16208 int num_entries = 0;
16209 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16210
16211 /* Calculate number of hotlist entries that can
16212 * be passed in wma message request.
16213 */
16214 avail_space = max_msg_len - cmd_size;
16215 num_entries = avail_space / per_entry_size;
16216 return num_entries;
16217}
16218
16219/**
16220 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16221 * @wmi_handle: wmi handle
16222 * @photlist: hotlist command params
16223 * @buf_len: buffer length
16224 *
16225 * This function fills individual elements for hotlist request and
16226 * TLV for bssid entries
16227 *
16228 * Return: CDF Status.
16229 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016230static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016231 struct ext_scan_setbssi_hotlist_params *
16232 photlist, int *buf_len)
16233{
16234 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16235 wmi_extscan_hotlist_entry *dest_hotlist;
16236 struct ap_threshold_params *src_ap = photlist->ap;
16237 wmi_buf_t buf;
16238 uint8_t *buf_ptr;
16239
16240 int j, index = 0;
16241 int cmd_len = 0;
16242 int num_entries;
16243 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016244 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016245 int len = sizeof(*cmd);
16246
16247 len += WMI_TLV_HDR_SIZE;
16248 cmd_len = len;
16249
16250 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16251 cmd_len,
16252 sizeof(*dest_hotlist));
16253 /* setbssid hotlist expects the bssid list
16254 * to be non zero value
16255 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016256 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016257 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016258 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016259 }
16260
16261 /* Split the hot list entry pages and send multiple command
16262 * requests if the buffer reaches the maximum request size
16263 */
16264 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016265 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016266 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16267 buf = wmi_buf_alloc(wmi_handle, len);
16268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016269 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16270 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016271 }
16272 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16273 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16274 buf_ptr;
16275 WMITLV_SET_HDR(&cmd->tlv_header,
16276 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16277 WMITLV_GET_STRUCT_TLVLEN
16278 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16279
16280 /* Multiple requests are sent until the num_entries_in_page
16281 * matches the total_entries
16282 */
16283 cmd->request_id = photlist->requestId;
16284 cmd->vdev_id = photlist->sessionId;
16285 cmd->total_entries = numap;
16286 cmd->mode = 1;
16287 cmd->num_entries_in_page = min_entries;
16288 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16289 cmd->first_entry_index = index;
16290
Govind Singhb53420c2016-03-09 14:32:57 +053016291 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016292 __func__, cmd->vdev_id, cmd->total_entries,
16293 cmd->num_entries_in_page,
16294 cmd->lost_ap_scan_count);
16295
16296 buf_ptr += sizeof(*cmd);
16297 WMITLV_SET_HDR(buf_ptr,
16298 WMITLV_TAG_ARRAY_STRUC,
16299 min_entries * sizeof(wmi_extscan_hotlist_entry));
16300 dest_hotlist = (wmi_extscan_hotlist_entry *)
16301 (buf_ptr + WMI_TLV_HDR_SIZE);
16302
16303 /* Populate bssid, channel info and rssi
16304 * for the bssid's that are sent as hotlists.
16305 */
16306 for (j = 0; j < min_entries; j++) {
16307 WMITLV_SET_HDR(dest_hotlist,
16308 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16309 WMITLV_GET_STRUCT_TLVLEN
16310 (wmi_extscan_hotlist_entry));
16311
16312 dest_hotlist->min_rssi = src_ap->low;
16313 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16314 &dest_hotlist->bssid);
16315
Govind Singhb53420c2016-03-09 14:32:57 +053016316 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016317 __func__, dest_hotlist->channel,
16318 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016319 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016320 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16321 __func__, dest_hotlist->bssid.mac_addr31to0,
16322 dest_hotlist->bssid.mac_addr47to32);
16323 dest_hotlist++;
16324 src_ap++;
16325 }
16326 buf_ptr += WMI_TLV_HDR_SIZE +
16327 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16328
16329 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16330 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016331 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016332 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016333 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016334 }
16335 index = index + min_entries;
16336 num_entries = numap - min_entries;
16337 len = cmd_len;
16338 }
Govind Singhb53420c2016-03-09 14:32:57 +053016339 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016340}
16341
Govind Singhbca3b1b2016-05-02 17:59:24 +053016342/**
Dustin Brown4423f632017-01-13 15:24:07 -080016343 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16344 * @wmi_handle: the WMI handle
16345 * @vdev_id: the Id of the vdev to apply the configuration to
16346 * @ucast_mode: the active BPF mode to configure for unicast packets
16347 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16348 * packets
16349 *
16350 * Return: QDF status
16351 */
16352static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16353 uint8_t vdev_id,
16354 enum wmi_host_active_bpf_mode ucast_mode,
16355 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16356{
16357 const WMITLV_TAG_ID tag_id =
16358 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16359 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16360 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16361 QDF_STATUS status;
16362 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16363 wmi_buf_t buf;
16364
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016365 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016366 vdev_id, ucast_mode, mcast_bcast_mode);
16367
16368 /* allocate command buffer */
16369 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16370 if (!buf) {
16371 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16372 return QDF_STATUS_E_NOMEM;
16373 }
16374
16375 /* set TLV header */
16376 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16377 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16378
16379 /* populate data */
16380 cmd->vdev_id = vdev_id;
16381 cmd->uc_mode = ucast_mode;
16382 cmd->mcbc_mode = mcast_bcast_mode;
16383
16384 /* send to FW */
16385 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16386 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16387 if (QDF_IS_STATUS_ERROR(status)) {
16388 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16389 status);
16390 wmi_buf_free(buf);
16391 return status;
16392 }
16393
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016394 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016395
16396 return QDF_STATUS_SUCCESS;
16397}
16398
16399/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016400 * send_power_dbg_cmd_tlv() - send power debug commands
16401 * @wmi_handle: wmi handle
16402 * @param: wmi power debug parameter
16403 *
16404 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16405 *
16406 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16407 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016408static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16409 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016410{
16411 wmi_buf_t buf = NULL;
16412 QDF_STATUS status;
16413 int len, args_tlv_len;
16414 uint8_t *buf_ptr;
16415 uint8_t i;
16416 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16417 uint32_t *cmd_args;
16418
16419 /* Prepare and send power debug cmd parameters */
16420 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16421 len = sizeof(*cmd) + args_tlv_len;
16422 buf = wmi_buf_alloc(wmi_handle, len);
16423 if (!buf) {
16424 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16425 return QDF_STATUS_E_NOMEM;
16426 }
16427
16428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16429 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16430 WMITLV_SET_HDR(&cmd->tlv_header,
16431 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16432 WMITLV_GET_STRUCT_TLVLEN
16433 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16434
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016435 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16436 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016437 cmd->module_id = param->module_id;
16438 cmd->num_args = param->num_args;
16439 buf_ptr += sizeof(*cmd);
16440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16441 (param->num_args * sizeof(uint32_t)));
16442 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16443 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
16444 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
16445 cmd_args[i] = param->args[i];
16446 WMI_LOGI("%d,", param->args[i]);
16447 }
16448
16449 status = wmi_unified_cmd_send(wmi_handle, buf,
16450 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16451 if (QDF_IS_STATUS_ERROR(status)) {
16452 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16453 status);
16454 goto error;
16455 }
16456
16457 return QDF_STATUS_SUCCESS;
16458error:
16459 wmi_buf_free(buf);
16460
16461 return status;
16462}
16463
Govind Singhe7f2f342016-05-23 12:12:52 +053016464/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016465 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16466 * @wmi_handle: wmi handle
16467 * @param: wmi multiple vdev restart req param
16468 *
16469 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16470 *
16471 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16472 */
16473static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16474 wmi_unified_t wmi_handle,
16475 struct multiple_vdev_restart_params *param)
16476{
16477 wmi_buf_t buf;
16478 QDF_STATUS qdf_status;
16479 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16480 int i;
16481 uint8_t *buf_ptr;
16482 uint32_t *vdev_ids;
16483 wmi_channel *chan_info;
16484 struct channel_param *tchan_info;
16485 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16486
16487 len += sizeof(wmi_channel);
16488 if (param->num_vdevs)
16489 len += sizeof(uint32_t) * param->num_vdevs;
16490
16491 buf = wmi_buf_alloc(wmi_handle, len);
16492 if (!buf) {
16493 WMI_LOGE("Failed to allocate memory\n");
16494 qdf_status = QDF_STATUS_E_NOMEM;
16495 goto end;
16496 }
16497
16498 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16499 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16500 buf_ptr;
16501
16502 WMITLV_SET_HDR(&cmd->tlv_header,
16503 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16504 WMITLV_GET_STRUCT_TLVLEN
16505 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016506 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16507 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016508 cmd->requestor_id = param->requestor_id;
16509 cmd->disable_hw_ack = param->disable_hw_ack;
16510 cmd->cac_duration_ms = param->cac_duration_ms;
16511 cmd->num_vdevs = param->num_vdevs;
16512
16513 buf_ptr += sizeof(*cmd);
16514
16515 WMITLV_SET_HDR(buf_ptr,
16516 WMITLV_TAG_ARRAY_UINT32,
16517 sizeof(A_UINT32) * param->num_vdevs);
16518 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16519 for (i = 0; i < param->num_vdevs; i++) {
16520 vdev_ids[i] = param->vdev_ids[i];
16521 }
16522
16523 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
16524
16525 WMITLV_SET_HDR(buf_ptr,
16526 WMITLV_TAG_STRUC_wmi_channel,
16527 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016528 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016529 tchan_info = &(param->ch_param);
16530 chan_info->mhz = tchan_info->mhz;
16531 chan_info->band_center_freq1 = tchan_info->cfreq1;
16532 chan_info->band_center_freq2 = tchan_info->cfreq2;
16533 if (tchan_info->is_chan_passive)
16534 WMI_SET_CHANNEL_FLAG(chan_info,
16535 WMI_CHAN_FLAG_PASSIVE);
16536 if (tchan_info->allow_vht)
16537 WMI_SET_CHANNEL_FLAG(chan_info,
16538 WMI_CHAN_FLAG_ALLOW_VHT);
16539 else if (tchan_info->allow_ht)
16540 WMI_SET_CHANNEL_FLAG(chan_info,
16541 WMI_CHAN_FLAG_ALLOW_HT);
16542 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16543 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16544 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16545 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16546 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16547 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016548 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016549
16550 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16551 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16552
16553 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16554 WMI_LOGE("%s: Failed to send\n", __func__);
16555 wmi_buf_free(buf);
16556 }
16557
16558end:
16559 return qdf_status;
16560}
16561
16562/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016563 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16564 * @wmi_handle: wmi handle
16565 * @pdev_id: pdev id
16566 *
16567 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16568 *
16569 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16570 */
16571static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16572 uint32_t pdev_id)
16573{
16574 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16575 wmi_buf_t buf;
16576 uint16_t len;
16577 QDF_STATUS ret;
16578
16579 len = sizeof(*cmd);
16580 buf = wmi_buf_alloc(wmi_handle, len);
16581
16582 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16583
16584 if (!buf) {
16585 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16586 return QDF_STATUS_E_NOMEM;
16587 }
16588
16589 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16590 wmi_buf_data(buf);
16591
16592 WMITLV_SET_HDR(&cmd->tlv_header,
16593 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16594 WMITLV_GET_STRUCT_TLVLEN(
16595 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16596
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016597 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016598 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16599 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16600 if (QDF_IS_STATUS_ERROR(ret)) {
16601 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16602 __func__, ret, pdev_id);
16603 wmi_buf_free(buf);
16604 return QDF_STATUS_E_FAILURE;
16605 }
16606
16607 return QDF_STATUS_SUCCESS;
16608}
16609
16610/**
16611 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16612 * @wmi_handle: wmi handle
16613 * @pdev_id: pdev id
16614 *
16615 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16616 *
16617 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16618 */
16619static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16620 uint32_t pdev_id)
16621{
16622 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16623 wmi_buf_t buf;
16624 uint16_t len;
16625 QDF_STATUS ret;
16626
16627 len = sizeof(*cmd);
16628 buf = wmi_buf_alloc(wmi_handle, len);
16629
16630 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16631
16632 if (!buf) {
16633 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16634 return QDF_STATUS_E_NOMEM;
16635 }
16636
16637 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16638 wmi_buf_data(buf);
16639
16640 WMITLV_SET_HDR(&cmd->tlv_header,
16641 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16642 WMITLV_GET_STRUCT_TLVLEN(
16643 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16644
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016645 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016646 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16647 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16648 if (QDF_IS_STATUS_ERROR(ret)) {
16649 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16650 __func__, ret, pdev_id);
16651 wmi_buf_free(buf);
16652 return QDF_STATUS_E_FAILURE;
16653 }
16654
16655 return QDF_STATUS_SUCCESS;
16656}
16657
16658/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016659 * init_cmd_send_tlv() - send initialization cmd to fw
16660 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016661 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016662 *
16663 * Return: QDF_STATUS_SUCCESS for success or error code
16664 */
16665static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016666 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016667{
16668 wmi_buf_t buf;
16669 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016670 uint8_t *buf_ptr;
16671 wmi_resource_config *resource_cfg;
16672 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016673 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016674 uint16_t idx;
16675 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016676 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016677
Kiran Venkatappa26117052016-12-23 19:58:54 +053016678 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16679 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016680 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016681
16682 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16683 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16684 WMI_TLV_HDR_SIZE +
16685 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16686
16687 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016688 if (!buf) {
16689 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16690 return QDF_STATUS_E_FAILURE;
16691 }
16692
16693 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16694 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16695 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16696
16697 host_mem_chunks = (wlan_host_memory_chunk *)
16698 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16699 + WMI_TLV_HDR_SIZE);
16700
16701 WMITLV_SET_HDR(&cmd->tlv_header,
16702 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16703 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16704
Kiran Venkatappa26117052016-12-23 19:58:54 +053016705 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016706 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16707 WMITLV_TAG_STRUC_wmi_resource_config,
16708 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16709
Kiran Venkatappa26117052016-12-23 19:58:54 +053016710 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016711 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16712 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16713 WMITLV_GET_STRUCT_TLVLEN
16714 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016715 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16716 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16717 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016718 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16719 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016720 idx, host_mem_chunks[idx].size,
16721 host_mem_chunks[idx].ptr);
16722 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016723 cmd->num_host_mem_chunks = param->num_mem_chunks;
16724 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16725
Govind Singhe7f2f342016-05-23 12:12:52 +053016726 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16727 WMITLV_TAG_ARRAY_STRUC,
16728 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016729 param->num_mem_chunks));
16730
16731 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016732 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016733
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016734 /* Fill fw_abi_vers */
16735 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016736
Abhishek Singh716c46c2016-05-04 16:24:07 +053016737 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16738 if (QDF_IS_STATUS_ERROR(ret)) {
16739 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16740 ret);
16741 wmi_buf_free(buf);
16742 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016743
Abhishek Singh716c46c2016-05-04 16:24:07 +053016744 return ret;
16745
Govind Singhe7f2f342016-05-23 12:12:52 +053016746}
16747
16748/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016749 * send_addba_send_cmd_tlv() - send addba send command to fw
16750 * @wmi_handle: wmi handle
16751 * @param: pointer to delba send params
16752 * @macaddr: peer mac address
16753 *
16754 * Send WMI_ADDBA_SEND_CMDID command to firmware
16755 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16756 */
16757static QDF_STATUS
16758send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16759 uint8_t macaddr[IEEE80211_ADDR_LEN],
16760 struct addba_send_params *param)
16761{
16762 wmi_addba_send_cmd_fixed_param *cmd;
16763 wmi_buf_t buf;
16764 uint16_t len;
16765 QDF_STATUS ret;
16766
16767 len = sizeof(*cmd);
16768
16769 buf = wmi_buf_alloc(wmi_handle, len);
16770 if (!buf) {
16771 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16772 return QDF_STATUS_E_NOMEM;
16773 }
16774
16775 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16776
16777 WMITLV_SET_HDR(&cmd->tlv_header,
16778 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16779 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16780
16781 cmd->vdev_id = param->vdev_id;
16782 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16783 cmd->tid = param->tidno;
16784 cmd->buffersize = param->buffersize;
16785
16786 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16787 if (QDF_IS_STATUS_ERROR(ret)) {
16788 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16789 wmi_buf_free(buf);
16790 return QDF_STATUS_E_FAILURE;
16791 }
16792
16793 return QDF_STATUS_SUCCESS;
16794}
16795
16796/**
16797 * send_delba_send_cmd_tlv() - send delba send command to fw
16798 * @wmi_handle: wmi handle
16799 * @param: pointer to delba send params
16800 * @macaddr: peer mac address
16801 *
16802 * Send WMI_DELBA_SEND_CMDID command to firmware
16803 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16804 */
16805static QDF_STATUS
16806send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16807 uint8_t macaddr[IEEE80211_ADDR_LEN],
16808 struct delba_send_params *param)
16809{
16810 wmi_delba_send_cmd_fixed_param *cmd;
16811 wmi_buf_t buf;
16812 uint16_t len;
16813 QDF_STATUS ret;
16814
16815 len = sizeof(*cmd);
16816
16817 buf = wmi_buf_alloc(wmi_handle, len);
16818 if (!buf) {
16819 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16820 return QDF_STATUS_E_NOMEM;
16821 }
16822
16823 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16824
16825 WMITLV_SET_HDR(&cmd->tlv_header,
16826 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16827 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16828
16829 cmd->vdev_id = param->vdev_id;
16830 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16831 cmd->tid = param->tidno;
16832 cmd->initiator = param->initiator;
16833 cmd->reasoncode = param->reasoncode;
16834
16835 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16836 if (QDF_IS_STATUS_ERROR(ret)) {
16837 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16838 wmi_buf_free(buf);
16839 return QDF_STATUS_E_FAILURE;
16840 }
16841
16842 return QDF_STATUS_SUCCESS;
16843}
16844
16845/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016846 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16847 * to fw
16848 * @wmi_handle: wmi handle
16849 * @param: pointer to addba clearresp params
16850 * @macaddr: peer mac address
16851 * Return: 0 for success or error code
16852 */
16853static QDF_STATUS
16854send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16855 uint8_t macaddr[IEEE80211_ADDR_LEN],
16856 struct addba_clearresponse_params *param)
16857{
16858 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16859 wmi_buf_t buf;
16860 uint16_t len;
16861 QDF_STATUS ret;
16862
16863 len = sizeof(*cmd);
16864
16865 buf = wmi_buf_alloc(wmi_handle, len);
16866 if (!buf) {
16867 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16868 return QDF_STATUS_E_FAILURE;
16869 }
16870 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16871
16872 WMITLV_SET_HDR(&cmd->tlv_header,
16873 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16874 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16875
16876 cmd->vdev_id = param->vdev_id;
16877 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16878
16879 ret = wmi_unified_cmd_send(wmi_handle,
16880 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16881 if (QDF_IS_STATUS_ERROR(ret)) {
16882 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16883 wmi_buf_free(buf);
16884 return QDF_STATUS_E_FAILURE;
16885 }
16886
16887 return QDF_STATUS_SUCCESS;
16888}
16889
16890/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016891 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16892 * @wmi_handle: wmi handle
16893 * @bcn_ctrl_param: pointer to bcn_offload_control param
16894 *
16895 * Return: QDF_STATUS_SUCCESS for success or error code
16896 */
16897static
16898QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16899 struct bcn_offload_control *bcn_ctrl_param)
16900{
16901 wmi_buf_t buf;
16902 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16903 QDF_STATUS ret;
16904 uint32_t len;
16905
16906 len = sizeof(*cmd);
16907
16908 buf = wmi_buf_alloc(wmi_handle, len);
16909 if (!buf) {
16910 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16911 return QDF_STATUS_E_FAILURE;
16912 }
16913
16914 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16915 WMITLV_SET_HDR(&cmd->tlv_header,
16916 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16917 WMITLV_GET_STRUCT_TLVLEN
16918 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16919 cmd->vdev_id = bcn_ctrl_param->vdev_id;
16920 if (bcn_ctrl_param->bcn_tx_enable)
16921 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16922 else
16923 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
16924
16925
16926 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16927 WMI_BCN_OFFLOAD_CTRL_CMDID);
16928
16929 if (QDF_IS_STATUS_ERROR(ret)) {
16930 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16931 ret);
16932 wmi_buf_free(buf);
16933 }
16934
16935 return ret;
16936}
16937
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016938#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16939static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16940 struct nan_datapath_initiator_req *ndp_req)
16941{
16942 uint16_t len;
16943 wmi_buf_t buf;
16944 uint8_t *tlv_ptr;
16945 QDF_STATUS status;
16946 wmi_channel *ch_tlv;
16947 wmi_ndp_initiator_req_fixed_param *cmd;
16948 uint32_t passphrase_len, service_name_len;
16949 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
16950
16951 /*
16952 * WMI command expects 4 byte alligned len:
16953 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16954 */
16955 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16956 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16957 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16958 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16959 service_name_len =
16960 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16961 /* allocated memory for fixed params as well as variable size data */
16962 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16963 + ndp_cfg_len + ndp_app_info_len + pmk_len
16964 + passphrase_len + service_name_len;
16965
16966 buf = wmi_buf_alloc(wmi_handle, len);
16967 if (!buf) {
16968 WMI_LOGE("wmi_buf_alloc failed");
16969 return QDF_STATUS_E_NOMEM;
16970 }
16971
16972 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16973 WMITLV_SET_HDR(&cmd->tlv_header,
16974 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16975 WMITLV_GET_STRUCT_TLVLEN(
16976 wmi_ndp_initiator_req_fixed_param));
16977 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16978 cmd->transaction_id = ndp_req->transaction_id;
16979 cmd->service_instance_id = ndp_req->service_instance_id;
16980 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16981 &cmd->peer_discovery_mac_addr);
16982
16983 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16984 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16985 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16986 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16987 cmd->nan_csid = ndp_req->ncs_sk_type;
16988 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16989 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16990
16991 ch_tlv = (wmi_channel *)&cmd[1];
16992 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16993 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16994 ch_tlv->mhz = ndp_req->channel;
16995 tlv_ptr = (uint8_t *)&ch_tlv[1];
16996
16997 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16998 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16999 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17000 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17001
17002 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17003 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17004 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17005 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17006
17007 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17008 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17009 cmd->nan_pmk_len);
17010 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17011
17012 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17013 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17014 cmd->nan_passphrase_len);
17015 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17016
17017 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17018 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17019 ndp_req->service_name.service_name,
17020 cmd->nan_servicename_len);
17021 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17022
17023 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17024 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17025 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17026 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17027 cmd->peer_discovery_mac_addr.mac_addr31to0,
17028 cmd->peer_discovery_mac_addr.mac_addr47to32);
17029
17030 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17031 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17032 ndp_req->ndp_config.ndp_cfg,
17033 ndp_req->ndp_config.ndp_cfg_len);
17034
17035 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17036 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17037 ndp_req->ndp_info.ndp_app_info,
17038 ndp_req->ndp_info.ndp_app_info_len);
17039
17040 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17041 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17042 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17043
17044 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17045 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17046 ndp_req->passphrase.passphrase,
17047 cmd->nan_passphrase_len);
17048
17049 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17050 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17051 ndp_req->service_name.service_name,
17052 cmd->nan_servicename_len);
17053
17054 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17055 WMI_NDP_INITIATOR_REQ_CMDID);
17056
17057 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17058 WMI_NDP_INITIATOR_REQ_CMDID);
17059 if (QDF_IS_STATUS_ERROR(status)) {
17060 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17061 wmi_buf_free(buf);
17062 }
17063
17064 return status;
17065}
17066
17067static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17068 struct nan_datapath_responder_req *req)
17069{
17070 uint16_t len;
17071 wmi_buf_t buf;
17072 uint8_t *tlv_ptr;
17073 QDF_STATUS status;
17074 wmi_ndp_responder_req_fixed_param *cmd;
17075 uint32_t passphrase_len, service_name_len;
17076 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17077
17078 vdev_id = wlan_vdev_get_id(req->vdev);
17079 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17080 vdev_id, req->transaction_id,
17081 req->ndp_rsp,
17082 req->ndp_instance_id,
17083 req->ndp_info.ndp_app_info_len);
17084
17085 /*
17086 * WMI command expects 4 byte alligned len:
17087 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17088 */
17089 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17090 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17091 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17092 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17093 service_name_len =
17094 qdf_roundup(req->service_name.service_name_len, 4);
17095
17096 /* allocated memory for fixed params as well as variable size data */
17097 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17098 + pmk_len + passphrase_len + service_name_len;
17099
17100 buf = wmi_buf_alloc(wmi_handle, len);
17101 if (!buf) {
17102 WMI_LOGE("wmi_buf_alloc failed");
17103 return QDF_STATUS_E_NOMEM;
17104 }
17105 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17106 WMITLV_SET_HDR(&cmd->tlv_header,
17107 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17108 WMITLV_GET_STRUCT_TLVLEN(
17109 wmi_ndp_responder_req_fixed_param));
17110 cmd->vdev_id = vdev_id;
17111 cmd->transaction_id = req->transaction_id;
17112 cmd->ndp_instance_id = req->ndp_instance_id;
17113 cmd->rsp_code = req->ndp_rsp;
17114 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17115 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17116 cmd->nan_pmk_len = req->pmk.pmk_len;
17117 cmd->nan_csid = req->ncs_sk_type;
17118 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17119 cmd->nan_servicename_len = req->service_name.service_name_len;
17120
17121 tlv_ptr = (uint8_t *)&cmd[1];
17122 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17123 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17124 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17125
17126 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17127 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17128 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17129 req->ndp_info.ndp_app_info,
17130 req->ndp_info.ndp_app_info_len);
17131
17132 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17133 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17134 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17135 cmd->nan_pmk_len);
17136
17137 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17138 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17139 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17140 req->passphrase.passphrase,
17141 cmd->nan_passphrase_len);
17142 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17143
17144 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17145 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17146 req->service_name.service_name,
17147 cmd->nan_servicename_len);
17148
17149 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17150
17151 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17152 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17153
17154 WMI_LOGD("ndp_config len: %d",
17155 req->ndp_config.ndp_cfg_len);
17156 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17157 req->ndp_config.ndp_cfg,
17158 req->ndp_config.ndp_cfg_len);
17159
17160 WMI_LOGD("ndp_app_info len: %d",
17161 req->ndp_info.ndp_app_info_len);
17162 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17163 req->ndp_info.ndp_app_info,
17164 req->ndp_info.ndp_app_info_len);
17165
17166 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17167 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17168 req->pmk.pmk, cmd->nan_pmk_len);
17169
17170 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17171 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17172 req->passphrase.passphrase,
17173 cmd->nan_passphrase_len);
17174
17175 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17176 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17177 req->service_name.service_name,
17178 cmd->nan_servicename_len);
17179
17180 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17181 WMI_NDP_RESPONDER_REQ_CMDID);
17182 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17183 WMI_NDP_RESPONDER_REQ_CMDID);
17184 if (QDF_IS_STATUS_ERROR(status)) {
17185 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17186 wmi_buf_free(buf);
17187 }
17188 return status;
17189}
17190
17191static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17192 struct nan_datapath_end_req *req)
17193{
17194 uint16_t len;
17195 wmi_buf_t buf;
17196 QDF_STATUS status;
17197 uint32_t ndp_end_req_len, i;
17198 wmi_ndp_end_req *ndp_end_req_lst;
17199 wmi_ndp_end_req_fixed_param *cmd;
17200
17201 /* len of tlv following fixed param */
17202 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17203 /* above comes out to 4 byte alligned already, no need of padding */
17204 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17205 buf = wmi_buf_alloc(wmi_handle, len);
17206 if (!buf) {
17207 WMI_LOGE("Malloc failed");
17208 return QDF_STATUS_E_NOMEM;
17209 }
17210
17211 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17212 WMITLV_SET_HDR(&cmd->tlv_header,
17213 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17214 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17215
17216 cmd->transaction_id = req->transaction_id;
17217
17218 /* set tlv pointer to end of fixed param */
17219 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17220 ndp_end_req_len);
17221
17222 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17223 WMI_TLV_HDR_SIZE);
17224 for (i = 0; i < req->num_ndp_instances; i++) {
17225 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17226 WMITLV_TAG_ARRAY_FIXED_STRUC,
17227 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17228
17229 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17230 }
17231
17232 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17233 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17234 WMI_NDP_END_REQ_CMDID);
17235 if (QDF_IS_STATUS_ERROR(status)) {
17236 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17237 wmi_buf_free(buf);
17238 }
17239
17240 return status;
17241}
17242
17243static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
17244 uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
17245{
17246 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17247 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17248
17249 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17250 fixed_params = event->fixed_param;
17251
17252 *rsp = qdf_mem_malloc(sizeof(**rsp));
17253 if (!(*rsp)) {
17254 WMI_LOGE("malloc failed");
17255 return QDF_STATUS_E_NOMEM;
17256 }
17257
17258 (*rsp)->vdev =
17259 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17260 fixed_params->vdev_id,
17261 WLAN_NAN_ID);
17262 if (!(*rsp)->vdev) {
17263 WMI_LOGE("vdev is null");
17264 qdf_mem_free(*rsp);
17265 return QDF_STATUS_E_INVAL;
17266 }
17267
17268 (*rsp)->transaction_id = fixed_params->transaction_id;
17269 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17270 (*rsp)->status = fixed_params->rsp_status;
17271 (*rsp)->reason = fixed_params->reason_code;
17272
17273 return QDF_STATUS_SUCCESS;
17274}
17275
17276static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
17277 uint8_t *data, struct nan_datapath_indication_event **rsp)
17278{
17279 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17280 wmi_ndp_indication_event_fixed_param *fixed_params;
17281
17282 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17283 fixed_params =
17284 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17285
17286 *rsp = qdf_mem_malloc(sizeof(**rsp));
17287 if (!(*rsp)) {
17288 WMI_LOGE("malloc failed");
17289 return QDF_STATUS_E_NOMEM;
17290 }
17291
17292 (*rsp)->vdev =
17293 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17294 fixed_params->vdev_id,
17295 WLAN_NAN_ID);
17296 if (!(*rsp)->vdev) {
17297 WMI_LOGE("vdev is null");
17298 qdf_mem_free(*rsp);
17299 return QDF_STATUS_E_INVAL;
17300 }
17301 (*rsp)->service_instance_id = fixed_params->service_instance_id;
17302 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17303 (*rsp)->role = fixed_params->self_ndp_role;
17304 (*rsp)->policy = fixed_params->accept_policy;
17305
17306 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17307 (*rsp)->peer_mac_addr.bytes);
17308 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
17309 (*rsp)->peer_discovery_mac_addr.bytes);
17310
17311 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17312 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17313 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17314 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17315 fixed_params->service_instance_id,
17316 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17317 fixed_params->accept_policy,
17318 fixed_params->nan_csid, fixed_params->nan_scid_len,
17319 (*rsp)->peer_mac_addr.bytes,
17320 (*rsp)->peer_discovery_mac_addr.bytes);
17321
17322 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17323 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17324 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17325
17326 WMI_LOGD("ndp_app_info - %d bytes",
17327 fixed_params->ndp_app_info_len);
17328 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17329 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17330
17331 (*rsp)->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17332 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17333 (*rsp)->ncs_sk_type = fixed_params->nan_csid;
17334 (*rsp)->scid.scid_len = fixed_params->nan_scid_len;
17335 qdf_mem_copy((*rsp)->ndp_config.ndp_cfg, event->ndp_cfg,
17336 (*rsp)->ndp_config.ndp_cfg_len);
17337 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17338 (*rsp)->ndp_info.ndp_app_info_len);
17339 qdf_mem_copy((*rsp)->scid.scid, event->ndp_scid, (*rsp)->scid.scid_len);
17340 WMI_LOGD("scid hex dump:");
17341 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17342 (*rsp)->scid.scid, (*rsp)->scid.scid_len);
17343
17344 return QDF_STATUS_SUCCESS;
17345}
17346
17347static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
17348 uint8_t *data, struct nan_datapath_confirm_event **rsp)
17349{
17350 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17351 wmi_ndp_confirm_event_fixed_param *fixed_params;
17352
17353 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17354 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17355 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",
17356 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17357 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17358 fixed_params->reason_code,
17359 fixed_params->num_active_ndps_on_peer);
17360 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17361 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17362 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17363
17364 WMI_LOGD("ndp_app_info - %d bytes",
17365 fixed_params->ndp_app_info_len);
17366 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17367 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17368
17369 *rsp = qdf_mem_malloc(sizeof(**rsp));
17370 if (!(*rsp)) {
17371 WMI_LOGE("malloc failed");
17372 return QDF_STATUS_E_NOMEM;
17373 }
17374
17375 (*rsp)->vdev =
17376 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17377 fixed_params->vdev_id,
17378 WLAN_NAN_ID);
17379 if (!(*rsp)->vdev) {
17380 WMI_LOGE("vdev is null");
17381 qdf_mem_free(*rsp);
17382 return QDF_STATUS_E_INVAL;
17383 }
17384 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17385 (*rsp)->rsp_code = fixed_params->rsp_code;
17386 (*rsp)->reason_code = fixed_params->reason_code;
17387 (*rsp)->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
17388 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17389 (*rsp)->peer_ndi_mac_addr.bytes);
17390 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17391 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17392 (*rsp)->ndp_info.ndp_app_info_len);
17393
17394 return QDF_STATUS_SUCCESS;
17395}
17396
17397static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
17398 uint8_t *data, struct nan_datapath_responder_rsp **rsp)
17399{
17400 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17401 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17402
17403 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17404 fixed_params = event->fixed_param;
17405
17406 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",
17407 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
17408 (*rsp)->peer_mac_addr.bytes, (*rsp)->transaction_id,
17409 (*rsp)->status, (*rsp)->reason, (*rsp)->create_peer);
17410
17411 *rsp = qdf_mem_malloc(sizeof(**rsp));
17412 if (!(*rsp)) {
17413 WMI_LOGE("malloc failed");
17414 return QDF_STATUS_E_NOMEM;
17415 }
17416
17417 (*rsp)->vdev =
17418 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17419 fixed_params->vdev_id,
17420 WLAN_NAN_ID);
17421 if (!(*rsp)->vdev) {
17422 WMI_LOGE("vdev is null");
17423 qdf_mem_free(*rsp);
17424 return QDF_STATUS_E_INVAL;
17425 }
17426 (*rsp)->transaction_id = fixed_params->transaction_id;
17427 (*rsp)->reason = fixed_params->reason_code;
17428 (*rsp)->status = fixed_params->rsp_status;
17429 (*rsp)->create_peer = fixed_params->create_peer;
17430 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17431 (*rsp)->peer_mac_addr.bytes);
17432
17433 return QDF_STATUS_SUCCESS;
17434}
17435
17436static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
17437 uint8_t *data, struct nan_datapath_end_rsp_event **rsp)
17438{
17439 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17440 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17441
17442 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17443 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17444 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17445 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17446 fixed_params->rsp_status, fixed_params->reason_code);
17447
17448 *rsp = qdf_mem_malloc(sizeof(**rsp));
17449 if (!(*rsp)) {
17450 WMI_LOGE("malloc failed");
17451 return QDF_STATUS_E_NOMEM;
17452 }
17453
17454 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17455 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17456 if (!(*rsp)->vdev) {
17457 WMI_LOGE("vdev is null");
17458 qdf_mem_free(*rsp);
17459 return QDF_STATUS_E_INVAL;
17460 }
17461 (*rsp)->transaction_id = fixed_params->transaction_id;
17462 (*rsp)->reason = fixed_params->reason_code;
17463 (*rsp)->status = fixed_params->rsp_status;
17464
17465 return QDF_STATUS_SUCCESS;
17466}
17467
17468static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17469 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17470{
17471 uint32_t i, buf_size;
17472 wmi_ndp_end_indication *ind;
17473 struct qdf_mac_addr peer_addr;
17474 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17475
17476 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17477 ind = event->ndp_end_indication_list;
17478
17479 if (event->num_ndp_end_indication_list == 0) {
17480 WMI_LOGE("Error: Event ignored, 0 ndp instances");
17481 return -EINVAL;
17482 }
17483
17484 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17485 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17486 if (!(*rsp)->vdev) {
17487 WMI_LOGE("vdev is null");
17488 qdf_mem_free(*rsp);
17489 return QDF_STATUS_E_INVAL;
17490 }
17491
17492 WMI_LOGD("number of ndp instances = %d",
17493 event->num_ndp_end_indication_list);
17494 buf_size = sizeof(*rsp) + event->num_ndp_end_indication_list *
17495 sizeof((*rsp)->ndp_map[0]);
17496 *rsp = qdf_mem_malloc(buf_size);
17497 if (!(*rsp)) {
17498 WMI_LOGE("Failed to allocate memory");
17499 return -ENOMEM;
17500 }
17501
17502 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17503 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17504 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17505 peer_addr.bytes);
17506 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17507 i, ind[i].type, ind[i].reason_code,
17508 ind[i].ndp_instance_id,
17509 ind[i].num_active_ndps_on_peer);
17510 /* Add each instance entry to the list */
17511 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17512 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17513 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17514 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17515 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17516 ind[i].num_active_ndps_on_peer;
17517 (*rsp)->ndp_map[i].type = ind[i].type;
17518 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17519 }
17520
17521 return QDF_STATUS_SUCCESS;
17522}
17523#endif
17524
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017525/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017526 * save_service_bitmap_tlv() - save service bitmap
17527 * @wmi_handle: wmi handle
17528 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017529 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017530 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017531 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017532 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017533static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017534QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017535 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017536{
17537 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017538 struct wmi_soc *soc = wmi_handle->soc;
17539
Govind Singhe7f2f342016-05-23 12:12:52 +053017540 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17541
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017542 /* If it is already allocated, use that buffer. This can happen
17543 * during target stop/start scenarios where host allocation is skipped.
17544 */
17545 if (!soc->wmi_service_bitmap) {
17546 soc->wmi_service_bitmap =
17547 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17548 if (!soc->wmi_service_bitmap) {
17549 WMI_LOGE("Failed memory allocation for service bitmap");
17550 return QDF_STATUS_E_NOMEM;
17551 }
17552 }
17553
17554 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017555 param_buf->wmi_service_bitmap,
17556 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017557
17558 if (bitmap_buf)
17559 qdf_mem_copy(bitmap_buf,
17560 param_buf->wmi_service_bitmap,
17561 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017562
17563 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017564}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017565
17566/**
17567 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17568 * @wmi_handle: wmi handle
17569 * @param evt_buf: pointer to event buffer
17570 * @param bitmap_buf: bitmap buffer, for converged legacy support
17571 *
17572 * Return: QDF_STATUS
17573 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017574static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017575QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017576 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017577{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017578 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17579 wmi_service_available_event_fixed_param *ev;
17580 struct wmi_soc *soc = wmi_handle->soc;
17581
17582 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17583
17584 ev = param_buf->fixed_param;
17585
17586 /* If it is already allocated, use that buffer. This can happen
17587 * during target stop/start scenarios where host allocation is skipped.
17588 */
17589 if (!soc->wmi_ext_service_bitmap) {
17590 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17591 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17592 if (!soc->wmi_ext_service_bitmap) {
17593 WMI_LOGE("Failed memory allocation for service bitmap");
17594 return QDF_STATUS_E_NOMEM;
17595 }
17596 }
17597
17598 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17599 ev->wmi_service_segment_bitmap,
17600 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017601
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017602 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17603 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17604 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17605
Rajeev Kumar77901472017-02-12 02:12:17 -080017606 if (bitmap_buf)
17607 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017608 soc->wmi_ext_service_bitmap,
17609 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017610
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017611 return QDF_STATUS_SUCCESS;
17612}
Govind Singhe7f2f342016-05-23 12:12:52 +053017613/**
17614 * is_service_enabled_tlv() - Check if service enabled
17615 * @param wmi_handle: wmi handle
17616 * @param service_id: service identifier
17617 *
17618 * Return: 1 enabled, 0 disabled
17619 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017620static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17621 uint32_t service_id)
17622{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017623 struct wmi_soc *soc = wmi_handle->soc;
17624
17625 if (!soc->wmi_service_bitmap) {
17626 WMI_LOGE("WMI service bit map is not saved yet\n");
17627 return false;
17628 }
17629
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017630 /* if wmi_service_enabled was received with extended bitmap,
17631 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017632 */
17633 if (soc->wmi_ext_service_bitmap)
17634 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17635 soc->wmi_ext_service_bitmap,
17636 service_id);
17637
17638 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17639 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017640}
Govind Singhe7f2f342016-05-23 12:12:52 +053017641
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017642static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17643 struct wlan_psoc_target_capability_info *cap)
17644{
17645 /* except LDPC all flags are common betwen legacy and here
17646 * also IBFEER is not defined for TLV
17647 */
17648 cap->ht_cap_info |= ev_target_cap & (
17649 WMI_HT_CAP_ENABLED
17650 | WMI_HT_CAP_HT20_SGI
17651 | WMI_HT_CAP_DYNAMIC_SMPS
17652 | WMI_HT_CAP_TX_STBC
17653 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17654 | WMI_HT_CAP_RX_STBC
17655 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17656 | WMI_HT_CAP_LDPC
17657 | WMI_HT_CAP_L_SIG_TXOP_PROT
17658 | WMI_HT_CAP_MPDU_DENSITY
17659 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17660 | WMI_HT_CAP_HT40_SGI);
17661 if (ev_target_cap & WMI_HT_CAP_LDPC)
17662 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17663 WMI_HOST_HT_CAP_TX_LDPC;
17664}
Govind Singhe7f2f342016-05-23 12:12:52 +053017665/**
17666 * extract_service_ready_tlv() - extract service ready event
17667 * @wmi_handle: wmi handle
17668 * @param evt_buf: pointer to received event buffer
17669 * @param cap: pointer to hold target capability information extracted from even
17670 *
17671 * Return: QDF_STATUS_SUCCESS for success or error code
17672 */
17673static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017674 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017675{
17676 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17677 wmi_service_ready_event_fixed_param *ev;
17678
17679
17680 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17681
17682 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17683 if (!ev) {
17684 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17685 return QDF_STATUS_E_FAILURE;
17686 }
17687
17688 cap->phy_capability = ev->phy_capability;
17689 cap->max_frag_entry = ev->max_frag_entry;
17690 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017691 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017692 cap->vht_cap_info = ev->vht_cap_info;
17693 cap->vht_supp_mcs = ev->vht_supp_mcs;
17694 cap->hw_min_tx_power = ev->hw_min_tx_power;
17695 cap->hw_max_tx_power = ev->hw_max_tx_power;
17696 cap->sys_cap_info = ev->sys_cap_info;
17697 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17698 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17699 cap->max_num_scan_channels = ev->max_num_scan_channels;
17700 cap->max_supported_macs = ev->max_supported_macs;
17701 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17702 cap->txrx_chainmask = ev->txrx_chainmask;
17703 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17704 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017705 cap->fw_version = ev->fw_build_vers;
17706 /* fw_version_1 is not available in TLV. */
17707 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017708
17709 return QDF_STATUS_SUCCESS;
17710}
17711
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017712/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17713 * to host internal WMI_HOST_REGDMN_MODE values.
17714 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17715 * host currently. Add this in the future if required.
17716 * 11AX (Phase II) : 11ax related values are not currently
17717 * advertised separately by FW. As part of phase II regulatory bring-up,
17718 * finalize the advertisement mechanism.
17719 * @target_wireless_mode: target wireless mode received in message
17720 *
17721 * Return: returns the host internal wireless mode.
17722 */
17723static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17724{
17725
17726 uint32_t wireless_modes = 0;
17727
17728 if (target_wireless_mode & REGDMN_MODE_11A)
17729 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17730
17731 if (target_wireless_mode & REGDMN_MODE_TURBO)
17732 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17733
17734 if (target_wireless_mode & REGDMN_MODE_11B)
17735 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17736
17737 if (target_wireless_mode & REGDMN_MODE_PUREG)
17738 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17739
17740 if (target_wireless_mode & REGDMN_MODE_11G)
17741 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17742
17743 if (target_wireless_mode & REGDMN_MODE_108G)
17744 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17745
17746 if (target_wireless_mode & REGDMN_MODE_108A)
17747 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17748
17749 if (target_wireless_mode & REGDMN_MODE_XR)
17750 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17751
17752 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17753 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17754
17755 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17756 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17757
17758 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17759 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17760
17761 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17762 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17763
17764 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17765 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17766
17767 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17768 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17769
17770 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17771 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17772
17773 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17774 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17775
17776 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17777 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17778
17779 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17780 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17781
17782 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17783 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17784
17785 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17786 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17787
17788 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17789 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17790
17791 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17792 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17793
17794 return wireless_modes;
17795}
17796
Govind Singhe7f2f342016-05-23 12:12:52 +053017797/**
17798 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17799 * @wmi_handle: wmi handle
17800 * @param evt_buf: Pointer to event buffer
17801 * @param cap: pointer to hold HAL reg capabilities
17802 *
17803 * Return: QDF_STATUS_SUCCESS for success or error code
17804 */
17805static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017806 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017807{
17808 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17809
17810 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17811
17812 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17813 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017814 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017815
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017816 cap->wireless_modes = convert_wireless_modes_tlv(
17817 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017818
Govind Singhe7f2f342016-05-23 12:12:52 +053017819 return QDF_STATUS_SUCCESS;
17820}
17821
17822/**
17823 * extract_host_mem_req_tlv() - Extract host memory request event
17824 * @wmi_handle: wmi handle
17825 * @param evt_buf: pointer to event buffer
17826 * @param num_entries: pointer to hold number of entries requested
17827 *
17828 * Return: Number of entries requested
17829 */
17830static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17831 void *evt_buf, uint8_t *num_entries)
17832{
17833 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17834 wmi_service_ready_event_fixed_param *ev;
17835
17836 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17837
17838 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17839 if (!ev) {
17840 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17841 return NULL;
17842 }
17843
17844 *num_entries = ev->num_mem_reqs;
17845
17846 return (host_mem_req *)param_buf->mem_reqs;
17847}
17848
17849/**
17850 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17851 * ready function
17852 * @wmi_handle: wmi handle
17853 * @param evt_buf: pointer to event buffer
17854 *
17855 * Return: QDF_STATUS_SUCCESS for success or error code
17856 */
17857static QDF_STATUS
17858save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17859{
17860 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17861 wmi_service_ready_event_fixed_param *ev;
17862
17863
17864 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17865
17866 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17867 if (!ev) {
17868 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17869 return QDF_STATUS_E_FAILURE;
17870 }
17871
17872 /*Save fw version from service ready message */
17873 /*This will be used while sending INIT message */
17874 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17875 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017876
Govind Singhe7f2f342016-05-23 12:12:52 +053017877 return QDF_STATUS_SUCCESS;
17878}
17879
17880/**
17881 * ready_extract_init_status_tlv() - Extract init status from ready event
17882 * @wmi_handle: wmi handle
17883 * @param evt_buf: Pointer to event buffer
17884 *
17885 * Return: ready status
17886 */
17887static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17888 void *evt_buf)
17889{
17890 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17891 wmi_ready_event_fixed_param *ev = NULL;
17892
Govind Singhe7f2f342016-05-23 12:12:52 +053017893 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17894 ev = param_buf->fixed_param;
17895
17896 qdf_print("%s:%d\n", __func__, ev->status);
17897
17898 return ev->status;
17899}
17900
17901/**
17902 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17903 * @wmi_handle: wmi handle
17904 * @param evt_buf: pointer to event buffer
17905 * @param macaddr: Pointer to hold MAC address
17906 *
17907 * Return: QDF_STATUS_SUCCESS for success or error code
17908 */
17909static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17910 void *evt_buf, uint8_t *macaddr)
17911{
17912 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17913 wmi_ready_event_fixed_param *ev = NULL;
17914
17915
17916 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17917 ev = param_buf->fixed_param;
17918
17919 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17920
17921 return QDF_STATUS_SUCCESS;
17922}
17923
17924/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017925 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17926 * @wmi_handle: wmi handle
17927 * @param evt_buf: pointer to event buffer
17928 * @param macaddr: Pointer to hold number of MAC addresses
17929 *
17930 * Return: Pointer to addr list
17931 */
17932static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17933 void *evt_buf, uint8_t *num_mac)
17934{
17935 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17936 wmi_ready_event_fixed_param *ev = NULL;
17937
17938 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17939 ev = param_buf->fixed_param;
17940
17941 *num_mac = ev->num_extra_mac_addr;
17942
17943 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17944}
17945
17946/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017947 * extract_ready_params_tlv() - Extract data from ready event apart from
17948 * status, macaddr and version.
17949 * @wmi_handle: Pointer to WMI handle.
17950 * @evt_buf: Pointer to Ready event buffer.
17951 * @ev_param: Pointer to host defined struct to copy the data from event.
17952 *
17953 * Return: QDF_STATUS_SUCCESS on success.
17954 */
17955static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17956 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17957{
17958 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17959 wmi_ready_event_fixed_param *ev = NULL;
17960
17961 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17962 ev = param_buf->fixed_param;
17963
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017964 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017965 ev_param->num_dscp_table = ev->num_dscp_table;
17966 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17967 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017968 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017969 /* Agile_cap in ready event is not supported in TLV target */
17970 ev_param->agile_capability = false;
17971
17972 return QDF_STATUS_SUCCESS;
17973}
17974
17975/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017976 * extract_dbglog_data_len_tlv() - extract debuglog data length
17977 * @wmi_handle: wmi handle
17978 * @param evt_buf: pointer to event buffer
17979 *
17980 * Return: length
17981 */
17982static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017983 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017984{
17985 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17986
17987 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17988
17989 *len = param_buf->num_bufp;
17990
17991 return param_buf->bufp;
17992}
17993
17994/**
17995 * extract_vdev_start_resp_tlv() - extract vdev start response
17996 * @wmi_handle: wmi handle
17997 * @param evt_buf: pointer to event buffer
17998 * @param vdev_rsp: Pointer to hold vdev response
17999 *
18000 * Return: QDF_STATUS_SUCCESS for success or error code
18001 */
18002static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18003 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18004{
18005 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18006 wmi_vdev_start_response_event_fixed_param *ev;
18007
18008 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18009 if (!param_buf) {
18010 qdf_print("Invalid start response event buffer\n");
18011 return QDF_STATUS_E_INVAL;
18012 }
18013
18014 ev = param_buf->fixed_param;
18015 if (!ev) {
18016 qdf_print("Invalid start response event buffer\n");
18017 return QDF_STATUS_E_INVAL;
18018 }
18019
18020 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18021
18022 vdev_rsp->vdev_id = ev->vdev_id;
18023 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018024 switch (ev->resp_type) {
18025 case WMI_VDEV_START_RESP_EVENT:
18026 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18027 break;
18028 case WMI_VDEV_RESTART_RESP_EVENT:
18029 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18030 break;
18031 default:
18032 qdf_print("Invalid start response event buffer\n");
18033 break;
18034 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018035 vdev_rsp->status = ev->status;
18036 vdev_rsp->chain_mask = ev->chain_mask;
18037 vdev_rsp->smps_mode = ev->smps_mode;
18038 vdev_rsp->mac_id = ev->mac_id;
18039 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18040 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18041
18042 return QDF_STATUS_SUCCESS;
18043}
18044
18045/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018046 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18047 * @wmi_handle: wmi handle
18048 * @param evt_buf: pointer to event buffer
18049 * @param delete_rsp: Pointer to hold vdev delete response
18050 *
18051 * Return: QDF_STATUS_SUCCESS for success or error code
18052 */
18053static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18054 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18055{
18056 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18057 wmi_vdev_delete_resp_event_fixed_param *ev;
18058
18059 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18060 if (!param_buf) {
18061 WMI_LOGE("Invalid vdev delete response event buffer\n");
18062 return QDF_STATUS_E_INVAL;
18063 }
18064
18065 ev = param_buf->fixed_param;
18066 if (!ev) {
18067 WMI_LOGE("Invalid vdev delete response event\n");
18068 return QDF_STATUS_E_INVAL;
18069 }
18070
18071 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18072 delete_rsp->vdev_id = ev->vdev_id;
18073
18074 return QDF_STATUS_SUCCESS;
18075}
18076
18077
18078/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018079 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018080 * @wmi_handle: wmi handle
18081 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018082 * @param num_vdevs: Pointer to hold num vdev
18083 *
18084 * Return: QDF_STATUS_SUCCESS for success or error code
18085 */
18086static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18087 void *evt_buf, uint32_t *num_vdevs)
18088{
18089 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18090 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18091 uint32_t vdev_map;
18092
18093 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18094 if (!param_buf) {
18095 qdf_print("Invalid tbtt update ext event buffer\n");
18096 return QDF_STATUS_E_INVAL;
18097 }
18098 tbtt_offset_event = param_buf->fixed_param;
18099 vdev_map = tbtt_offset_event->vdev_map;
18100 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18101
18102 return QDF_STATUS_SUCCESS;
18103}
18104
18105/**
18106 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18107 * @wmi_handle: wmi handle
18108 * @param evt_buf: pointer to event buffer
18109 * @param num_vdevs: Pointer to hold num vdev
18110 *
18111 * Return: QDF_STATUS_SUCCESS for success or error code
18112 */
18113static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18114 void *evt_buf, uint32_t *num_vdevs)
18115{
18116 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18117 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18118
18119 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18120 if (!param_buf) {
18121 qdf_print("Invalid tbtt update ext event buffer\n");
18122 return QDF_STATUS_E_INVAL;
18123 }
18124 tbtt_offset_ext_event = param_buf->fixed_param;
18125
18126 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18127
18128 return QDF_STATUS_SUCCESS;
18129}
18130
18131/**
18132 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18133 * @wmi_handle: wmi handle
18134 * @param evt_buf: pointer to event buffer
18135 * @param idx: Index refering to a vdev
18136 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018137 *
18138 * Return: QDF_STATUS_SUCCESS for success or error code
18139 */
18140static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018141 void *evt_buf, uint8_t idx,
18142 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018143{
18144 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18145 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018146 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018147
18148 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18149 if (!param_buf) {
18150 qdf_print("Invalid tbtt update event buffer\n");
18151 return QDF_STATUS_E_INVAL;
18152 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018153
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018154 tbtt_offset_event = param_buf->fixed_param;
18155 vdev_map = tbtt_offset_event->vdev_map;
18156 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18157 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18158 return QDF_STATUS_E_INVAL;
18159 tbtt_param->tbttoffset =
18160 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18161
18162 return QDF_STATUS_SUCCESS;
18163}
18164
18165/**
18166 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18167 * @wmi_handle: wmi handle
18168 * @param evt_buf: pointer to event buffer
18169 * @param idx: Index refering to a vdev
18170 * @param tbtt_param: Pointer to tbttoffset event param
18171 *
18172 * Return: QDF_STATUS_SUCCESS for success or error code
18173 */
18174static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18175 void *evt_buf, uint8_t idx,
18176 struct tbttoffset_params *tbtt_param)
18177{
18178 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18179 wmi_tbtt_offset_info *tbtt_offset_info;
18180
18181 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18182 if (!param_buf) {
18183 qdf_print("Invalid tbtt update event buffer\n");
18184 return QDF_STATUS_E_INVAL;
18185 }
18186 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18187
18188 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18189 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018190
18191 return QDF_STATUS_SUCCESS;
18192}
18193
18194/**
18195 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18196 * @wmi_handle: wmi handle
18197 * @param evt_buf: pointer to event buffer
18198 * @param hdr: Pointer to hold header
18199 * @param bufp: Pointer to hold pointer to rx param buffer
18200 *
18201 * Return: QDF_STATUS_SUCCESS for success or error code
18202 */
18203static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018204 void *evt_buf, struct mgmt_rx_event_params *hdr,
18205 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018206{
18207 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18208 wmi_mgmt_rx_hdr *ev_hdr = NULL;
18209
18210 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18211 if (!param_tlvs) {
18212 WMI_LOGE("Get NULL point message from FW");
18213 return QDF_STATUS_E_INVAL;
18214 }
18215
18216 ev_hdr = param_tlvs->hdr;
18217 if (!hdr) {
18218 WMI_LOGE("Rx event is NULL");
18219 return QDF_STATUS_E_INVAL;
18220 }
18221
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018222 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18223 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018224
18225 hdr->channel = ev_hdr->channel;
18226 hdr->snr = ev_hdr->snr;
18227 hdr->rate = ev_hdr->rate;
18228 hdr->phy_mode = ev_hdr->phy_mode;
18229 hdr->buf_len = ev_hdr->buf_len;
18230 hdr->status = ev_hdr->status;
18231 hdr->flags = ev_hdr->flags;
18232 hdr->rssi = ev_hdr->rssi;
18233 hdr->tsf_delta = ev_hdr->tsf_delta;
18234 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
18235
18236 *bufp = param_tlvs->bufp;
18237
18238 return QDF_STATUS_SUCCESS;
18239}
18240
18241/**
18242 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18243 * @wmi_handle: wmi handle
18244 * @param evt_buf: pointer to event buffer
18245 * @param vdev_id: Pointer to hold vdev identifier
18246 *
18247 * Return: QDF_STATUS_SUCCESS for success or error code
18248 */
18249static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18250 void *evt_buf, uint32_t *vdev_id)
18251{
18252 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18253 wmi_vdev_stopped_event_fixed_param *resp_event;
18254
18255 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18256 if (!param_buf) {
18257 WMI_LOGE("Invalid event buffer");
18258 return QDF_STATUS_E_INVAL;
18259 }
18260 resp_event = param_buf->fixed_param;
18261 *vdev_id = resp_event->vdev_id;
18262
18263 return QDF_STATUS_SUCCESS;
18264}
18265
18266/**
18267 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18268 * @wmi_handle: wmi handle
18269 * @param evt_buf: pointer to event buffer
18270 * @param param: Pointer to hold roam param
18271 *
18272 * Return: QDF_STATUS_SUCCESS for success or error code
18273 */
18274static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18275 void *evt_buf, wmi_host_roam_event *param)
18276{
18277 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18278 wmi_roam_event_fixed_param *evt;
18279
18280 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18281 if (!param_buf) {
18282 WMI_LOGE("Invalid roam event buffer");
18283 return QDF_STATUS_E_INVAL;
18284 }
18285
18286 evt = param_buf->fixed_param;
18287 qdf_mem_zero(param, sizeof(*param));
18288
18289 param->vdev_id = evt->vdev_id;
18290 param->reason = evt->reason;
18291 param->rssi = evt->rssi;
18292
18293 return QDF_STATUS_SUCCESS;
18294}
18295
18296/**
18297 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18298 * @wmi_handle: wmi handle
18299 * @param evt_buf: pointer to event buffer
18300 * @param param: Pointer to hold vdev scan param
18301 *
18302 * Return: QDF_STATUS_SUCCESS for success or error code
18303 */
18304static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018305 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018306{
18307 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18308 wmi_scan_event_fixed_param *evt = NULL;
18309
18310 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18311 evt = param_buf->fixed_param;
18312
18313 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018314
Govind Singhe7f2f342016-05-23 12:12:52 +053018315 switch (evt->event) {
18316 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018317 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018318 break;
18319 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018320 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018321 break;
18322 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018323 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018324 break;
18325 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018326 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018327 break;
18328 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018329 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018330 break;
18331 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018332 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018333 break;
18334 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018335 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018336 break;
18337 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018338 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018339 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018340 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018341 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018342 break;
18343 case WMI_SCAN_EVENT_MAX:
18344 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018345 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018346 break;
18347 };
18348
18349 switch (evt->reason) {
18350 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018351 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018352 break;
18353 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018354 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018355 break;
18356 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018357 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018358 break;
18359 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018360 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018361 break;
18362 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018363 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018364 break;
18365 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018366 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018367 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018368 case WMI_SCAN_REASON_SUSPENDED:
18369 param->reason = SCAN_REASON_SUSPENDED;
18370 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018371 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018372 param->reason = SCAN_REASON_MAX;
18373 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018374 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018375 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018376 break;
18377 };
18378
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018379 param->chan_freq = evt->channel_freq;
18380 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018381 param->scan_id = evt->scan_id;
18382 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018383 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018384
18385 return QDF_STATUS_SUCCESS;
18386}
18387
Frank Liu3d5e9992017-03-15 17:51:43 +080018388#ifdef CONVERGED_TDLS_ENABLE
18389/**
18390 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18391 * @wmi_handle: wmi handle
18392 * @param evt_buf: pointer to event buffer
18393 * @param param: Pointer to hold vdev tdls param
18394 *
18395 * Return: QDF_STATUS_SUCCESS for success or error code
18396 */
18397static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18398 void *evt_buf, struct tdls_event_info *param)
18399{
18400 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18401 wmi_tdls_peer_event_fixed_param *evt;
18402
18403 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18404 if (!param_buf) {
18405 WMI_LOGE("%s: NULL param_buf", __func__);
18406 return QDF_STATUS_E_NULL_VALUE;
18407 }
18408
18409 evt = param_buf->fixed_param;
18410
18411 qdf_mem_zero(param, sizeof(*param));
18412
18413 param->vdev_id = evt->vdev_id;
18414 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18415 param->peermac.bytes);
18416 switch (evt->peer_status) {
18417 case WMI_TDLS_SHOULD_DISCOVER:
18418 param->message_type = TDLS_SHOULD_DISCOVER;
18419 break;
18420 case WMI_TDLS_SHOULD_TEARDOWN:
18421 param->message_type = TDLS_SHOULD_TEARDOWN;
18422 break;
18423 case WMI_TDLS_PEER_DISCONNECTED:
18424 param->message_type = TDLS_PEER_DISCONNECTED;
18425 break;
18426 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18427 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18428 break;
18429 default:
18430 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18431 __func__, evt->peer_status);
18432 return QDF_STATUS_E_INVAL;
18433 };
18434
18435 switch (evt->peer_reason) {
18436 case WMI_TDLS_TEARDOWN_REASON_TX:
18437 param->peer_reason = TDLS_TEARDOWN_TX;
18438 break;
18439 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18440 param->peer_reason = TDLS_TEARDOWN_RSSI;
18441 break;
18442 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18443 param->peer_reason = TDLS_TEARDOWN_SCAN;
18444 break;
18445 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18446 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18447 break;
18448 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18449 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18450 break;
18451 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18452 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18453 break;
18454 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18455 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18456 break;
18457 case WMI_TDLS_ENTER_BUF_STA:
18458 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18459 break;
18460 case WMI_TDLS_EXIT_BUF_STA:
18461 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18462 break;
18463 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18464 param->peer_reason = TDLS_ENTER_BT_BUSY;
18465 break;
18466 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18467 param->peer_reason = TDLS_EXIT_BT_BUSY;
18468 break;
18469 case WMI_TDLS_SCAN_STARTED_EVENT:
18470 param->peer_reason = TDLS_SCAN_STARTED;
18471 break;
18472 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18473 param->peer_reason = TDLS_SCAN_COMPLETED;
18474 break;
18475
18476 default:
18477 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18478 __func__, evt->peer_reason, evt->peer_status);
18479 return QDF_STATUS_E_INVAL;
18480 };
18481
18482 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18483 __func__, param->peermac.bytes, param->message_type,
18484 param->peer_reason, param->vdev_id);
18485
18486 return QDF_STATUS_SUCCESS;
18487}
18488#endif
18489
Govind Singhe7f2f342016-05-23 12:12:52 +053018490/**
18491 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18492 * @wmi_handle: wmi handle
18493 * @param evt_buf: pointer to event buffer
18494 * @param param: Pointer to hold MGMT TX completion params
18495 *
18496 * Return: QDF_STATUS_SUCCESS for success or error code
18497 */
18498static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18499 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18500{
18501 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18502 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18503
18504 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18505 evt_buf;
18506 if (!param_buf) {
18507 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18508 return QDF_STATUS_E_INVAL;
18509 }
18510 cmpl_params = param_buf->fixed_param;
18511
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018512 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18513 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018514 param->desc_id = cmpl_params->desc_id;
18515 param->status = cmpl_params->status;
18516
18517 return QDF_STATUS_SUCCESS;
18518}
18519
18520/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018521 * extract_offchan_data_tx_compl_param_tlv() -
18522 * extract Offchan data tx completion event params
18523 * @wmi_handle: wmi handle
18524 * @param evt_buf: pointer to event buffer
18525 * @param param: Pointer to hold offchan data TX completion params
18526 *
18527 * Return: QDF_STATUS_SUCCESS for success or error code
18528 */
18529static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18530 wmi_unified_t wmi_handle, void *evt_buf,
18531 struct wmi_host_offchan_data_tx_compl_event *param)
18532{
18533 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18534 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18535
18536 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18537 evt_buf;
18538 if (!param_buf) {
18539 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18540 return QDF_STATUS_E_INVAL;
18541 }
18542 cmpl_params = param_buf->fixed_param;
18543
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018544 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18545 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018546 param->desc_id = cmpl_params->desc_id;
18547 param->status = cmpl_params->status;
18548
18549 return QDF_STATUS_SUCCESS;
18550}
18551
18552/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018553 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18554 * status tlv
18555 * @wmi_handle: wmi handle
18556 * @param evt_buf: pointer to event buffer
18557 * @param param: Pointer to hold csa switch count status event param
18558 *
18559 * Return: QDF_STATUS_SUCCESS for success or error code
18560 */
18561static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18562 wmi_unified_t wmi_handle,
18563 void *evt_buf,
18564 struct pdev_csa_switch_count_status *param)
18565{
18566 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18567 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18568
18569 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18570 evt_buf;
18571 if (!param_buf) {
18572 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18573 return QDF_STATUS_E_INVAL;
18574 }
18575
18576 csa_status = param_buf->fixed_param;
18577
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018578 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18579 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018580 param->current_switch_count = csa_status->current_switch_count;
18581 param->num_vdevs = csa_status->num_vdevs;
18582 param->vdev_ids = param_buf->vdev_ids;
18583
18584 return QDF_STATUS_SUCCESS;
18585}
18586
18587/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018588 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018589 * @wmi_handle: wmi handle
18590 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018591 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018592 *
18593 * Return: QDF_STATUS_SUCCESS for success or error code
18594 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018595static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18596 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018597{
18598 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18599 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018600 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018601
18602 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18603 if (!param_buf) {
18604 WMI_LOGE("Invalid swba event buffer");
18605 return QDF_STATUS_E_INVAL;
18606 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018607
Govind Singhe7f2f342016-05-23 12:12:52 +053018608 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018609 *num_vdevs = swba_event->num_vdevs;
18610 if (!(*num_vdevs)) {
18611 vdev_map = swba_event->vdev_map;
18612 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18613 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018614
18615 return QDF_STATUS_SUCCESS;
18616}
18617
18618/**
18619 * extract_swba_tim_info_tlv() - extract swba tim info from event
18620 * @wmi_handle: wmi handle
18621 * @param evt_buf: pointer to event buffer
18622 * @param idx: Index to bcn info
18623 * @param tim_info: Pointer to hold tim info
18624 *
18625 * Return: QDF_STATUS_SUCCESS for success or error code
18626 */
18627static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18628 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18629{
18630 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18631 wmi_tim_info *tim_info_ev;
18632
18633 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18634 if (!param_buf) {
18635 WMI_LOGE("Invalid swba event buffer");
18636 return QDF_STATUS_E_INVAL;
18637 }
18638
18639 tim_info_ev = &param_buf->tim_info[idx];
18640
18641 tim_info->tim_len = tim_info_ev->tim_len;
18642 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18643 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18644 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18645 tim_info->tim_changed = tim_info_ev->tim_changed;
18646 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018647 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018648
18649 return QDF_STATUS_SUCCESS;
18650}
18651
18652/**
18653 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18654 * @wmi_handle: wmi handle
18655 * @param evt_buf: pointer to event buffer
18656 * @param idx: Index to bcn info
18657 * @param p2p_desc: Pointer to hold p2p NoA info
18658 *
18659 * Return: QDF_STATUS_SUCCESS for success or error code
18660 */
18661static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18662 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18663{
18664 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18665 wmi_p2p_noa_info *p2p_noa_info;
18666 uint8_t i = 0;
18667
18668 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18669 if (!param_buf) {
18670 WMI_LOGE("Invalid swba event buffer");
18671 return QDF_STATUS_E_INVAL;
18672 }
18673
18674 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18675
18676 p2p_desc->modified = false;
18677 p2p_desc->num_descriptors = 0;
18678 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18679 p2p_desc->modified = true;
18680 p2p_desc->index =
18681 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18682 p2p_desc->oppPS =
18683 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18684 p2p_desc->ctwindow =
18685 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18686 p2p_desc->num_descriptors =
18687 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18688 (p2p_noa_info);
18689 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18690 p2p_desc->noa_descriptors[i].type_count =
18691 (uint8_t) p2p_noa_info->noa_descriptors[i].
18692 type_count;
18693 p2p_desc->noa_descriptors[i].duration =
18694 p2p_noa_info->noa_descriptors[i].duration;
18695 p2p_desc->noa_descriptors[i].interval =
18696 p2p_noa_info->noa_descriptors[i].interval;
18697 p2p_desc->noa_descriptors[i].start_time =
18698 p2p_noa_info->noa_descriptors[i].start_time;
18699 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018700 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018701 }
18702
18703 return QDF_STATUS_SUCCESS;
18704}
18705
Wu Gaocd3a8512017-03-13 20:17:34 +080018706#ifdef CONVERGED_P2P_ENABLE
18707/**
18708 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18709 * @wmi_handle: wmi handle
18710 * @param evt_buf: pointer to event buffer
18711 * @param param: Pointer to hold p2p noa info
18712 *
18713 * Return: QDF_STATUS_SUCCESS for success or error code
18714 */
18715static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18716 wmi_unified_t wmi_handle, void *evt_buf,
18717 struct p2p_noa_info *param)
18718{
18719 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18720 wmi_p2p_noa_event_fixed_param *fixed_param;
18721 uint8_t i;
18722 wmi_p2p_noa_info *wmi_noa_info;
18723 uint8_t *buf_ptr;
18724 uint32_t descriptors;
18725
18726 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18727 if (!param_tlvs) {
18728 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18729 return QDF_STATUS_E_INVAL;
18730 }
18731
18732 if (!param) {
18733 WMI_LOGE("noa information param is null");
18734 return QDF_STATUS_E_INVAL;
18735 }
18736
18737 fixed_param = param_tlvs->fixed_param;
18738 buf_ptr = (uint8_t *) fixed_param;
18739 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18740 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18741
18742 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18743 WMI_LOGE("%s: noa attr is not modified", __func__);
18744 return QDF_STATUS_E_INVAL;
18745 }
18746
18747 param->vdev_id = fixed_param->vdev_id;
18748 param->index =
18749 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18750 param->opps_ps =
18751 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18752 param->ct_window =
18753 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18754 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18755 param->num_desc = (uint8_t) descriptors;
18756
18757 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18758 param->index, param->opps_ps, param->ct_window,
18759 param->num_desc);
18760 for (i = 0; i < param->num_desc; i++) {
18761 param->noa_desc[i].type_count =
18762 (uint8_t) wmi_noa_info->noa_descriptors[i].
18763 type_count;
18764 param->noa_desc[i].duration =
18765 wmi_noa_info->noa_descriptors[i].duration;
18766 param->noa_desc[i].interval =
18767 wmi_noa_info->noa_descriptors[i].interval;
18768 param->noa_desc[i].start_time =
18769 wmi_noa_info->noa_descriptors[i].start_time;
18770 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18771 __func__, i, param->noa_desc[i].type_count,
18772 param->noa_desc[i].duration,
18773 param->noa_desc[i].interval,
18774 param->noa_desc[i].start_time);
18775 }
18776
18777 return QDF_STATUS_SUCCESS;
18778}
18779
18780/**
18781 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18782 * information from event
18783 * @wmi_handle: wmi handle
18784 * @param evt_buf: pointer to event buffer
18785 * @param param: Pointer to hold p2p lo stop event information
18786 *
18787 * Return: QDF_STATUS_SUCCESS for success or error code
18788 */
18789static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18790 wmi_unified_t wmi_handle, void *evt_buf,
18791 struct p2p_lo_event *param)
18792{
18793 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18794 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18795
18796 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18797 evt_buf;
18798 if (!param_tlvs) {
18799 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18800 return QDF_STATUS_E_INVAL;
18801 }
18802
18803 if (!param) {
18804 WMI_LOGE("lo stop event param is null");
18805 return QDF_STATUS_E_INVAL;
18806 }
18807
18808 lo_param = param_tlvs->fixed_param;
18809 param->vdev_id = lo_param->vdev_id;
18810 param->reason_code = lo_param->reason;
18811 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18812 param->vdev_id, param->reason_code);
18813
18814 return QDF_STATUS_SUCCESS;
18815}
18816#endif /* End of CONVERGED_P2P_ENABLE */
18817
Govind Singhe7f2f342016-05-23 12:12:52 +053018818/**
18819 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18820 * @wmi_handle: wmi handle
18821 * @param evt_buf: pointer to event buffer
18822 * @param ev: Pointer to hold peer param
18823 *
18824 * Return: QDF_STATUS_SUCCESS for success or error code
18825 */
18826static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18827 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18828{
18829 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18830 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18831
18832 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18833 kickout_event = param_buf->fixed_param;
18834
18835 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18836 ev->peer_macaddr);
18837
18838 ev->reason = kickout_event->reason;
18839 ev->rssi = kickout_event->rssi;
18840
18841 return QDF_STATUS_SUCCESS;
18842}
18843
18844/**
18845 * extract_all_stats_counts_tlv() - extract all stats count from event
18846 * @wmi_handle: wmi handle
18847 * @param evt_buf: pointer to event buffer
18848 * @param stats_param: Pointer to hold stats count
18849 *
18850 * Return: QDF_STATUS_SUCCESS for success or error code
18851 */
18852static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18853 void *evt_buf, wmi_host_stats_event *stats_param)
18854{
18855 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18856 wmi_stats_event_fixed_param *ev;
18857
18858 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18859
18860 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18861 if (!ev) {
18862 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
18863 return QDF_STATUS_E_FAILURE;
18864 }
18865
18866 switch (ev->stats_id) {
18867 case WMI_REQUEST_PEER_STAT:
18868 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18869 break;
18870
18871 case WMI_REQUEST_AP_STAT:
18872 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18873 break;
18874
18875 case WMI_REQUEST_PDEV_STAT:
18876 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18877 break;
18878
18879 case WMI_REQUEST_VDEV_STAT:
18880 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18881 break;
18882
18883 case WMI_REQUEST_BCNFLT_STAT:
18884 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18885 break;
18886
18887 case WMI_REQUEST_VDEV_RATE_STAT:
18888 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18889 break;
18890
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018891 case WMI_REQUEST_BCN_STAT:
18892 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18893 break;
18894
Govind Singhe7f2f342016-05-23 12:12:52 +053018895 default:
18896 stats_param->stats_id = 0;
18897 break;
18898
18899 }
18900
18901 stats_param->num_pdev_stats = ev->num_pdev_stats;
18902 stats_param->num_pdev_ext_stats = 0;
18903 stats_param->num_vdev_stats = ev->num_vdev_stats;
18904 stats_param->num_peer_stats = ev->num_peer_stats;
18905 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18906 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018907 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018908 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18909 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018910
18911 return QDF_STATUS_SUCCESS;
18912}
18913
18914/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018915 * extract_pdev_tx_stats() - extract pdev tx stats from event
18916 */
18917static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18918{
18919 /* Tx Stats */
18920 tx->comp_queued = tx_stats->comp_queued;
18921 tx->comp_delivered = tx_stats->comp_delivered;
18922 tx->msdu_enqued = tx_stats->msdu_enqued;
18923 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18924 tx->wmm_drop = tx_stats->wmm_drop;
18925 tx->local_enqued = tx_stats->local_enqued;
18926 tx->local_freed = tx_stats->local_freed;
18927 tx->hw_queued = tx_stats->hw_queued;
18928 tx->hw_reaped = tx_stats->hw_reaped;
18929 tx->underrun = tx_stats->underrun;
18930 tx->tx_abort = tx_stats->tx_abort;
18931 tx->mpdus_requed = tx_stats->mpdus_requed;
18932 tx->data_rc = tx_stats->data_rc;
18933 tx->self_triggers = tx_stats->self_triggers;
18934 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18935 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18936 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18937 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18938 tx->pdev_resets = tx_stats->pdev_resets;
18939 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18940 tx->phy_underrun = tx_stats->phy_underrun;
18941 tx->txop_ovf = tx_stats->txop_ovf;
18942
18943 return;
18944}
18945
18946
18947/**
18948 * extract_pdev_rx_stats() - extract pdev rx stats from event
18949 */
18950static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18951{
18952 /* Rx Stats */
18953 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18954 rx->status_rcvd = rx_stats->status_rcvd;
18955 rx->r0_frags = rx_stats->r0_frags;
18956 rx->r1_frags = rx_stats->r1_frags;
18957 rx->r2_frags = rx_stats->r2_frags;
18958 /* Only TLV */
18959 rx->r3_frags = 0;
18960 rx->htt_msdus = rx_stats->htt_msdus;
18961 rx->htt_mpdus = rx_stats->htt_mpdus;
18962 rx->loc_msdus = rx_stats->loc_msdus;
18963 rx->loc_mpdus = rx_stats->loc_mpdus;
18964 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18965 rx->phy_errs = rx_stats->phy_errs;
18966 rx->phy_err_drop = rx_stats->phy_err_drop;
18967 rx->mpdu_errs = rx_stats->mpdu_errs;
18968
18969 return;
18970}
18971
18972/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018973 * extract_pdev_stats_tlv() - extract pdev stats from event
18974 * @wmi_handle: wmi handle
18975 * @param evt_buf: pointer to event buffer
18976 * @param index: Index into pdev stats
18977 * @param pdev_stats: Pointer to hold pdev stats
18978 *
18979 * Return: QDF_STATUS_SUCCESS for success or error code
18980 */
18981static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18982 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18983{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018984 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18985 wmi_stats_event_fixed_param *ev_param;
18986 uint8_t *data;
18987
18988 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18989 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18990
18991 data = param_buf->data;
18992
18993 if (index < ev_param->num_pdev_stats) {
18994 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18995 (index * sizeof(wmi_pdev_stats)));
18996
18997 pdev_stats->chan_nf = ev->chan_nf;
18998 pdev_stats->tx_frame_count = ev->tx_frame_count;
18999 pdev_stats->rx_frame_count = ev->rx_frame_count;
19000 pdev_stats->rx_clear_count = ev->rx_clear_count;
19001 pdev_stats->cycle_count = ev->cycle_count;
19002 pdev_stats->phy_err_count = ev->phy_err_count;
19003 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19004
19005 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19006 &(ev->pdev_stats.tx));
19007 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19008 &(ev->pdev_stats.rx));
19009 }
19010
Govind Singhe7f2f342016-05-23 12:12:52 +053019011 return QDF_STATUS_SUCCESS;
19012}
19013
19014/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019015 * extract_unit_test_tlv() - extract unit test data
19016 * @wmi_handle: wmi handle
19017 * @param evt_buf: pointer to event buffer
19018 * @param unit_test: pointer to hold unit test data
19019 * @param maxspace: Amount of space in evt_buf
19020 *
19021 * Return: QDF_STATUS_SUCCESS for success or error code
19022 */
19023static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19024 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19025{
19026 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19027 wmi_unit_test_event_fixed_param *ev_param;
19028 uint32_t num_bufp;
19029 uint32_t copy_size;
19030 uint8_t *bufp;
19031
19032 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19033 ev_param = param_buf->fixed_param;
19034 bufp = param_buf->bufp;
19035 num_bufp = param_buf->num_bufp;
19036 unit_test->vdev_id = ev_param->vdev_id;
19037 unit_test->module_id = ev_param->module_id;
19038 unit_test->diag_token = ev_param->diag_token;
19039 unit_test->flag = ev_param->flag;
19040 unit_test->payload_len = ev_param->payload_len;
19041 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19042 ev_param->vdev_id,
19043 ev_param->module_id,
19044 ev_param->diag_token,
19045 ev_param->flag);
19046 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19047 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19048 bufp, num_bufp);
19049 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19050 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19051 unit_test->buffer_len = copy_size;
19052
19053 return QDF_STATUS_SUCCESS;
19054}
19055
19056/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019057 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19058 * @wmi_handle: wmi handle
19059 * @param evt_buf: pointer to event buffer
19060 * @param index: Index into extended pdev stats
19061 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19062 *
19063 * Return: QDF_STATUS_SUCCESS for success or error code
19064 */
19065static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19066 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19067{
19068 return QDF_STATUS_SUCCESS;
19069}
19070
19071/**
19072 * extract_vdev_stats_tlv() - extract vdev stats from event
19073 * @wmi_handle: wmi handle
19074 * @param evt_buf: pointer to event buffer
19075 * @param index: Index into vdev stats
19076 * @param vdev_stats: Pointer to hold vdev stats
19077 *
19078 * Return: QDF_STATUS_SUCCESS for success or error code
19079 */
19080static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19081 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19082{
19083 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19084 wmi_stats_event_fixed_param *ev_param;
19085 uint8_t *data;
19086
19087 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19088 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19089 data = (uint8_t *) param_buf->data;
19090
19091 if (index < ev_param->num_vdev_stats) {
19092 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19093 ((ev_param->num_pdev_stats) *
19094 sizeof(wmi_pdev_stats)) +
19095 (index * sizeof(wmi_vdev_stats)));
19096
19097 vdev_stats->vdev_id = ev->vdev_id;
19098 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19099 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19100
19101 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19102 sizeof(ev->tx_frm_cnt));
19103 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19104 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19105 ev->multiple_retry_cnt,
19106 sizeof(ev->multiple_retry_cnt));
19107 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19108 sizeof(ev->fail_cnt));
19109 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19110 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19111 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19112 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19113 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19114 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19115 sizeof(ev->tx_rate_history));
19116 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19117 sizeof(ev->bcn_rssi_history));
19118
19119 }
19120
19121 return QDF_STATUS_SUCCESS;
19122}
19123
19124/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019125 * extract_bcn_stats_tlv() - extract bcn stats from event
19126 * @wmi_handle: wmi handle
19127 * @param evt_buf: pointer to event buffer
19128 * @param index: Index into vdev stats
19129 * @param bcn_stats: Pointer to hold bcn stats
19130 *
19131 * Return: QDF_STATUS_SUCCESS for success or error code
19132 */
19133static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19134 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19135{
19136 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19137 wmi_stats_event_fixed_param *ev_param;
19138 uint8_t *data;
19139
19140 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19141 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19142 data = (uint8_t *) param_buf->data;
19143
19144 if (index < ev_param->num_bcn_stats) {
19145 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19146 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19147 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19148 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19149 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19150 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19151 (index * sizeof(wmi_bcn_stats)));
19152
19153 bcn_stats->vdev_id = ev->vdev_id;
19154 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19155 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19156 }
19157
19158 return QDF_STATUS_SUCCESS;
19159}
19160
19161/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019162 * extract_peer_stats_tlv() - extract peer stats from event
19163 * @wmi_handle: wmi handle
19164 * @param evt_buf: pointer to event buffer
19165 * @param index: Index into peer stats
19166 * @param peer_stats: Pointer to hold peer stats
19167 *
19168 * Return: QDF_STATUS_SUCCESS for success or error code
19169 */
19170static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19171 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19172{
19173 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19174 wmi_stats_event_fixed_param *ev_param;
19175 uint8_t *data;
19176
19177 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19178 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19179 data = (uint8_t *) param_buf->data;
19180
19181 if (index < ev_param->num_peer_stats) {
19182 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19183 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19184 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19185 (index * sizeof(wmi_peer_stats)));
19186
19187 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19188
19189 OS_MEMCPY(&(peer_stats->peer_macaddr),
19190 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19191
19192 peer_stats->peer_rssi = ev->peer_rssi;
19193 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19194 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19195 }
19196
19197 return QDF_STATUS_SUCCESS;
19198}
19199
19200/**
19201 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19202 * @wmi_handle: wmi handle
19203 * @param evt_buf: pointer to event buffer
19204 * @param index: Index into bcn fault stats
19205 * @param bcnflt_stats: Pointer to hold bcn fault stats
19206 *
19207 * Return: QDF_STATUS_SUCCESS for success or error code
19208 */
19209static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19210 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19211{
19212 return QDF_STATUS_SUCCESS;
19213}
19214
19215/**
19216 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19217 * @wmi_handle: wmi handle
19218 * @param evt_buf: pointer to event buffer
19219 * @param index: Index into extended peer stats
19220 * @param peer_extd_stats: Pointer to hold extended peer stats
19221 *
19222 * Return: QDF_STATUS_SUCCESS for success or error code
19223 */
19224static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19225 void *evt_buf, uint32_t index,
19226 wmi_host_peer_extd_stats *peer_extd_stats)
19227{
19228 return QDF_STATUS_SUCCESS;
19229}
19230
19231/**
19232 * extract_chan_stats_tlv() - extract chan stats from event
19233 * @wmi_handle: wmi handle
19234 * @param evt_buf: pointer to event buffer
19235 * @param index: Index into chan stats
19236 * @param vdev_extd_stats: Pointer to hold chan stats
19237 *
19238 * Return: QDF_STATUS_SUCCESS for success or error code
19239 */
19240static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19241 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19242{
19243 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19244 wmi_stats_event_fixed_param *ev_param;
19245 uint8_t *data;
19246
19247 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19248 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19249 data = (uint8_t *) param_buf->data;
19250
19251 if (index < ev_param->num_chan_stats) {
19252 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19253 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19254 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19255 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19256 (index * sizeof(wmi_chan_stats)));
19257
19258
19259 /* Non-TLV doesnt have num_chan_stats */
19260 chan_stats->chan_mhz = ev->chan_mhz;
19261 chan_stats->sampling_period_us = ev->sampling_period_us;
19262 chan_stats->rx_clear_count = ev->rx_clear_count;
19263 chan_stats->tx_duration_us = ev->tx_duration_us;
19264 chan_stats->rx_duration_us = ev->rx_duration_us;
19265 }
19266
19267 return QDF_STATUS_SUCCESS;
19268}
19269
19270/**
19271 * extract_profile_ctx_tlv() - extract profile context from event
19272 * @wmi_handle: wmi handle
19273 * @param evt_buf: pointer to event buffer
19274 * @idx: profile stats index to extract
19275 * @param profile_ctx: Pointer to hold profile context
19276 *
19277 * Return: QDF_STATUS_SUCCESS for success or error code
19278 */
19279static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19280 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19281{
19282 return QDF_STATUS_SUCCESS;
19283}
19284
19285/**
19286 * extract_profile_data_tlv() - extract profile data from event
19287 * @wmi_handle: wmi handle
19288 * @param evt_buf: pointer to event buffer
19289 * @param profile_data: Pointer to hold profile data
19290 *
19291 * Return: QDF_STATUS_SUCCESS for success or error code
19292 */
19293static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19294 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19295{
19296
19297 return QDF_STATUS_SUCCESS;
19298}
19299
19300/**
19301 * extract_chan_info_event_tlv() - extract chan information from event
19302 * @wmi_handle: wmi handle
19303 * @param evt_buf: pointer to event buffer
19304 * @param chan_info: Pointer to hold chan information
19305 *
19306 * Return: QDF_STATUS_SUCCESS for success or error code
19307 */
19308static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19309 void *evt_buf, wmi_host_chan_info_event *chan_info)
19310{
19311 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19312 wmi_chan_info_event_fixed_param *ev;
19313
19314 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19315
19316 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19317 if (!ev) {
19318 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19319 return QDF_STATUS_E_FAILURE;
19320 }
19321
19322 chan_info->err_code = ev->err_code;
19323 chan_info->freq = ev->freq;
19324 chan_info->cmd_flags = ev->cmd_flags;
19325 chan_info->noise_floor = ev->noise_floor;
19326 chan_info->rx_clear_count = ev->rx_clear_count;
19327 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019328 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19329 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019330 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19331 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19332 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019333 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19334 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19335 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19336 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19337 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19338 chan_info->rx_frame_count = ev->rx_frame_count;
19339 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19340 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019341
19342 return QDF_STATUS_SUCCESS;
19343}
19344
19345/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019346 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19347 * @wmi_handle: WMI handle
19348 * @param evt_buf: Pointer to event buffer
19349 * @param param: Pointer to hold data
19350 *
19351 * Return : QDF_STATUS_SUCCESS for success or error code
19352 */
19353static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19354 uint8_t *evt_buf,
19355 struct wmi_host_pdev_utf_event *event)
19356{
19357 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019358 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019359
19360 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19361 event->data = param_buf->data;
19362 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019363 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019364 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019365 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019366 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019367
19368 return QDF_STATUS_SUCCESS;
19369}
Govind Singhe7f2f342016-05-23 12:12:52 +053019370
Kiran Venkatappa06520822016-08-10 23:55:40 +053019371/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019372 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19373 * @wmi_handle: wmi handle
19374 * @param evt_buf: pointer to event buffer
19375 * @param param: Pointer to hold evt buf
19376 *
19377 * Return: QDF_STATUS_SUCCESS for success or error code
19378 */
19379static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19380 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19381{
19382 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19383 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19384 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19385 uint8_t i = 0, j = 0;
19386
19387 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19388 if (!param_buf)
19389 return QDF_STATUS_E_INVAL;
19390
19391 hw_caps = param_buf->soc_hw_mode_caps;
19392 if (!hw_caps)
19393 return QDF_STATUS_E_INVAL;
19394
19395 if (!hw_caps->num_chainmask_tables)
19396 return QDF_STATUS_E_INVAL;
19397
19398 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19399
19400 if (chainmask_caps == NULL)
19401 return QDF_STATUS_E_INVAL;
19402
19403 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19404
19405 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19406 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19407
19408 chainmask_table[i].cap_list[j].chainmask =
19409 chainmask_caps->chainmask;
19410
19411 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19412 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19413
19414 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19415 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19416
19417 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19418 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19419
19420 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19421 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19422
19423 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19424 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19425
19426 chainmask_table[i].cap_list[j].chain_mask_2G =
19427 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19428
19429 chainmask_table[i].cap_list[j].chain_mask_5G =
19430 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19431
19432 chainmask_table[i].cap_list[j].chain_mask_tx =
19433 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19434
19435 chainmask_table[i].cap_list[j].chain_mask_rx =
19436 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19437
19438 chainmask_table[i].cap_list[j].supports_aDFS =
19439 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19440
19441 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19442 chainmask_caps->supported_flags,
19443 chainmask_caps->chainmask
19444 );
19445 chainmask_caps++;
19446 }
19447 }
19448
19449 return QDF_STATUS_SUCCESS;
19450}
19451
19452/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019453 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19454 * from event
19455 * @wmi_handle: wmi handle
19456 * @param evt_buf: pointer to event buffer
19457 * @param param: Pointer to hold evt buf
19458 *
19459 * Return: QDF_STATUS_SUCCESS for success or error code
19460 */
19461static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019462 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019463{
19464 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19465 wmi_service_ready_ext_event_fixed_param *ev;
19466 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19467 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019468 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19469 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019470
19471 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19472 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019473 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019474
19475 ev = param_buf->fixed_param;
19476 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019477 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019478
19479 /* Move this to host based bitmap */
19480 param->default_conc_scan_config_bits =
19481 ev->default_conc_scan_config_bits;
19482 param->default_fw_config_bits = ev->default_fw_config_bits;
19483 param->he_cap_info = ev->he_cap_info;
19484 param->mpdu_density = ev->mpdu_density;
19485 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019486 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019487 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019488 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19489
19490 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019491 if (hw_caps)
19492 param->num_hw_modes = hw_caps->num_hw_modes;
19493 else
19494 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019495
19496 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019497 if (reg_caps)
19498 param->num_phy = reg_caps->num_phy;
19499 else
19500 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019501
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019502 if (hw_caps) {
19503 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19504 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19505 } else
19506 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019507
19508 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19509
19510 if (chain_mask_combo == NULL)
19511 return QDF_STATUS_SUCCESS;
19512
19513 qdf_print("Dumping chain mask combo data\n");
19514
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019515 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019516
19517 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19518 chain_mask_combo->chainmask_table_id,
19519 chain_mask_combo->num_valid_chainmask
19520 );
19521
19522 param->chainmask_table[i].table_id =
19523 chain_mask_combo->chainmask_table_id;
19524 param->chainmask_table[i].num_valid_chainmasks =
19525 chain_mask_combo->num_valid_chainmask;
19526 chain_mask_combo++;
19527 }
19528 qdf_print("chain mask combo end\n");
19529
Kiran Venkatappa06520822016-08-10 23:55:40 +053019530 return QDF_STATUS_SUCCESS;
19531}
19532
19533/**
19534 * extract_hw_mode_cap_service_ready_ext_tlv() -
19535 * extract HW mode cap from service ready event
19536 * @wmi_handle: wmi handle
19537 * @param evt_buf: pointer to event buffer
19538 * @param param: Pointer to hold evt buf
19539 * @param hw_mode_idx: hw mode idx should be less than num_mode
19540 *
19541 * Return: QDF_STATUS_SUCCESS for success or error code
19542 */
19543static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19544 wmi_unified_t wmi_handle,
19545 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019546 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019547{
19548 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19549 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19550
19551 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19552 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019553 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019554
19555 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019556 if (!hw_caps)
19557 return QDF_STATUS_E_INVAL;
19558
Kiran Venkatappa06520822016-08-10 23:55:40 +053019559 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019560 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019561
19562 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19563 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19564
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019565 param->hw_mode_config_type =
19566 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19567
Kiran Venkatappa06520822016-08-10 23:55:40 +053019568 return QDF_STATUS_SUCCESS;
19569}
19570
19571/**
19572 * extract_mac_phy_cap_service_ready_ext_tlv() -
19573 * extract MAC phy cap from service ready event
19574 * @wmi_handle: wmi handle
19575 * @param evt_buf: pointer to event buffer
19576 * @param param: Pointer to hold evt buf
19577 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019578 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019579 *
19580 * Return: QDF_STATUS_SUCCESS for success or error code
19581 */
19582static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19583 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019584 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019585 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019586{
19587 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019588 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019589 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19590 uint32_t phy_map;
19591 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019592
19593 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19594 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019595 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019596
19597 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019598 if (!hw_caps)
19599 return QDF_STATUS_E_INVAL;
19600
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019601 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19602 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19603 break;
19604
19605 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19606 while (phy_map) {
19607 phy_map >>= 1;
19608 phy_idx++;
19609 }
19610 }
19611
19612 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019613 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019614
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019615 phy_idx += phy_id;
19616 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019617 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019618
19619 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019620
19621 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019622 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19623 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019624 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019625 param->supports_11b =
19626 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19627 param->supports_11g =
19628 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19629 param->supports_11a =
19630 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19631 param->supports_11n =
19632 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19633 param->supports_11ac =
19634 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19635 param->supports_11ax =
19636 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019637
19638 param->supported_bands = mac_phy_caps->supported_bands;
19639 param->ampdu_density = mac_phy_caps->ampdu_density;
19640 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19641 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19642 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19643 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19644 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19645 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19646 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19647 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19648 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19649 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19650 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19651 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19652 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19653 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19654 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19655 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019656 qdf_mem_copy(&param->he_cap_phy_info_2G,
19657 &mac_phy_caps->he_cap_phy_info_2G,
19658 sizeof(param->he_cap_phy_info_2G));
19659 qdf_mem_copy(&param->he_cap_phy_info_5G,
19660 &mac_phy_caps->he_cap_phy_info_5G,
19661 sizeof(param->he_cap_phy_info_5G));
19662 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19663 sizeof(param->he_ppet2G));
19664 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19665 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019666 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019667
19668 return QDF_STATUS_SUCCESS;
19669}
19670
19671/**
19672 * extract_reg_cap_service_ready_ext_tlv() -
19673 * extract REG cap from service ready event
19674 * @wmi_handle: wmi handle
19675 * @param evt_buf: pointer to event buffer
19676 * @param param: Pointer to hold evt buf
19677 * @param phy_idx: phy idx should be less than num_mode
19678 *
19679 * Return: QDF_STATUS_SUCCESS for success or error code
19680 */
19681static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19682 wmi_unified_t wmi_handle,
19683 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019684 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019685{
19686 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19687 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19688 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19689
19690 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19691 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019692 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019693
19694 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019695 if (!reg_caps)
19696 return QDF_STATUS_E_INVAL;
19697
Kiran Venkatappa06520822016-08-10 23:55:40 +053019698 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019699 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019700
19701 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19702
19703 param->phy_id = ext_reg_cap->phy_id;
19704 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19705 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19706 param->regcap1 = ext_reg_cap->regcap1;
19707 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019708 param->wireless_modes = convert_wireless_modes_tlv(
19709 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019710 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19711 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19712 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19713 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19714
19715 return QDF_STATUS_SUCCESS;
19716}
19717
Sathish Kumarf396c722017-11-17 17:30:41 +053019718static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19719 wmi_unified_t wmi_handle,
19720 uint8_t *event, uint8_t idx,
19721 struct wlan_psoc_host_dbr_ring_caps *param)
19722{
19723 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19724 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19725
19726 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19727 if (!param_buf)
19728 return QDF_STATUS_E_INVAL;
19729
19730 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19731
19732 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19733 dbr_ring_caps->pdev_id);
19734 param->mod_id = dbr_ring_caps->mod_id;
19735 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19736 param->min_buf_size = dbr_ring_caps->min_buf_size;
19737 param->min_buf_align = dbr_ring_caps->min_buf_align;
19738
19739 return QDF_STATUS_SUCCESS;
19740}
19741
19742static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19743 uint8_t *event, struct direct_buf_rx_rsp *param)
19744{
19745 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19746 wmi_dma_buf_release_fixed_param *ev;
19747
19748 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19749 if (!param_buf)
19750 return QDF_STATUS_E_INVAL;
19751
19752 ev = param_buf->fixed_param;
19753 if (!ev)
19754 return QDF_STATUS_E_INVAL;
19755
19756 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19757 ev->pdev_id);
19758 param->mod_id = ev->mod_id;
19759 param->num_buf_release_entry = ev->num_buf_release_entry;
19760 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19761 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19762
19763 return QDF_STATUS_SUCCESS;
19764}
19765
19766static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19767 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19768{
19769 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19770 wmi_dma_buf_release_entry *entry;
19771
19772 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19773 if (!param_buf)
19774 return QDF_STATUS_E_INVAL;
19775
19776 entry = &param_buf->entries[idx];
19777
19778 if (!entry) {
19779 WMI_LOGE("%s: Entry is NULL\n", __func__);
19780 return QDF_STATUS_E_FAILURE;
19781 }
19782
19783 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19784
19785 param->paddr_lo = entry->paddr_lo;
19786 param->paddr_hi = entry->paddr_hi;
19787
19788 return QDF_STATUS_SUCCESS;
19789}
19790
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019791/**
19792 * extract_dcs_interference_type_tlv() - extract dcs interference type
19793 * from event
19794 * @wmi_handle: wmi handle
19795 * @param evt_buf: pointer to event buffer
19796 * @param param: Pointer to hold dcs interference param
19797 *
19798 * Return: 0 for success or error code
19799 */
19800static QDF_STATUS extract_dcs_interference_type_tlv(
19801 wmi_unified_t wmi_handle,
19802 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19803{
19804 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19805
19806 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19807 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019808 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019809
19810 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019811 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19812 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019813
19814 return QDF_STATUS_SUCCESS;
19815}
19816
19817/*
19818 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19819 * @wmi_handle: wmi handle
19820 * @param evt_buf: pointer to event buffer
19821 * @param cw_int: Pointer to hold cw interference
19822 *
19823 * Return: 0 for success or error code
19824 */
19825static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19826 void *evt_buf,
19827 wmi_host_ath_dcs_cw_int *cw_int)
19828{
19829 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19830 wlan_dcs_cw_int *ev;
19831
19832 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19833 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019834 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019835
19836 ev = param_buf->cw_int;
19837
19838 cw_int->channel = ev->channel;
19839
19840 return QDF_STATUS_SUCCESS;
19841}
19842
19843/**
19844 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19845 * @wmi_handle: wmi handle
19846 * @param evt_buf: pointer to event buffer
19847 * @param wlan_stat: Pointer to hold wlan stats
19848 *
19849 * Return: 0 for success or error code
19850 */
19851static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19852 void *evt_buf,
19853 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19854{
19855 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19856 wlan_dcs_im_tgt_stats_t *ev;
19857
19858 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19859 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019860 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019861
19862 ev = param_buf->wlan_stat;
19863 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19864 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19865 wlan_stat->tx_waste_time = ev->tx_waste_time;
19866 wlan_stat->rx_time = ev->rx_time;
19867 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19868 wlan_stat->mib_stats.listen_time = ev->listen_time;
19869 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19870 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19871 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19872 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19873 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19874 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19875 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19876 wlan_stat->chan_nf = ev->chan_nf;
19877 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19878
19879 return QDF_STATUS_SUCCESS;
19880}
19881
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019882/**
19883 * extract_thermal_stats_tlv() - extract thermal stats from event
19884 * @wmi_handle: wmi handle
19885 * @param evt_buf: Pointer to event buffer
19886 * @param temp: Pointer to hold extracted temperature
19887 * @param level: Pointer to hold extracted level
19888 *
19889 * Return: 0 for success or error code
19890 */
19891static QDF_STATUS
19892extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19893 void *evt_buf, uint32_t *temp,
19894 uint32_t *level, uint32_t *pdev_id)
19895{
19896 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19897 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19898
19899 param_buf =
19900 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19901 if (!param_buf)
19902 return QDF_STATUS_E_INVAL;
19903
19904 tt_stats_event = param_buf->fixed_param;
19905
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019906 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19907 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019908 *temp = tt_stats_event->temp;
19909 *level = tt_stats_event->level;
19910
19911 return QDF_STATUS_SUCCESS;
19912}
19913
19914/**
19915 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19916 * @wmi_handle: wmi handle
19917 * @param evt_buf: pointer to event buffer
19918 * @param idx: Index to level stats
19919 * @param levelcount: Pointer to hold levelcount
19920 * @param dccount: Pointer to hold dccount
19921 *
19922 * Return: 0 for success or error code
19923 */
19924static QDF_STATUS
19925extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19926 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19927 uint32_t *dccount)
19928{
19929 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19930 wmi_therm_throt_level_stats_info *tt_level_info;
19931
19932 param_buf =
19933 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19934 if (!param_buf)
19935 return QDF_STATUS_E_INVAL;
19936
19937 tt_level_info = param_buf->therm_throt_level_stats_info;
19938
19939 if (idx < THERMAL_LEVELS) {
19940 *levelcount = tt_level_info[idx].level_count;
19941 *dccount = tt_level_info[idx].dc_count;
19942 return QDF_STATUS_SUCCESS;
19943 }
19944
19945 return QDF_STATUS_E_FAILURE;
19946}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019947#ifdef BIG_ENDIAN_HOST
19948/**
19949 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19950 * @param data_len - data length
19951 * @param data - pointer to data
19952 *
19953 * Return: QDF_STATUS - success or error status
19954 */
19955static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19956{
19957 uint8_t *data_aligned = NULL;
19958 int c;
19959 unsigned char *data_unaligned;
19960
19961 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19962 FIPS_ALIGN));
19963 /* Assigning unaligned space to copy the data */
19964 /* Checking if kmalloc does succesful allocation */
19965 if (data_unaligned == NULL)
19966 return QDF_STATUS_E_FAILURE;
19967
19968 /* Checking if space is alligned */
19969 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19970 /* align the data space */
19971 data_aligned =
19972 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19973 } else {
19974 data_aligned = (u_int8_t *)data_unaligned;
19975 }
19976
19977 /* memset and copy content from data to data aligned */
19978 OS_MEMSET(data_aligned, 0, data_len);
19979 OS_MEMCPY(data_aligned, data, data_len);
19980 /* Endianness to LE */
19981 for (c = 0; c < data_len/4; c++) {
19982 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019983 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019984 }
19985
19986 /* Copy content to event->data */
19987 OS_MEMCPY(data, data_aligned, data_len);
19988
19989 /* clean up allocated space */
19990 qdf_mem_free(data_unaligned);
19991 data_aligned = NULL;
19992 data_unaligned = NULL;
19993
19994 /*************************************************************/
19995
19996 return QDF_STATUS_SUCCESS;
19997}
19998#else
19999/**
20000 * fips_conv_data_be() - DUMMY for LE platform
20001 *
20002 * Return: QDF_STATUS - success
20003 */
20004static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20005{
20006 return QDF_STATUS_SUCCESS;
20007}
20008#endif
20009
20010/**
20011 * extract_fips_event_data_tlv() - extract fips event data
20012 * @wmi_handle: wmi handle
20013 * @param evt_buf: pointer to event buffer
20014 * @param param: pointer FIPS event params
20015 *
20016 * Return: 0 for success or error code
20017 */
20018static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20019 void *evt_buf, struct wmi_host_fips_event_param *param)
20020{
20021 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20022 wmi_pdev_fips_event_fixed_param *event;
20023
20024 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20025 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20026
20027 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20028 QDF_STATUS_SUCCESS)
20029 return QDF_STATUS_E_FAILURE;
20030
20031 param->data = (uint32_t *)param_buf->data;
20032 param->data_len = event->data_len;
20033 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020034 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20035 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020036
20037 return QDF_STATUS_SUCCESS;
20038}
20039
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020040/*
20041 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20042 * @wmi_handle: wmi handle
20043 * @param evt_buf: pointer to event buffer
20044 * @param vdev_id: Pointer to hold vdev_id
20045 * @param mac_addr: Pointer to hold peer mac address
20046 *
20047 * Return: QDF_STATUS_SUCCESS for success or error code
20048 */
20049static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20050 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20051{
20052 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20053 wmi_peer_delete_resp_event_fixed_param *ev;
20054
20055 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20056
20057 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20058 if (!ev) {
20059 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20060 return QDF_STATUS_E_FAILURE;
20061 }
20062
20063 param->vdev_id = ev->vdev_id;
20064 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20065 &param->mac_address.bytes[0]);
20066
20067 return QDF_STATUS_SUCCESS;
20068}
20069
Govind Singhecf03cd2016-05-12 12:45:51 +053020070static bool is_management_record_tlv(uint32_t cmd_id)
20071{
jiad36c94d22018-01-22 15:37:03 +080020072 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20073 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20074 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020075 return true;
jiad36c94d22018-01-22 15:37:03 +080020076 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020077
Govind Singhecf03cd2016-05-12 12:45:51 +053020078 return false;
20079}
20080
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020081static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20082{
20083 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20084
20085 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20086
20087 switch (set_cmd->param_id) {
20088 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20089 case WMI_VDEV_PARAM_DTIM_POLICY:
20090 return HTC_TX_PACKET_TAG_AUTO_PM;
20091 default:
20092 break;
20093 }
20094
20095 return 0;
20096}
20097
20098static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20099{
20100 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20101
20102 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20103
20104 switch (ps_cmd->param) {
20105 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20106 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20107 case WMI_STA_PS_ENABLE_QPOWER:
20108 return HTC_TX_PACKET_TAG_AUTO_PM;
20109 default:
20110 break;
20111 }
20112
20113 return 0;
20114}
20115
20116static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20117 uint32_t cmd_id)
20118{
20119 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20120 return 0;
20121
20122 switch (cmd_id) {
20123 case WMI_VDEV_SET_PARAM_CMDID:
20124 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20125 case WMI_STA_POWERSAVE_PARAM_CMDID:
20126 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20127 default:
20128 break;
20129 }
20130
20131 return 0;
20132}
20133
20134static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20135{
20136 uint16_t tag = 0;
20137
20138 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20139 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20140 __func__);
20141 return tag;
20142 }
20143
20144 if (wmi_handle->tag_crash_inject)
20145 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20146
20147 wmi_handle->tag_crash_inject = false;
20148 return tag;
20149}
20150
20151/**
20152 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20153 * @wmi_handle: WMI handle
20154 * @buf: WMI buffer
20155 * @cmd_id: WMI command Id
20156 *
20157 * Return htc_tx_tag
20158 */
20159static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20160 wmi_buf_t buf,
20161 uint32_t cmd_id)
20162{
20163 uint16_t htc_tx_tag = 0;
20164
20165 switch (cmd_id) {
20166 case WMI_WOW_ENABLE_CMDID:
20167 case WMI_PDEV_SUSPEND_CMDID:
20168 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20169 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20170 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20171 case WMI_PDEV_RESUME_CMDID:
20172 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20173 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20174#ifdef FEATURE_WLAN_D0WOW
20175 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20176#endif
20177 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20178 break;
20179 case WMI_FORCE_FW_HANG_CMDID:
20180 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20181 break;
20182 case WMI_VDEV_SET_PARAM_CMDID:
20183 case WMI_STA_POWERSAVE_PARAM_CMDID:
20184 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20185 default:
20186 break;
20187 }
20188
20189 return htc_tx_tag;
20190}
20191
Sathish Kumard3ab1002017-02-07 17:10:59 +053020192/**
20193 * extract_channel_hopping_event_tlv() - extract channel hopping param
20194 * from event
20195 * @wmi_handle: wmi handle
20196 * @param evt_buf: pointer to event buffer
20197 * @param ch_hopping: Pointer to hold channel hopping param
20198 *
20199 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20200 */
20201static QDF_STATUS extract_channel_hopping_event_tlv(
20202 wmi_unified_t wmi_handle, void *evt_buf,
20203 wmi_host_pdev_channel_hopping_event *ch_hopping)
20204{
20205 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20206 wmi_pdev_channel_hopping_event_fixed_param *event;
20207
20208 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20209 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20210 param_buf->fixed_param;
20211
20212 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20213 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020214 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20215 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020216
20217 return QDF_STATUS_SUCCESS;
20218}
20219
20220/**
20221 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20222 * @wmi_handle: wmi handle
20223 * @param evt_buf: pointer to event buffer
20224 * @param param: Pointer to hold tpc param
20225 *
20226 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20227 */
20228static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20229 void *evt_buf,
20230 wmi_host_pdev_tpc_event *param)
20231{
20232 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20233 wmi_pdev_tpc_event_fixed_param *event;
20234
20235 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20236 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20237
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020238 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20239 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020240 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20241
20242 return QDF_STATUS_SUCCESS;
20243}
20244
20245
20246#ifdef BIG_ENDIAN_HOST
20247/**
20248 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20249 * @param data_len - data length
20250 * @param data - pointer to data
20251 *
20252 * Return: QDF_STATUS - success or error status
20253 */
20254static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20255{
20256 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020257 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020258 /* Skip swapping the first word */
20259 datap += sizeof(uint32_t);
20260 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20261 i++, datap += sizeof(uint32_t)) {
20262 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20263 }
20264
20265 return QDF_STATUS_SUCCESS;
20266}
20267#else
20268/**
20269 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20270 * @param data_len - data length
20271 * @param data - pointer to data
20272 *
20273 * Return: QDF_STATUS - success or error status
20274 */
20275static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20276{
20277 return QDF_STATUS_SUCCESS;
20278}
20279#endif
20280
20281/**
20282 * extract_wds_addr_event_tlv() - extract wds address from event
20283 * @wmi_handle: wmi handle
20284 * @param evt_buf: pointer to event buffer
20285 * @param wds_ev: Pointer to hold wds address
20286 *
20287 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20288 */
20289static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20290 void *evt_buf,
20291 uint16_t len, wds_addr_event_t *wds_ev)
20292{
20293 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20294 wmi_wds_addr_event_fixed_param *ev;
20295 int i;
20296
20297 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20298 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20299
20300 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20301 return QDF_STATUS_E_FAILURE;
20302
20303 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20304 sizeof(wds_ev->event_type));
20305 for (i = 0; i < 4; i++) {
20306 wds_ev->peer_mac[i] =
20307 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20308 wds_ev->dest_mac[i] =
20309 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20310 }
20311 for (i = 0; i < 2; i++) {
20312 wds_ev->peer_mac[4+i] =
20313 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20314 wds_ev->dest_mac[4+i] =
20315 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20316 }
20317 return QDF_STATUS_SUCCESS;
20318}
20319
20320/**
20321 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20322 * from event
20323 * @wmi_handle: wmi handle
20324 * @param evt_buf: pointer to event buffer
20325 * @param ev: Pointer to hold peer param and ps state
20326 *
20327 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20328 */
20329static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20330 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20331{
20332 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20333 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20334
20335 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20336 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20337 param_buf->fixed_param;
20338
20339 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20340 ev->peer_ps_state = event->peer_ps_state;
20341
20342 return QDF_STATUS_SUCCESS;
20343}
20344
20345/**
20346 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20347 * @wmi_handle: wmi handle
20348 * @param evt_buf: pointer to event buffer
20349 * @param inst_rssi_resp: Pointer to hold inst rssi response
20350 *
20351 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20352 */
20353static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20354 wmi_unified_t wmi_handle, void *evt_buf,
20355 wmi_host_inst_stats_resp *inst_rssi_resp)
20356{
20357 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20358 wmi_inst_rssi_stats_resp_fixed_param *event;
20359
20360 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20361 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20362
20363 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20364 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20365 inst_rssi_resp->iRSSI = event->iRSSI;
20366
20367 return QDF_STATUS_SUCCESS;
20368}
20369
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020370static struct cur_reg_rule
20371*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20372 wmi_regulatory_rule_struct *wmi_reg_rule)
20373{
20374 struct cur_reg_rule *reg_rule_ptr;
20375 uint32_t count;
20376
20377 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20378
20379 if (NULL == reg_rule_ptr) {
20380 WMI_LOGE("memory allocation failure");
20381 return NULL;
20382 }
20383
20384 for (count = 0; count < num_reg_rules; count++) {
20385 reg_rule_ptr[count].start_freq =
20386 WMI_REG_RULE_START_FREQ_GET(
20387 wmi_reg_rule[count].freq_info);
20388 reg_rule_ptr[count].end_freq =
20389 WMI_REG_RULE_END_FREQ_GET(
20390 wmi_reg_rule[count].freq_info);
20391 reg_rule_ptr[count].max_bw =
20392 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020393 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020394 reg_rule_ptr[count].reg_power =
20395 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020396 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020397 reg_rule_ptr[count].ant_gain =
20398 WMI_REG_RULE_ANTENNA_GAIN_GET(
20399 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020400 reg_rule_ptr[count].flags =
20401 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020402 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020403 }
20404
20405 return reg_rule_ptr;
20406}
20407
20408static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20409 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20410 struct cur_regulatory_info *reg_info, uint32_t len)
20411{
20412 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20413 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20414 wmi_regulatory_rule_struct *wmi_reg_rule;
20415 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20416
20417 WMI_LOGD("processing regulatory channel list");
20418
20419 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20420 if (!param_buf) {
20421 WMI_LOGE("invalid channel list event buf");
20422 return QDF_STATUS_E_FAILURE;
20423 }
20424
20425 chan_list_event_hdr = param_buf->fixed_param;
20426
20427 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20428 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20429 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020430 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020431 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20432 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020433 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020434 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020435 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020436 reg_info->ctry_code = chan_list_event_hdr->country_id;
20437 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20438 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20439 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20440 else if (chan_list_event_hdr->status_code ==
20441 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20442 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20443 else if (chan_list_event_hdr->status_code ==
20444 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20445 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20446 else if (chan_list_event_hdr->status_code ==
20447 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20448 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20449 else if (chan_list_event_hdr->status_code ==
20450 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20451 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20452 else if (chan_list_event_hdr->status_code ==
20453 WMI_REG_SET_CC_STATUS_FAIL)
20454 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20455
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020456 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20457 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20458 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20459 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20460
20461 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20462 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20463
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020464 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20465 __func__, reg_info->alpha2, reg_info->dfs_region,
20466 reg_info->min_bw_2g, reg_info->max_bw_2g,
20467 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020468
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020469 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20470 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020471 wmi_reg_rule =
20472 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20473 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20474 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020475 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20476 wmi_reg_rule);
20477 wmi_reg_rule += num_2g_reg_rules;
20478
20479 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20480 wmi_reg_rule);
20481
20482 WMI_LOGD("processed regulatory channel list");
20483
20484 return QDF_STATUS_SUCCESS;
20485}
20486
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020487static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20488 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20489 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20490{
20491 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20492 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20493
20494 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20495 if (!param_buf) {
20496 WMI_LOGE("invalid 11d country event buf");
20497 return QDF_STATUS_E_FAILURE;
20498 }
20499
20500 reg_11d_country_event = param_buf->fixed_param;
20501
20502 qdf_mem_copy(reg_11d_country->alpha2,
20503 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20504
20505 WMI_LOGD("processed 11d country event, new cc %s",
20506 reg_11d_country->alpha2);
20507
20508 return QDF_STATUS_SUCCESS;
20509}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020510
20511static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20512 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20513 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20514{
20515 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20516 wmi_avoid_freq_range_desc *afr_desc;
20517 uint32_t num_freq_ranges, freq_range_idx;
20518 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20519 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20520
20521 if (!param_buf) {
20522 WMI_LOGE("Invalid channel avoid event buffer");
20523 return QDF_STATUS_E_INVAL;
20524 }
20525
20526 afr_fixed_param = param_buf->fixed_param;
20527 if (!afr_fixed_param) {
20528 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20529 return QDF_STATUS_E_INVAL;
20530 }
20531
20532 if (!ch_avoid_ind) {
20533 WMI_LOGE("Invalid channel avoid indication buffer");
20534 return QDF_STATUS_E_INVAL;
20535 }
20536 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20537 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20538 afr_fixed_param->num_freq_ranges;
20539
20540 WMI_LOGD("Channel avoid event received with %d ranges",
20541 num_freq_ranges);
20542
20543 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20544 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20545 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20546 freq_range_idx++) {
20547 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20548 afr_desc->start_freq;
20549 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20550 afr_desc->end_freq;
20551 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20552 freq_range_idx, afr_desc->tlv_header,
20553 afr_desc->start_freq, afr_desc->end_freq);
20554 afr_desc++;
20555 }
20556
20557 return QDF_STATUS_SUCCESS;
20558}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020559#ifdef DFS_COMPONENT_ENABLE
20560/**
20561 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20562 * @wmi_handle: wma handle
20563 * @evt_buf: event buffer
20564 * @vdev_id: vdev id
20565 * @len: length of buffer
20566 *
20567 * Return: 0 for success or error code
20568 */
20569static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20570 uint8_t *evt_buf,
20571 uint32_t *vdev_id,
20572 uint32_t len)
20573{
20574 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20575 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20576
20577 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20578 if (!param_tlvs) {
20579 WMI_LOGE("invalid cac complete event buf");
20580 return QDF_STATUS_E_FAILURE;
20581 }
20582
20583 cac_event = param_tlvs->fixed_param;
20584 *vdev_id = cac_event->vdev_id;
20585 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20586
20587 return QDF_STATUS_SUCCESS;
20588}
20589
20590/**
20591 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20592 * @wmi_handle: wma handle
20593 * @evt_buf: event buffer
20594 * @radar_found: radar found event info
20595 * @len: length of buffer
20596 *
20597 * Return: 0 for success or error code
20598 */
20599static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20600 wmi_unified_t wmi_handle,
20601 uint8_t *evt_buf,
20602 struct radar_found_info *radar_found,
20603 uint32_t len)
20604{
20605 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20606 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20607
20608 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20609 if (!param_tlv) {
20610 WMI_LOGE("invalid radar detection event buf");
20611 return QDF_STATUS_E_FAILURE;
20612 }
20613
20614 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020615 radar_found->pdev_id = wmi_handle->ops->
20616 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020617 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020618 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020619 radar_found->chan_width = radar_event->chan_width;
20620 radar_found->detector_id = radar_event->detector_id;
20621 radar_found->segment_id = radar_event->segment_id;
20622 radar_found->timestamp = radar_event->timestamp;
20623 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020624 radar_found->freq_offset = radar_event->freq_offset;
20625 radar_found->sidx = radar_event->sidx;
20626
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020627 WMI_LOGI("processed radar found event pdev %d,"
20628 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20629 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20630 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20631 "is_chirp %d,detection mode %d\n",
20632 radar_event->pdev_id, radar_event->pdev_id,
20633 radar_event->timestamp, radar_event->chan_freq,
20634 radar_event->chan_width, radar_event->detector_id,
20635 radar_event->freq_offset, radar_event->segment_id,
20636 radar_event->sidx, radar_event->is_chirp,
20637 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020638
20639 return QDF_STATUS_SUCCESS;
20640}
20641#endif
20642
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020643/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020644 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20645 * @wmi_handle: wmi handle
20646 * @get_rcpi_param: rcpi params
20647 *
20648 * Return: QDF status
20649 */
20650static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20651 struct rcpi_req *get_rcpi_param)
20652{
20653 wmi_buf_t buf;
20654 wmi_request_rcpi_cmd_fixed_param *cmd;
20655 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20656
20657 buf = wmi_buf_alloc(wmi_handle, len);
20658 if (!buf) {
20659 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20660 return QDF_STATUS_E_NOMEM;
20661 }
20662
20663 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20664 WMITLV_SET_HDR(&cmd->tlv_header,
20665 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20666 WMITLV_GET_STRUCT_TLVLEN
20667 (wmi_request_rcpi_cmd_fixed_param));
20668
20669 cmd->vdev_id = get_rcpi_param->vdev_id;
20670 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20671 &cmd->peer_macaddr);
20672 cmd->measurement_type = get_rcpi_param->measurement_type;
20673 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20674 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20675 WMI_REQUEST_RCPI_CMDID)) {
20676
20677 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20678 __func__);
20679 wmi_buf_free(buf);
20680 return QDF_STATUS_E_FAILURE;
20681 }
20682
20683 return QDF_STATUS_SUCCESS;
20684}
20685
20686/**
20687 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20688 * @wmi_handle: wmi handle
20689 * @evt_buf: pointer to event buffer
20690 * @res: pointer to hold rcpi response from firmware
20691 *
20692 * Return: QDF_STATUS_SUCCESS for successful event parse
20693 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20694 */
20695static QDF_STATUS
20696extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20697 void *evt_buf, struct rcpi_res *res)
20698{
20699 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20700 wmi_update_rcpi_event_fixed_param *event;
20701
20702 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20703 if (!param_buf) {
20704 WMI_LOGE(FL("Invalid rcpi event"));
20705 return QDF_STATUS_E_INVAL;
20706 }
20707
20708 event = param_buf->fixed_param;
20709 res->vdev_id = event->vdev_id;
20710 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20711
20712 switch (event->measurement_type) {
20713
20714 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20715 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20716 break;
20717
20718 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20719 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20720 break;
20721
20722 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20723 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20724 break;
20725
20726 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20727 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20728 break;
20729
20730 default:
20731 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20732 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20733 return QDF_STATUS_E_FAILURE;
20734 }
20735
20736 if (event->status)
20737 return QDF_STATUS_E_FAILURE;
20738 else
20739 return QDF_STATUS_SUCCESS;
20740}
20741
20742/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020743 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20744 * host to target defines. For legacy there is not conversion
20745 * required. Just return pdev_id as it is.
20746 * @param pdev_id: host pdev_id to be converted.
20747 * Return: target pdev_id after conversion.
20748 */
20749static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20750 uint32_t pdev_id)
20751{
20752 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20753 return WMI_PDEV_ID_SOC;
20754
20755 /*No conversion required*/
20756 return pdev_id;
20757}
20758
20759/**
20760 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20761 * target to host defines. For legacy there is not conversion
20762 * required. Just return pdev_id as it is.
20763 * @param pdev_id: target pdev_id to be converted.
20764 * Return: host pdev_id after conversion.
20765 */
20766static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20767 uint32_t pdev_id)
20768{
20769 /*No conversion required*/
20770 return pdev_id;
20771}
20772
20773/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020774 * send_set_country_cmd_tlv() - WMI scan channel list function
20775 * @param wmi_handle : handle to WMI.
20776 * @param param : pointer to hold scan channel list parameter
20777 *
20778 * Return: 0 on success and -ve on failure.
20779 */
20780static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20781 struct set_country *params)
20782{
20783 wmi_buf_t buf;
20784 QDF_STATUS qdf_status;
20785 wmi_set_current_country_cmd_fixed_param *cmd;
20786 uint16_t len = sizeof(*cmd);
20787
20788 buf = wmi_buf_alloc(wmi_handle, len);
20789 if (!buf) {
20790 WMI_LOGE("Failed to allocate memory");
20791 qdf_status = QDF_STATUS_E_NOMEM;
20792 goto end;
20793 }
20794
20795 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20796 WMITLV_SET_HDR(&cmd->tlv_header,
20797 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20798 WMITLV_GET_STRUCT_TLVLEN
20799 (wmi_set_current_country_cmd_fixed_param));
20800
20801 WMI_LOGD("setting cuurnet country to %s", params->country);
20802
20803 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20804
20805 cmd->pdev_id = params->pdev_id;
20806
20807 qdf_status = wmi_unified_cmd_send(wmi_handle,
20808 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20809
20810 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20811 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20812 wmi_buf_free(buf);
20813 }
20814
20815end:
20816 return qdf_status;
20817}
20818
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020819#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20820 WMI_SET_BITS(alpha, 0, 8, val0); \
20821 WMI_SET_BITS(alpha, 8, 8, val1); \
20822 WMI_SET_BITS(alpha, 16, 8, val2); \
20823 } while (0)
20824
20825static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20826 uint8_t pdev_id, struct cc_regdmn_s *rd)
20827{
20828 wmi_set_init_country_cmd_fixed_param *cmd;
20829 uint16_t len;
20830 wmi_buf_t buf;
20831 int ret;
20832
20833 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20834 buf = wmi_buf_alloc(wmi_handle, len);
20835 if (!buf) {
20836 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20837 return QDF_STATUS_E_NOMEM;
20838 }
20839 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20840 WMITLV_SET_HDR(&cmd->tlv_header,
20841 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20842 WMITLV_GET_STRUCT_TLVLEN
20843 (wmi_set_init_country_cmd_fixed_param));
20844
20845 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20846
20847 if (rd->flags == CC_IS_SET) {
20848 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20849 cmd->country_code.country_id = rd->cc.country_code;
20850 } else if (rd->flags == ALPHA_IS_SET) {
20851 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20852 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20853 rd->cc.alpha[0],
20854 rd->cc.alpha[1],
20855 rd->cc.alpha[2]);
20856 } else if (rd->flags == REGDMN_IS_SET) {
20857 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20858 cmd->country_code.domain_code = rd->cc.regdmn_id;
20859 }
20860
20861 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20862 WMI_SET_INIT_COUNTRY_CMDID);
20863 if (ret) {
20864 WMI_LOGE("Failed to config wow wakeup event");
20865 wmi_buf_free(buf);
20866 return QDF_STATUS_E_FAILURE;
20867 }
20868
20869 return QDF_STATUS_SUCCESS;
20870}
20871
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020872/**
20873 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20874 * configuration params
20875 * @wmi_handle: wmi handler
20876 * @limit_off_chan_param: pointer to wmi_off_chan_param
20877 *
20878 * Return: 0 for success and non zero for failure
20879 */
20880static
20881QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20882 struct wmi_limit_off_chan_param *limit_off_chan_param)
20883{
20884 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20885 wmi_buf_t buf;
20886 uint32_t len = sizeof(*cmd);
20887 int err;
20888
20889 buf = wmi_buf_alloc(wmi_handle, len);
20890 if (!buf) {
20891 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20892 __func__);
20893 return QDF_STATUS_E_NOMEM;
20894 }
20895
20896 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20897
20898 WMITLV_SET_HDR(&cmd->tlv_header,
20899 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20900 WMITLV_GET_STRUCT_TLVLEN(
20901 wmi_vdev_limit_offchan_cmd_fixed_param));
20902
20903 cmd->vdev_id = limit_off_chan_param->vdev_id;
20904
20905 cmd->flags &= 0;
20906 if (limit_off_chan_param->status)
20907 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20908 if (limit_off_chan_param->skip_dfs_chans)
20909 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20910
20911 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20912 cmd->rest_time = limit_off_chan_param->rest_time;
20913
20914 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20915 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20916 cmd->rest_time);
20917
20918 err = wmi_unified_cmd_send(wmi_handle, buf,
20919 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20920 if (QDF_IS_STATUS_ERROR(err)) {
20921 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20922 wmi_buf_free(buf);
20923 return QDF_STATUS_E_FAILURE;
20924 }
20925
20926 return QDF_STATUS_SUCCESS;
20927}
20928
Anurag Chouhan97f00422017-09-11 14:56:30 +053020929/**
20930 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20931 * @wmi_handle: wmi handler
20932 * @req_buf: set arp stats request buffer
20933 *
20934 * Return: 0 for success and non zero for failure
20935 */
20936static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20937 struct set_arp_stats *req_buf)
20938{
20939 wmi_buf_t buf = NULL;
20940 QDF_STATUS status;
20941 int len;
20942 uint8_t *buf_ptr;
20943 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20944
20945 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20946 buf = wmi_buf_alloc(wmi_handle, len);
20947 if (!buf) {
20948 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20949 return QDF_STATUS_E_NOMEM;
20950 }
20951
20952 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20953 wmi_set_arp =
20954 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20955 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20956 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20957 WMITLV_GET_STRUCT_TLVLEN
20958 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20959
20960 /* fill in per roam config values */
20961 wmi_set_arp->vdev_id = req_buf->vdev_id;
20962
20963 wmi_set_arp->set_clr = req_buf->flag;
20964 wmi_set_arp->pkt_type = req_buf->pkt_type;
20965 wmi_set_arp->ipv4 = req_buf->ip_addr;
20966
20967 /* Send per roam config parameters */
20968 status = wmi_unified_cmd_send(wmi_handle, buf,
20969 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20970 if (QDF_IS_STATUS_ERROR(status)) {
20971 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
20972 status);
20973 goto error;
20974 }
20975
20976 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
20977 req_buf->flag, req_buf->vdev_id);
20978 return QDF_STATUS_SUCCESS;
20979error:
20980 wmi_buf_free(buf);
20981
20982 return status;
20983}
20984
20985/**
20986 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
20987 * @wmi_handle: wmi handler
20988 * @req_buf: get arp stats request buffer
20989 *
20990 * Return: 0 for success and non zero for failure
20991 */
20992static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20993 struct get_arp_stats *req_buf)
20994{
20995 wmi_buf_t buf = NULL;
20996 QDF_STATUS status;
20997 int len;
20998 uint8_t *buf_ptr;
20999 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21000
21001 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21002 buf = wmi_buf_alloc(wmi_handle, len);
21003 if (!buf) {
21004 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21005 return QDF_STATUS_E_NOMEM;
21006 }
21007
21008 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21009 get_arp_stats =
21010 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21011 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21012 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21013 WMITLV_GET_STRUCT_TLVLEN
21014 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21015
21016 /* fill in arp stats req cmd values */
21017 get_arp_stats->vdev_id = req_buf->vdev_id;
21018
21019 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21020 /* Send per roam config parameters */
21021 status = wmi_unified_cmd_send(wmi_handle, buf,
21022 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21023 if (QDF_IS_STATUS_ERROR(status)) {
21024 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21025 status);
21026 goto error;
21027 }
21028
21029 return QDF_STATUS_SUCCESS;
21030error:
21031 wmi_buf_free(buf);
21032
21033 return status;
21034}
21035
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021036/**
21037 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21038 * @wmi_handle: wmi handler
21039 * @pmk_info: pointer to PMK cache entry
21040 * @vdev_id: vdev id
21041 *
21042 * Return: 0 for success and non zero for failure
21043 */
21044static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21045 struct wmi_unified_pmk_cache *pmk_info)
21046{
21047 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21048 wmi_buf_t buf;
21049 QDF_STATUS status;
21050 uint8_t *buf_ptr;
21051 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021052 uint32_t len = sizeof(*cmd);
21053
21054 if (pmk_info->pmk_len)
21055 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021056
21057 buf = wmi_buf_alloc(wmi_handle, len);
21058 if (!buf) {
21059 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21060 __func__);
21061 return QDF_STATUS_E_NOMEM;
21062 }
21063
21064 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21065 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21066
21067 WMITLV_SET_HDR(&cmd->tlv_header,
21068 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21069 WMITLV_GET_STRUCT_TLVLEN(
21070 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21071
21072 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021073
21074 /* If pmk_info->pmk_len is 0, this is a flush request */
21075 if (!pmk_info->pmk_len) {
21076 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21077 cmd->num_cache = 0;
21078 goto send_cmd;
21079 }
21080
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021081 cmd->num_cache = 1;
21082 buf_ptr += sizeof(*cmd);
21083
21084 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21085 sizeof(*pmksa));
21086 buf_ptr += WMI_TLV_HDR_SIZE;
21087
21088 pmksa = (wmi_pmk_cache *)buf_ptr;
21089 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21090 WMITLV_GET_STRUCT_TLVLEN
21091 (wmi_pmk_cache));
21092 pmksa->pmk_len = pmk_info->pmk_len;
21093 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21094 pmksa->pmkid_len = pmk_info->pmkid_len;
21095 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21096 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21097 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21098 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21099 pmksa->ssid.ssid_len);
21100 pmksa->cache_id = pmk_info->cache_id;
21101 pmksa->cat_flag = pmk_info->cat_flag;
21102 pmksa->action_flag = pmk_info->action_flag;
21103
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021104send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021105 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21106 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21107 if (status != QDF_STATUS_SUCCESS) {
21108 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21109 __func__, status);
21110 wmi_buf_free(buf);
21111 }
21112
21113 return status;
21114}
21115
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021116/**
21117 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21118 * @wmi_handle: wmi handle
21119 * @param: reserved param
21120 *
21121 * Return: 0 for success or error code
21122 */
21123static QDF_STATUS
21124send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21125 uint32_t param)
21126{
21127 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21128 wmi_buf_t buf;
21129 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21130
21131 buf = wmi_buf_alloc(wmi_handle, len);
21132 if (!buf) {
21133 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21134 return QDF_STATUS_E_FAILURE;
21135 }
21136 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21137 WMITLV_SET_HDR(&cmd->tlv_header,
21138 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21139 WMITLV_GET_STRUCT_TLVLEN
21140 (wmi_pdev_check_cal_version_cmd_fixed_param));
21141 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21142 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21143 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21144 wmi_buf_free(buf);
21145 return QDF_STATUS_E_FAILURE;
21146 }
21147
21148 return QDF_STATUS_SUCCESS;
21149}
21150
21151/**
21152 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21153 * @wmi_handle: wmi handle
21154 * @param evt_buf: pointer to event buffer
21155 * @param param: Pointer to hold peer caldata version data
21156 *
21157 * Return: 0 for success or error code
21158 */
21159static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21160 wmi_unified_t wmi_handle,
21161 void *evt_buf,
21162 wmi_host_pdev_check_cal_version_event *param)
21163{
21164 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21165 wmi_pdev_check_cal_version_event_fixed_param *event;
21166
21167 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21168 if (!param_tlvs) {
21169 WMI_LOGE("invalid cal version event buf");
21170 return QDF_STATUS_E_FAILURE;
21171 }
21172 event = param_tlvs->fixed_param;
21173 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21174 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21175 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21176 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21177
21178 param->software_cal_version = event->software_cal_version;
21179 param->board_cal_version = event->board_cal_version;
21180 param->cal_ok = event->cal_status;
21181
21182 return QDF_STATUS_SUCCESS;
21183}
21184
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021185/*
21186 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21187 * @wmi_handle: wmi handle
21188 * @params: pointer to wmi_btm_config
21189 *
21190 * Return: QDF_STATUS
21191 */
21192static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21193 struct wmi_btm_config *params)
21194{
21195
21196 wmi_btm_config_fixed_param *cmd;
21197 wmi_buf_t buf;
21198 uint32_t len;
21199
21200 len = sizeof(*cmd);
21201 buf = wmi_buf_alloc(wmi_handle, len);
21202 if (!buf) {
21203 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21204 return QDF_STATUS_E_NOMEM;
21205 }
21206
21207 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21208 WMITLV_SET_HDR(&cmd->tlv_header,
21209 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21210 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21211 cmd->vdev_id = params->vdev_id;
21212 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021213 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21214 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21215 cmd->stick_time_seconds = params->btm_sticky_time;
21216
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021217 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21218 WMI_ROAM_BTM_CONFIG_CMDID)) {
21219 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21220 __func__);
21221 wmi_buf_free(buf);
21222 return QDF_STATUS_E_FAILURE;
21223 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021224
21225 return QDF_STATUS_SUCCESS;
21226}
21227
21228/**
21229 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21230 * configurations to firmware.
21231 * @wmi_handle: wmi handle
21232 * @obss_cfg_param: obss detection configurations
21233 *
21234 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21235 *
21236 * Return: QDF_STATUS
21237 */
21238static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21239 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21240{
21241 wmi_buf_t buf;
21242 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21243 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21244
21245 buf = wmi_buf_alloc(wmi_handle, len);
21246 if (!buf) {
21247 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21248 return QDF_STATUS_E_NOMEM;
21249 }
21250
21251 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21252 WMITLV_SET_HDR(&cmd->tlv_header,
21253 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21254 WMITLV_GET_STRUCT_TLVLEN
21255 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21256
21257 cmd->vdev_id = obss_cfg_param->vdev_id;
21258 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21259 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21260 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21261 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21262 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21263 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21264 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21265 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
21266 WMI_LOGD("Sending WMI_SAP_OBSS_DETECTION_CFG_CMDID vdev_id:%d",
21267 cmd->vdev_id);
21268
21269 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21270 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21271 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21272 wmi_buf_free(buf);
21273 return QDF_STATUS_E_FAILURE;
21274 }
21275
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021276 return QDF_STATUS_SUCCESS;
21277}
21278
Arif Hussain33d98502018-01-12 13:15:04 -080021279/**
21280 * extract_obss_detection_info_tlv() - Extract obss detection info
21281 * received from firmware.
21282 * @evt_buf: pointer to event buffer
21283 * @obss_detection: Pointer to hold obss detection info
21284 *
21285 * Return: QDF_STATUS
21286 */
21287static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21288 struct wmi_obss_detect_info
21289 *obss_detection)
21290{
21291 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21292 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21293
21294 if (!obss_detection) {
21295 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21296 return QDF_STATUS_E_INVAL;
21297 }
21298
21299 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21300 if (!param_buf) {
21301 WMI_LOGE("%s: Invalid evt_buf", __func__);
21302 return QDF_STATUS_E_INVAL;
21303 }
21304
21305 fix_param = param_buf->fixed_param;
21306 obss_detection->vdev_id = fix_param->vdev_id;
21307 obss_detection->matched_detection_masks =
21308 fix_param->matched_detection_masks;
21309 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21310 &obss_detection->matched_bssid_addr[0]);
21311 switch (fix_param->reason) {
21312 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21313 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21314 break;
21315 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21316 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21317 break;
21318 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21319 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21320 break;
21321 default:
21322 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21323 return QDF_STATUS_E_INVAL;
21324 }
21325
21326 return QDF_STATUS_SUCCESS;
21327}
21328
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021329/**
21330 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21331 * @wmi_handle: wmi handler
21332 * @params: pointer to 11k offload params
21333 *
21334 * Return: 0 for success and non zero for failure
21335 */
21336static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21337 struct wmi_11k_offload_params *params)
21338{
21339 wmi_11k_offload_report_fixed_param *cmd;
21340 wmi_buf_t buf;
21341 QDF_STATUS status;
21342 uint8_t *buf_ptr;
21343 wmi_neighbor_report_11k_offload_tlv_param
21344 *neighbor_report_offload_params;
21345 wmi_neighbor_report_offload *neighbor_report_offload;
21346
21347 uint32_t len = sizeof(*cmd);
21348
21349 if (params->offload_11k_bitmask &
21350 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21351 len += WMI_TLV_HDR_SIZE +
21352 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21353
21354 buf = wmi_buf_alloc(wmi_handle, len);
21355 if (!buf) {
21356 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21357 __func__);
21358 return QDF_STATUS_E_NOMEM;
21359 }
21360
21361 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21362 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21363
21364 WMITLV_SET_HDR(&cmd->tlv_header,
21365 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21366 WMITLV_GET_STRUCT_TLVLEN(
21367 wmi_11k_offload_report_fixed_param));
21368
21369 cmd->vdev_id = params->vdev_id;
21370 cmd->offload_11k = params->offload_11k_bitmask;
21371
21372 if (params->offload_11k_bitmask &
21373 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21374 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21375
21376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21377 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21378 buf_ptr += WMI_TLV_HDR_SIZE;
21379
21380 neighbor_report_offload_params =
21381 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21382 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21383 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21384 WMITLV_GET_STRUCT_TLVLEN(
21385 wmi_neighbor_report_11k_offload_tlv_param));
21386
21387 neighbor_report_offload = &neighbor_report_offload_params->
21388 neighbor_rep_ofld_params;
21389
21390 neighbor_report_offload->time_offset =
21391 params->neighbor_report_params.time_offset;
21392 neighbor_report_offload->low_rssi_offset =
21393 params->neighbor_report_params.low_rssi_offset;
21394 neighbor_report_offload->bmiss_count_trigger =
21395 params->neighbor_report_params.bmiss_count_trigger;
21396 neighbor_report_offload->per_threshold_offset =
21397 params->neighbor_report_params.per_threshold_offset;
21398 neighbor_report_offload->neighbor_report_cache_timeout =
21399 params->neighbor_report_params.
21400 neighbor_report_cache_timeout;
21401 neighbor_report_offload->max_neighbor_report_req_cap =
21402 params->neighbor_report_params.
21403 max_neighbor_report_req_cap;
21404 neighbor_report_offload->ssid.ssid_len =
21405 params->neighbor_report_params.ssid.length;
21406 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21407 &params->neighbor_report_params.ssid.mac_ssid,
21408 neighbor_report_offload->ssid.ssid_len);
21409 }
21410
21411 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21412 WMI_11K_OFFLOAD_REPORT_CMDID);
21413 if (status != QDF_STATUS_SUCCESS) {
21414 WMI_LOGE("%s: failed to send 11k offload command %d",
21415 __func__, status);
21416 wmi_buf_free(buf);
21417 }
21418
21419 return status;
21420}
21421
21422/**
21423 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21424 * command
21425 * @wmi_handle: wmi handler
21426 * @params: pointer to neighbor report invoke params
21427 *
21428 * Return: 0 for success and non zero for failure
21429 */
21430static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21431 struct wmi_invoke_neighbor_report_params *params)
21432{
21433 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21434 wmi_buf_t buf;
21435 QDF_STATUS status;
21436 uint8_t *buf_ptr;
21437 uint32_t len = sizeof(*cmd);
21438
21439 buf = wmi_buf_alloc(wmi_handle, len);
21440 if (!buf) {
21441 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21442 __func__);
21443 return QDF_STATUS_E_NOMEM;
21444 }
21445
21446 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21447 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21448
21449 WMITLV_SET_HDR(&cmd->tlv_header,
21450 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21451 WMITLV_GET_STRUCT_TLVLEN(
21452 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21453
21454 cmd->vdev_id = params->vdev_id;
21455 cmd->flags = params->send_resp_to_host;
21456
21457 cmd->ssid.ssid_len = params->ssid.length;
21458 qdf_mem_copy(cmd->ssid.ssid,
21459 &params->ssid.mac_ssid,
21460 cmd->ssid.ssid_len);
21461
21462 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21463 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21464 if (status != QDF_STATUS_SUCCESS) {
21465 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21466 __func__, status);
21467 wmi_buf_free(buf);
21468 }
21469
21470 return status;
21471}
21472
Govind Singh5eb51532016-03-09 11:34:12 +053021473struct wmi_ops tlv_ops = {
21474 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21475 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21476 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021477 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21478 .send_hidden_ssid_vdev_restart_cmd =
21479 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021480 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21481 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21482 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021483 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021484 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021485 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021486 .send_peer_rx_reorder_queue_setup_cmd =
21487 send_peer_rx_reorder_queue_setup_cmd_tlv,
21488 .send_peer_rx_reorder_queue_remove_cmd =
21489 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021490 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21491 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21492 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021493 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21494 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
21495 .send_suspend_cmd = send_suspend_cmd_tlv,
21496 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021497#ifdef FEATURE_WLAN_D0WOW
21498 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21499 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21500#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021501 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21502 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21503 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21504 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
21505 .send_dbglog_cmd = send_dbglog_cmd_tlv,
21506 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21507 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21508 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021509 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021510 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021511 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021512 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21513 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21514 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21515 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021516 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021517 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021518 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21519 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021520 .send_set_sta_uapsd_auto_trig_cmd =
21521 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021522 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21523 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21524 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021525#ifdef CONVERGED_P2P_ENABLE
21526 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21527 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21528#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021529 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21530 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053021531 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21532 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21533 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21534 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21535 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21536 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21537 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021538 .send_ocb_start_timing_advert_cmd =
21539 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053021540 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21541 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21542 .send_set_mcc_channel_time_latency_cmd =
21543 send_set_mcc_channel_time_latency_cmd_tlv,
21544 .send_set_mcc_channel_time_quota_cmd =
21545 send_set_mcc_channel_time_quota_cmd_tlv,
21546 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21547 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021548 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021549 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21550 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21551 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021552 .send_probe_rsp_tmpl_send_cmd =
21553 send_probe_rsp_tmpl_send_cmd_tlv,
21554 .send_p2p_go_set_beacon_ie_cmd =
21555 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021556 .send_setup_install_key_cmd =
21557 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021558 .send_set_gateway_params_cmd =
21559 send_set_gateway_params_cmd_tlv,
21560 .send_set_rssi_monitoring_cmd =
21561 send_set_rssi_monitoring_cmd_tlv,
21562 .send_scan_probe_setoui_cmd =
21563 send_scan_probe_setoui_cmd_tlv,
21564 .send_reset_passpoint_network_list_cmd =
21565 send_reset_passpoint_network_list_cmd_tlv,
21566 .send_set_passpoint_network_list_cmd =
21567 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021568 .send_roam_scan_offload_rssi_thresh_cmd =
21569 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021570 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021571 .send_roam_scan_filter_cmd =
21572 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021573 .send_set_epno_network_list_cmd =
21574 send_set_epno_network_list_cmd_tlv,
21575 .send_ipa_offload_control_cmd =
21576 send_ipa_offload_control_cmd_tlv,
21577 .send_extscan_get_capabilities_cmd =
21578 send_extscan_get_capabilities_cmd_tlv,
21579 .send_extscan_get_cached_results_cmd =
21580 send_extscan_get_cached_results_cmd_tlv,
21581 .send_extscan_stop_change_monitor_cmd =
21582 send_extscan_stop_change_monitor_cmd_tlv,
21583 .send_extscan_start_change_monitor_cmd =
21584 send_extscan_start_change_monitor_cmd_tlv,
21585 .send_extscan_stop_hotlist_monitor_cmd =
21586 send_extscan_stop_hotlist_monitor_cmd_tlv,
21587 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
21588 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
21589 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21590 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21591 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21592 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021593 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021594 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
21595 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21596 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21597 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021598 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021599 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21600 .send_snr_cmd = send_snr_cmd_tlv,
21601 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021602#ifdef WLAN_PMO_ENABLE
21603 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21604 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21605 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21606 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021607 .send_multiple_add_clear_mcbc_filter_cmd =
21608 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021609 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021610 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21611 .send_process_gtk_offload_getinfo_cmd =
21612 send_process_gtk_offload_getinfo_cmd_tlv,
21613 .send_enable_enhance_multicast_offload_cmd =
21614 send_enable_enhance_multicast_offload_tlv,
21615 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21616#ifdef FEATURE_WLAN_RA_FILTERING
21617 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21618#endif
21619 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021620 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21621 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021622 .send_lphb_config_tcp_pkt_filter_cmd =
21623 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021624 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
21625 .send_lphb_config_udp_pkt_filter_cmd =
21626 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053021627 .send_enable_disable_packet_filter_cmd =
21628 send_enable_disable_packet_filter_cmd_tlv,
21629 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021630#endif /* End of WLAN_PMO_ENABLE */
21631#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053021632 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
21633 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021634 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021635 .send_roam_scan_offload_mode_cmd =
21636 send_roam_scan_offload_mode_cmd_tlv,
21637 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
21638 .send_roam_scan_offload_ap_profile_cmd =
21639 send_roam_scan_offload_ap_profile_cmd_tlv,
21640#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021641#ifdef WLAN_SUPPORT_GREEN_AP
21642 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
21643 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
21644#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053021645 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
21646 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021647 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080021648 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021649 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070021650#ifdef WLAN_FEATURE_CIF_CFR
21651 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
21652#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053021653 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021654 .send_dfs_phyerr_filter_offload_en_cmd =
21655 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021656 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
21657 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
21658 .send_del_ts_cmd = send_del_ts_cmd_tlv,
21659 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
21660 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021661 .send_process_add_periodic_tx_ptrn_cmd =
21662 send_process_add_periodic_tx_ptrn_cmd_tlv,
21663 .send_process_del_periodic_tx_ptrn_cmd =
21664 send_process_del_periodic_tx_ptrn_cmd_tlv,
21665 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
21666 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
21667 .send_set_app_type2_params_in_fw_cmd =
21668 send_set_app_type2_params_in_fw_cmd_tlv,
21669 .send_set_auto_shutdown_timer_cmd =
21670 send_set_auto_shutdown_timer_cmd_tlv,
21671 .send_nan_req_cmd = send_nan_req_cmd_tlv,
21672 .send_process_dhcpserver_offload_cmd =
21673 send_process_dhcpserver_offload_cmd_tlv,
21674 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
21675 .send_process_ch_avoid_update_cmd =
21676 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053021677 .send_pdev_set_regdomain_cmd =
21678 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021679 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
21680 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
21681 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
21682 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021683 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053021684 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021685 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053021686 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021687 .send_set_base_macaddr_indicate_cmd =
21688 send_set_base_macaddr_indicate_cmd_tlv,
21689 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
21690 .send_enable_specific_fw_logs_cmd =
21691 send_enable_specific_fw_logs_cmd_tlv,
21692 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053021693 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053021694 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053021695 .send_pdev_set_dual_mac_config_cmd =
21696 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021697 .send_app_type1_params_in_fw_cmd =
21698 send_app_type1_params_in_fw_cmd_tlv,
21699 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
21700 .send_process_roam_synch_complete_cmd =
21701 send_process_roam_synch_complete_cmd_tlv,
21702 .send_unit_test_cmd = send_unit_test_cmd_tlv,
21703 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
21704 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021705 .send_roam_scan_offload_scan_period_cmd =
21706 send_roam_scan_offload_scan_period_cmd_tlv,
21707 .send_roam_scan_offload_chan_list_cmd =
21708 send_roam_scan_offload_chan_list_cmd_tlv,
21709 .send_roam_scan_offload_rssi_change_cmd =
21710 send_roam_scan_offload_rssi_change_cmd_tlv,
21711 .send_get_buf_extscan_hotlist_cmd =
21712 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080021713 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053021714 .send_adapt_dwelltime_params_cmd =
21715 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053021716 .send_dbs_scan_sel_params_cmd =
21717 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021718 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021719 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
21720 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
21721 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
21722 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
21723 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
21724 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053021725 .send_vdev_set_custom_aggr_size_cmd =
21726 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053021727 .send_vdev_set_qdepth_thresh_cmd =
21728 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021729 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
21730 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
21731 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053021732 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
21733 .send_smart_ant_set_training_info_cmd =
21734 send_smart_ant_set_training_info_cmd_tlv,
21735 .send_smart_ant_set_node_config_cmd =
21736 send_smart_ant_set_node_config_cmd_tlv,
21737 .send_set_atf_cmd = send_set_atf_cmd_tlv,
21738 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
21739 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021740 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
21741 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
21742 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
21743 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053021744 .send_periodic_chan_stats_config_cmd =
21745 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021746 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
21747 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
21748 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021749 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
21750 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
21751 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
21752 .send_vdev_spectral_configure_cmd =
21753 send_vdev_spectral_configure_cmd_tlv,
21754 .send_vdev_spectral_enable_cmd =
21755 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021756 .send_thermal_mitigation_param_cmd =
21757 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021758 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
21759 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053021760 .send_process_update_edca_param_cmd =
21761 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053021762 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021763 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053021764 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080021765 .send_addba_send_cmd = send_addba_send_cmd_tlv,
21766 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080021767 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021768 .get_target_cap_from_service_ready = extract_service_ready_tlv,
21769 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
21770 .extract_host_mem_req = extract_host_mem_req_tlv,
21771 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053021772 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021773 .is_service_enabled = is_service_enabled_tlv,
21774 .save_fw_version = save_fw_version_in_service_ready_tlv,
21775 .ready_extract_init_status = ready_extract_init_status_tlv,
21776 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070021777 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053021778 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021779 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
21780 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053021781 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021782 .extract_tbttoffset_update_params =
21783 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021784 .extract_ext_tbttoffset_update_params =
21785 extract_ext_tbttoffset_update_params_tlv,
21786 .extract_tbttoffset_num_vdevs =
21787 extract_tbttoffset_num_vdevs_tlv,
21788 .extract_ext_tbttoffset_num_vdevs =
21789 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021790 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
21791 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
21792 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
21793 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080021794#ifdef CONVERGED_TDLS_ENABLE
21795 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
21796#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053021797 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021798 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021799 .extract_swba_tim_info = extract_swba_tim_info_tlv,
21800 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021801#ifdef CONVERGED_P2P_ENABLE
21802 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
21803 .extract_p2p_lo_stop_ev_param =
21804 extract_p2p_lo_stop_ev_param_tlv,
21805#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021806 .extract_offchan_data_tx_compl_param =
21807 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021808 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
21809 .extract_all_stats_count = extract_all_stats_counts_tlv,
21810 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070021811 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021812 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
21813 .extract_vdev_stats = extract_vdev_stats_tlv,
21814 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053021815 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021816 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
21817 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
21818 .extract_chan_stats = extract_chan_stats_tlv,
21819 .extract_profile_ctx = extract_profile_ctx_tlv,
21820 .extract_profile_data = extract_profile_data_tlv,
21821 .extract_chan_info_event = extract_chan_info_event_tlv,
21822 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053021823 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053021824#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053021825 .send_encrypt_decrypt_send_cmd =
21826 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053021827 .extract_encrypt_decrypt_resp_event =
21828 extract_encrypt_decrypt_resp_event_tlv,
21829#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080021830 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080021831 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
21832 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053021833 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053021834 .send_multiple_vdev_restart_req_cmd =
21835 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053021836 .extract_service_ready_ext = extract_service_ready_ext_tlv,
21837 .extract_hw_mode_cap_service_ready_ext =
21838 extract_hw_mode_cap_service_ready_ext_tlv,
21839 .extract_mac_phy_cap_service_ready_ext =
21840 extract_mac_phy_cap_service_ready_ext_tlv,
21841 .extract_reg_cap_service_ready_ext =
21842 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053021843 .extract_dbr_ring_cap_service_ready_ext =
21844 extract_dbr_ring_cap_service_ready_ext_tlv,
21845 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
21846 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053021847 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053021848 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053021849 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
21850 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
21851 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053021852 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053021853 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053021854 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021855 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053021856 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053021857 .extract_pdev_csa_switch_count_status =
21858 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053021859 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
21860 .extract_wds_addr_event = extract_wds_addr_event_tlv,
21861 .extract_peer_sta_ps_statechange_ev =
21862 extract_peer_sta_ps_statechange_ev_tlv,
21863 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053021864 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080021865 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
21866 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021867 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053021868 extract_reg_chan_list_update_event_tlv,
21869 .extract_chainmask_tables =
21870 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021871 .extract_thermal_stats = extract_thermal_stats_tlv,
21872 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021873 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
21874 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021875#ifdef DFS_COMPONENT_ENABLE
21876 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
21877 .extract_dfs_radar_detection_event =
21878 extract_dfs_radar_detection_event_tlv,
21879#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021880 .convert_pdev_id_host_to_target =
21881 convert_host_pdev_id_to_target_pdev_id_legacy,
21882 .convert_pdev_id_target_to_host =
21883 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070021884
21885 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
21886 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
21887 .extract_reg_11d_new_country_event =
21888 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021889 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021890 .send_limit_off_chan_cmd =
21891 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070021892 .extract_reg_ch_avoid_event =
21893 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021894 .send_pdev_caldata_version_check_cmd =
21895 send_pdev_caldata_version_check_cmd_tlv,
21896 .extract_pdev_caldata_version_check_ev_param =
21897 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053021898 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
21899 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021900 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
21901#if defined(WLAN_FEATURE_FILS_SK)
21902 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
21903#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070021904 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080021905#ifdef WLAN_FEATURE_NAN_CONVERGENCE
21906 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
21907 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
21908 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
21909 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
21910 .extract_ndp_ind = extract_ndp_ind_tlv,
21911 .extract_ndp_confirm = extract_ndp_confirm_tlv,
21912 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
21913 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
21914 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
21915#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021916 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080021917 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080021918 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053021919#ifdef WLAN_SUPPORT_FILS
21920 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
21921 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
21922 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
21923#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021924 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
21925 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021926};
21927
Govind Singhe7f2f342016-05-23 12:12:52 +053021928/**
21929 * populate_tlv_event_id() - populates wmi event ids
21930 *
21931 * @param event_ids: Pointer to hold event ids
21932 * Return: None
21933 */
21934static void populate_tlv_events_id(uint32_t *event_ids)
21935{
21936 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
21937 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
21938 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
21939 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
21940 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
21941 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
21942 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
21943 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
21944 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
21945 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
21946 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
21947 event_ids[wmi_service_ready_ext_event_id] =
21948 WMI_SERVICE_READY_EXT_EVENTID;
21949 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
21950 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
21951 event_ids[wmi_vdev_install_key_complete_event_id] =
21952 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
21953 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
21954 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
21955
21956 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
21957 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
21958 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
21959 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
21960 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
21961 event_ids[wmi_peer_estimated_linkspeed_event_id] =
21962 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
21963 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053021964 event_ids[wmi_peer_delete_response_event_id] =
21965 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021966 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
21967 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
21968 event_ids[wmi_tbttoffset_update_event_id] =
21969 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053021970 event_ids[wmi_ext_tbttoffset_update_event_id] =
21971 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021972 event_ids[wmi_offload_bcn_tx_status_event_id] =
21973 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
21974 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
21975 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
21976 event_ids[wmi_mgmt_tx_completion_event_id] =
21977 WMI_MGMT_TX_COMPLETION_EVENTID;
21978
21979 event_ids[wmi_tx_delba_complete_event_id] =
21980 WMI_TX_DELBA_COMPLETE_EVENTID;
21981 event_ids[wmi_tx_addba_complete_event_id] =
21982 WMI_TX_ADDBA_COMPLETE_EVENTID;
21983 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
21984
21985 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
21986
21987 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
21988 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
21989
21990 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053021991 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021992
21993 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
21994
21995 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080021996 event_ids[wmi_p2p_lo_stop_event_id] =
21997 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053021998 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
21999 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022000 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022001 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22002 event_ids[wmi_wow_initial_wakeup_event_id] =
22003 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22004
22005 event_ids[wmi_rtt_meas_report_event_id] =
22006 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22007 event_ids[wmi_tsf_meas_report_event_id] =
22008 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22009 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22010 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22011 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22012 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22013 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022014 event_ids[wmi_diag_event_id_log_supported_event_id] =
22015 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22016 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22017 event_ids[wmi_nlo_scan_complete_event_id] =
22018 WMI_NLO_SCAN_COMPLETE_EVENTID;
22019 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22020 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22021
22022 event_ids[wmi_gtk_offload_status_event_id] =
22023 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22024 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22025 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22026 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22027
22028 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22029
22030 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22031
22032 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22033 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22034 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22035 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22036 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22037 event_ids[wmi_wlan_profile_data_event_id] =
22038 WMI_WLAN_PROFILE_DATA_EVENTID;
22039 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22040 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22041 event_ids[wmi_vdev_get_keepalive_event_id] =
22042 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22043 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22044
22045 event_ids[wmi_diag_container_event_id] =
22046 WMI_DIAG_DATA_CONTAINER_EVENTID;
22047
22048 event_ids[wmi_host_auto_shutdown_event_id] =
22049 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22050
22051 event_ids[wmi_update_whal_mib_stats_event_id] =
22052 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22053
22054 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22055 event_ids[wmi_update_vdev_rate_stats_event_id] =
22056 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22057
22058 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022059 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022060
22061 /** Set OCB Sched Response, deprecated */
22062 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22063
22064 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22065 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22066 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22067
22068 /* GPIO Event */
22069 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22070 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22071
22072 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22073 event_ids[wmi_rfkill_state_change_event_id] =
22074 WMI_RFKILL_STATE_CHANGE_EVENTID;
22075
22076 /* TDLS Event */
22077 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22078
22079 event_ids[wmi_batch_scan_enabled_event_id] =
22080 WMI_BATCH_SCAN_ENABLED_EVENTID;
22081 event_ids[wmi_batch_scan_result_event_id] =
22082 WMI_BATCH_SCAN_RESULT_EVENTID;
22083 /* OEM Event */
22084 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22085 event_ids[wmi_oem_meas_report_event_id] =
22086 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22087 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22088
22089 /* NAN Event */
22090 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22091
22092 /* LPI Event */
22093 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22094 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22095 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22096
22097 /* ExtScan events */
22098 event_ids[wmi_extscan_start_stop_event_id] =
22099 WMI_EXTSCAN_START_STOP_EVENTID;
22100 event_ids[wmi_extscan_operation_event_id] =
22101 WMI_EXTSCAN_OPERATION_EVENTID;
22102 event_ids[wmi_extscan_table_usage_event_id] =
22103 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22104 event_ids[wmi_extscan_cached_results_event_id] =
22105 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22106 event_ids[wmi_extscan_wlan_change_results_event_id] =
22107 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22108 event_ids[wmi_extscan_hotlist_match_event_id] =
22109 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22110 event_ids[wmi_extscan_capabilities_event_id] =
22111 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22112 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22113 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22114
22115 /* mDNS offload events */
22116 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22117
22118 /* SAP Authentication offload events */
22119 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22120 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22121
22122 /** Out-of-context-of-bss (OCB) events */
22123 event_ids[wmi_ocb_set_config_resp_event_id] =
22124 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22125 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22126 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22127 event_ids[wmi_dcc_get_stats_resp_event_id] =
22128 WMI_DCC_GET_STATS_RESP_EVENTID;
22129 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22130 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22131 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22132 /* System-On-Chip events */
22133 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22134 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22135 event_ids[wmi_soc_hw_mode_transition_event_id] =
22136 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22137 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22138 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022139 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022140 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22141 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022142 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022143 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22144 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22145 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22146 WMI_PEER_STA_PS_STATECHG_EVENTID;
22147 event_ids[wmi_pdev_channel_hopping_event_id] =
22148 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022149 event_ids[wmi_offchan_data_tx_completion_event] =
22150 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022151 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22152 event_ids[wmi_dfs_radar_detection_event_id] =
22153 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022154 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022155 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022156 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022157 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022158 event_ids[wmi_service_available_event_id] =
22159 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022160 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022161 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022162 /* NDP events */
22163 event_ids[wmi_ndp_initiator_rsp_event_id] =
22164 WMI_NDP_INITIATOR_RSP_EVENTID;
22165 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22166 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22167 event_ids[wmi_ndp_responder_rsp_event_id] =
22168 WMI_NDP_RESPONDER_RSP_EVENTID;
22169 event_ids[wmi_ndp_end_indication_event_id] =
22170 WMI_NDP_END_INDICATION_EVENTID;
22171 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
22172
22173 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22174 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22175 event_ids[wmi_pdev_chip_power_stats_event_id] =
22176 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22177 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22178 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22179 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
22180 event_ids[wmi_bpf_capability_info_event_id] =
22181 WMI_BPF_CAPABILIY_INFO_EVENTID;
22182 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22183 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22184 event_ids[wmi_report_rx_aggr_failure_event_id] =
22185 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22186 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22187 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22188 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22189 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22190 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22191 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22192 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22193 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22194 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22195 event_ids[wmi_coex_bt_activity_event_id] =
22196 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22197 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22198 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22199 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22200 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22201 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022202 event_ids[wmi_dma_buf_release_event_id] =
22203 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022204 event_ids[wmi_sap_obss_detection_report_event_id] =
22205 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022206 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022207 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022208}
22209
Soumya Bhat488092d2017-03-22 14:41:01 +053022210/**
22211 * populate_tlv_service() - populates wmi services
22212 *
22213 * @param wmi_service: Pointer to hold wmi_service
22214 * Return: None
22215 */
22216static void populate_tlv_service(uint32_t *wmi_service)
22217{
22218 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022219 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022220 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22221 wmi_service[wmi_service_roam_scan_offload] =
22222 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22223 wmi_service[wmi_service_bcn_miss_offload] =
22224 WMI_SERVICE_BCN_MISS_OFFLOAD;
22225 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22226 wmi_service[wmi_service_sta_advanced_pwrsave] =
22227 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22228 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22229 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22230 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22231 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22232 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22233 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22234 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22235 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22236 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22237 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22238 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22239 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22240 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22241 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22242 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22243 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22244 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22245 wmi_service[wmi_service_packet_power_save] =
22246 WMI_SERVICE_PACKET_POWER_SAVE;
22247 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22248 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22249 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22250 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22251 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22252 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22253 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22254 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22255 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22256 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22257 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22258 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22259 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22260 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22261 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22262 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22263 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22264 wmi_service[wmi_service_mcc_bcn_interval_change] =
22265 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22266 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22267 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22268 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22269 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22270 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22271 wmi_service[wmi_service_lte_ant_share_support] =
22272 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22273 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22274 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22275 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22276 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22277 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22278 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22279 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22280 wmi_service[wmi_service_bcn_txrate_override] =
22281 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22282 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22283 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22284 wmi_service[wmi_service_estimate_linkspeed] =
22285 WMI_SERVICE_ESTIMATE_LINKSPEED;
22286 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22287 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22288 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22289 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22290 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22291 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22292 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22293 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22294 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22295 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22296 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22297 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22298 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22299 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22300 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22301 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22302 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22303 wmi_service[wmi_service_sap_auth_offload] =
22304 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22305 wmi_service[wmi_service_dual_band_simultaneous_support] =
22306 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22307 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22308 wmi_service[wmi_service_ap_arpns_offload] =
22309 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22310 wmi_service[wmi_service_per_band_chainmask_support] =
22311 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22312 wmi_service[wmi_service_packet_filter_offload] =
22313 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22314 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22315 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22316 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22317 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22318 wmi_service[wmi_service_multiple_vdev_restart] =
22319 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22320
22321 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22322 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22323 wmi_service[wmi_service_smart_antenna_sw_support] =
22324 WMI_SERVICE_UNAVAILABLE;
22325 wmi_service[wmi_service_smart_antenna_hw_support] =
22326 WMI_SERVICE_UNAVAILABLE;
22327 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022328 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022329 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022330 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22331 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22332 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22333 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22334 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22335 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22336 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22337 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022338 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22339 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22340 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022341 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022342 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22343 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22344 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22345 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22346 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22347 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022348 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22349 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22350 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22351 wmi_service[wmi_service_unified_wow_capability] =
22352 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22353 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
22354 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
22355 wmi_service[wmi_service_sync_delete_cmds] =
22356 WMI_SERVICE_SYNC_DELETE_CMDS;
22357 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22358 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22359 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22360 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22361 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22362 wmi_service[wmi_service_deprecated_replace] =
22363 WMI_SERVICE_DEPRECATED_REPLACE;
22364 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22365 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22366 wmi_service[wmi_service_enhanced_mcast_filter] =
22367 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22368 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22369 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22370 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22371 wmi_service[wmi_service_p2p_listen_offload_support] =
22372 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22373 wmi_service[wmi_service_mark_first_wakeup_packet] =
22374 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22375 wmi_service[wmi_service_multiple_mcast_filter_set] =
22376 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22377 wmi_service[wmi_service_host_managed_rx_reorder] =
22378 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22379 wmi_service[wmi_service_flash_rdwr_support] =
22380 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22381 wmi_service[wmi_service_wlan_stats_report] =
22382 WMI_SERVICE_WLAN_STATS_REPORT;
22383 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22384 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22385 wmi_service[wmi_service_dfs_phyerr_offload] =
22386 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22387 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22388 wmi_service[wmi_service_fw_mem_dump_support] =
22389 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22390 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22391 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22392 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22393 wmi_service[wmi_service_hw_data_filtering] =
22394 WMI_SERVICE_HW_DATA_FILTERING;
22395 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22396 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022397 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022398 wmi_service[wmi_service_extended_nss_support] =
22399 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022400 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022401 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22402 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022403 wmi_service[wmi_service_offchan_data_tid_support] =
22404 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022405 wmi_service[wmi_service_support_dma] =
22406 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022407 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22408 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22409 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
22410
Soumya Bhat488092d2017-03-22 14:41:01 +053022411}
22412
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022413#ifndef CONFIG_MCL
22414
Govind Singhe7f2f342016-05-23 12:12:52 +053022415/**
22416 * populate_pdev_param_tlv() - populates pdev params
22417 *
22418 * @param pdev_param: Pointer to hold pdev params
22419 * Return: None
22420 */
22421static void populate_pdev_param_tlv(uint32_t *pdev_param)
22422{
22423 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22424 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22425 pdev_param[wmi_pdev_param_txpower_limit2g] =
22426 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22427 pdev_param[wmi_pdev_param_txpower_limit5g] =
22428 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22429 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22430 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22431 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22432 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22433 WMI_PDEV_PARAM_BEACON_TX_MODE;
22434 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22435 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22436 pdev_param[wmi_pdev_param_protection_mode] =
22437 WMI_PDEV_PARAM_PROTECTION_MODE;
22438 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22439 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22440 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22441 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22442 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22443 pdev_param[wmi_pdev_param_sta_kickout_th] =
22444 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22445 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22446 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22447 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22448 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22449 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22450 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22451 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22452 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22453 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22454 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22455 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22456 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22457 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22458 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22459 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22460 pdev_param[wmi_pdev_param_ltr_rx_override] =
22461 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22462 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22463 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22464 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22465 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22466 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22467 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22468 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22469 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22470 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22471 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22472 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22473 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22474 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22475 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22476 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22477 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22478 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22479 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22480 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22481 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22482 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22483 pdev_param[wmi_pdev_param_arp_ac_override] =
22484 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22485 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22486 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22487 pdev_param[wmi_pdev_param_ani_poll_period] =
22488 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22489 pdev_param[wmi_pdev_param_ani_listen_period] =
22490 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22491 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22492 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22493 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22494 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22495 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22496 pdev_param[wmi_pdev_param_idle_ps_config] =
22497 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22498 pdev_param[wmi_pdev_param_power_gating_sleep] =
22499 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22500 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22501 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22502 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22503 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22504 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22505 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22506 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22507 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22508 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22509 pdev_param[wmi_pdev_param_power_collapse_enable] =
22510 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22511 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22512 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22513 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22514 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22515 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22516 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22517 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22518 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22519 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22520 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22521 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22522 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22523 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22524 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22525 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22526 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22527 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22528 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22529 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22530 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22531 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22532 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22533 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22534 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22535 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22536 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22537 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22538 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22539 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22540 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22541 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22542 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22543 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22544 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22545 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22546 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22547 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22548 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22549 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
22550 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
22551 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
22552 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
22553 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
22554 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022555 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
22556 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
22557 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053022558 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
22559 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022560 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053022561 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022562 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
22563 pdev_param[wmi_pdev_param_proxy_sta_mode] =
22564 WMI_PDEV_PARAM_PROXY_STA_MODE;
22565 pdev_param[wmi_pdev_param_mu_group_policy] =
22566 WMI_PDEV_PARAM_MU_GROUP_POLICY;
22567 pdev_param[wmi_pdev_param_noise_detection] =
22568 WMI_PDEV_PARAM_NOISE_DETECTION;
22569 pdev_param[wmi_pdev_param_noise_threshold] =
22570 WMI_PDEV_PARAM_NOISE_THRESHOLD;
22571 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
22572 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
22573 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022574 pdev_param[wmi_pdev_param_atf_strict_sch] =
22575 WMI_PDEV_PARAM_ATF_STRICT_SCH;
22576 pdev_param[wmi_pdev_param_atf_sched_duration] =
22577 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022578 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
22579 pdev_param[wmi_pdev_param_sensitivity_level] =
22580 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
22581 pdev_param[wmi_pdev_param_signed_txpower_2g] =
22582 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
22583 pdev_param[wmi_pdev_param_signed_txpower_5g] =
22584 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070022585 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
22586 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
22587 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
22588 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022589 pdev_param[wmi_pdev_param_cca_threshold] =
22590 WMI_PDEV_PARAM_CCA_THRESHOLD;
22591 pdev_param[wmi_pdev_param_rts_fixed_rate] =
22592 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022593 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022594 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
22595 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
22596 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
22597 pdev_param[wmi_pdev_param_arp_srcaddr] =
22598 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
22599 pdev_param[wmi_pdev_param_arp_dstaddr] =
22600 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
22601 pdev_param[wmi_pdev_param_txpower_decr_db] =
22602 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053022603 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
22604 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022605 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
22606 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053022607 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022608 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022609 pdev_param[wmi_pdev_param_cust_txpower_scale] =
22610 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022611 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
22612 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022613 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
22614 WMI_UNAVAILABLE_PARAM;
22615 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
22616 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022617 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
22618 pdev_param[wmi_pdev_param_block_interbss] =
22619 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053022620 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022621 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
22622 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
22623 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022624 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022625 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053022626 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
22627 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022628 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053022629 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
22630 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053022631 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
22632 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
22633 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
22634 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
22635 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
22636 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
22637 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
22638 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
22639 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
22640 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
22641 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
22642 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
22643 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
22644 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
22645 pdev_param[wmi_pdev_param_fast_channel_reset] =
22646 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
22647 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022648 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053022649}
22650
22651/**
22652 * populate_vdev_param_tlv() - populates vdev params
22653 *
22654 * @param vdev_param: Pointer to hold vdev params
22655 * Return: None
22656 */
22657static void populate_vdev_param_tlv(uint32_t *vdev_param)
22658{
22659 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
22660 vdev_param[wmi_vdev_param_fragmentation_threshold] =
22661 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
22662 vdev_param[wmi_vdev_param_beacon_interval] =
22663 WMI_VDEV_PARAM_BEACON_INTERVAL;
22664 vdev_param[wmi_vdev_param_listen_interval] =
22665 WMI_VDEV_PARAM_LISTEN_INTERVAL;
22666 vdev_param[wmi_vdev_param_multicast_rate] =
22667 WMI_VDEV_PARAM_MULTICAST_RATE;
22668 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
22669 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
22670 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
22671 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
22672 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
22673 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
22674 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
22675 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
22676 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
22677 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
22678 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
22679 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
22680 vdev_param[wmi_vdev_param_bmiss_count_max] =
22681 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
22682 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
22683 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
22684 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
22685 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
22686 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
22687 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
22688 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
22689 vdev_param[wmi_vdev_param_disable_htprotection] =
22690 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
22691 vdev_param[wmi_vdev_param_sta_quickkickout] =
22692 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
22693 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
22694 vdev_param[wmi_vdev_param_protection_mode] =
22695 WMI_VDEV_PARAM_PROTECTION_MODE;
22696 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
22697 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
22698 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
22699 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
22700 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
22701 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
22702 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
22703 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
22704 vdev_param[wmi_vdev_param_bcast_data_rate] =
22705 WMI_VDEV_PARAM_BCAST_DATA_RATE;
22706 vdev_param[wmi_vdev_param_mcast_data_rate] =
22707 WMI_VDEV_PARAM_MCAST_DATA_RATE;
22708 vdev_param[wmi_vdev_param_mcast_indicate] =
22709 WMI_VDEV_PARAM_MCAST_INDICATE;
22710 vdev_param[wmi_vdev_param_dhcp_indicate] =
22711 WMI_VDEV_PARAM_DHCP_INDICATE;
22712 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
22713 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
22714 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
22715 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
22716 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
22717 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
22718 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
22719 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
22720 vdev_param[wmi_vdev_param_ap_enable_nawds] =
22721 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
22722 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
22723 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
22724 vdev_param[wmi_vdev_param_packet_powersave] =
22725 WMI_VDEV_PARAM_PACKET_POWERSAVE;
22726 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
22727 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
22728 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
22729 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
22730 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
22731 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
22732 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
22733 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
22734 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
22735 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
22736 vdev_param[wmi_vdev_param_early_rx_slop_step] =
22737 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
22738 vdev_param[wmi_vdev_param_early_rx_init_slop] =
22739 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
22740 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
22741 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
22742 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
22743 vdev_param[wmi_vdev_param_snr_num_for_cal] =
22744 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
22745 vdev_param[wmi_vdev_param_roam_fw_offload] =
22746 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
22747 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
22748 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
22749 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
22750 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
22751 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
22752 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
22753 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
22754 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
22755 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
22756 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
22757 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
22758 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
22759 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
22760 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
22761 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
22762 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
22763 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
22764 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
22765 vdev_param[wmi_vdev_param_inactivity_cnt] =
22766 WMI_VDEV_PARAM_INACTIVITY_CNT;
22767 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
22768 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
22769 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
22770 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
22771 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
22772 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
22773 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
22774 vdev_param[wmi_vdev_param_rx_leak_window] =
22775 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
22776 vdev_param[wmi_vdev_param_stats_avg_factor] =
22777 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
22778 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
22779 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
22780 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
22781 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
22782 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
22783 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053022784 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
22785 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053022786 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080022787 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
22788 vdev_param[wmi_vdev_param_he_range_ext_enable] =
22789 WMI_VDEV_PARAM_HE_RANGE_EXT;
22790 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
22791 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070022792 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053022793 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
22794 vdev_param[wmi_vdev_param_dtim_enable_cts] =
22795 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
22796 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
22797 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
22798 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
22799 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053022800 vdev_param[wmi_vdev_param_mcast2ucast_set] =
22801 WMI_VDEV_PARAM_MCAST2UCAST_SET;
22802 vdev_param[wmi_vdev_param_rc_num_retries] =
22803 WMI_VDEV_PARAM_RC_NUM_RETRIES;
22804 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
22805 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
22806 vdev_param[wmi_vdev_param_rts_fixed_rate] =
22807 WMI_VDEV_PARAM_RTS_FIXED_RATE;
22808 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
22809 vdev_param[wmi_vdev_param_vht80_ratemask] =
22810 WMI_VDEV_PARAM_VHT80_RATEMASK;
22811 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
22812 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
22813 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika88e11832017-09-18 15:59:34 -070022814 vdev_param[wmi_vdev_param_set_he_ltf] = WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053022815 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
22816 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Govind Singhe7f2f342016-05-23 12:12:52 +053022817}
22818#endif
22819
Govind Singh5eb51532016-03-09 11:34:12 +053022820/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022821 * populate_target_defines_tlv() - Populate target defines and params
22822 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053022823 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022824 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053022825 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053022826#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022827static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053022828{
Govind Singhe7f2f342016-05-23 12:12:52 +053022829 populate_pdev_param_tlv(wmi_handle->pdev_param);
22830 populate_vdev_param_tlv(wmi_handle->vdev_param);
22831}
22832#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022833static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
22834{ }
22835#endif
22836
22837/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022838 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
22839 * host to target defines.
22840 * @param pdev_id: host pdev_id to be converted.
22841 * Return: target pdev_id after conversion.
22842 */
22843static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
22844{
22845 switch (pdev_id) {
22846 case WMI_HOST_PDEV_ID_SOC:
22847 return WMI_PDEV_ID_SOC;
22848 case WMI_HOST_PDEV_ID_0:
22849 return WMI_PDEV_ID_1ST;
22850 case WMI_HOST_PDEV_ID_1:
22851 return WMI_PDEV_ID_2ND;
22852 case WMI_HOST_PDEV_ID_2:
22853 return WMI_PDEV_ID_3RD;
22854 }
22855
22856 QDF_ASSERT(0);
22857
22858 return WMI_PDEV_ID_SOC;
22859}
22860
22861/**
22862 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
22863 * target to host defines.
22864 * @param pdev_id: target pdev_id to be converted.
22865 * Return: host pdev_id after conversion.
22866 */
22867static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
22868{
22869 switch (pdev_id) {
22870 case WMI_PDEV_ID_SOC:
22871 return WMI_HOST_PDEV_ID_SOC;
22872 case WMI_PDEV_ID_1ST:
22873 return WMI_HOST_PDEV_ID_0;
22874 case WMI_PDEV_ID_2ND:
22875 return WMI_HOST_PDEV_ID_1;
22876 case WMI_PDEV_ID_3RD:
22877 return WMI_HOST_PDEV_ID_2;
22878 }
22879
22880 QDF_ASSERT(0);
22881
22882 return WMI_HOST_PDEV_ID_SOC;
22883}
22884
22885/**
22886 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
22887 *
22888 * Return None.
22889 */
22890void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
22891{
22892 wmi_handle->ops->convert_pdev_id_host_to_target =
22893 convert_host_pdev_id_to_target_pdev_id;
22894 wmi_handle->ops->convert_pdev_id_target_to_host =
22895 convert_target_pdev_id_to_host_pdev_id;
22896}
22897/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022898 * wmi_tlv_attach() - Attach TLV APIs
22899 *
22900 * Return: None
22901 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022902void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053022903{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053022904 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053022905#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053022906 /* Skip saving WMI_CMD_HDR and TLV HDR */
22907 wmi_handle->log_info.buf_offset_command = 8;
22908 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053022909 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053022910#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053022911 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022912 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022913 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053022914}